ISA的字长是如何在硬件和软件中实现的?
我了解到字长是 ISA 的一项功能,必须在硬件和软件中实现。我对答案只有一个模糊的想法。我需要更正或确认。字长是否成为CPU中通用寄存器的大小?对于编译器来说,字长是否会变成“int”的大小(只是普通的 int,而不是长或短)?
I have learnt that word-length is an ISA feature, which has to be implemented in hardware and software both. I have a vague idea only about the answer. I need correction or confirmation. Does the word-length becomes size of the general purpose register in the CPU? Does the word-length become the size of the 'int'(just plain int, not long or short) for a compiler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
字长度是系统本机处理的位数。目前常见的版本是 32 位字和 64 位字。
例如,一个字节可以保存 0 到 255 之间的数字。但是,32 位整数的范围是 0 到 4,294,967,295。整数是系统的本机“字大小”,因此在 32 位系统中为 4 字节宽,因此远大于 0-255。
事实上,在许多系统/编译器/等中。小于系统本机字大小的类型会转换为该字大小,因为它比尝试将多个值放入单个字更有效。例如,布尔值可以用单个位表示。但是,如果您编写一个使用 32 个布尔值的软件,它不会将它们全部压缩到一个单词中。当每个在金属上运行时,都会被分配自己的单词。
The word length is the number of bits natively handled by the system. Common versions right now are 32-bit words and 64-bit words.
For example, a byte can hold a number from 0-255. However, a 32-bit integer is from 0-4,294,967,295. An integer is the native "word size" of the system, so is 4-bytes wide in 32-bit systems and therefore is considerably larger than 0-255.
In fact, in many systems/compilers/etc. types which are smaller than a system's native word size are converted to that word size simply because it's more efficient than trying to put multiple values into a single word. A boolean, for example, can be represented by a single bit. However, if you write a piece of software that uses 32 boolean values, it's not going to squeeze them all into a single word. Each will be assigned its own word when it runs on the metal.
我冒昧地将这个问题解释为 C 或 C++ 计算机上整数的大小。在这种情况下,此链接将有所帮助 - int 的大小是否取决于编译器和/或处理器?。
然而,如果从字面上看,那么CPU的字大小应该是其寄存器的大小。
I am taking liberty and interpreting this question as size of integer on a computer in C or C++. In that case this link will help - Does the size of an int depend on the compiler and/or processor?.
However if read it literally then size of word of CPU should be size of its register.
硬件实现:字长是CPU一次读取的字节数,也可以称为机器的自然大小。尽管计算机没有任何自然的东西。在实现中它也成为 CPU 寄存器的大小,因为它需要寄存器来存储它所获取的内容。话虽如此,可以使用更大的寄存器来进行存储。 IA-32 软件(字长 32 位)可以在 x86-64(字长 64 位)上运行。 软件实现:字长变成“int”的大小(只是普通的int,而不是长、短)
Hardware implementation : Word-length is the number of bytes fetched by the CPU at a time and can also be called the natural size of the machine. though there is nothing natural about the computers. it also becomes size of the CPU's register in implementation, since it needs registers to store what it fetches. Having said that, it is possible to use a bigger register for storing purpose. IA-32 softwares (with word length 32bits) can run on x86-64 (with word length 64 bits). Software implementation: word-length becomes the size of 'int' (just plain int, not long,short)