问题描述
这是什么意思:我只有 12 位的立即数,所以我可以只表示 0 到 2^12 = 4096 的立即数吗?操作数 2 ,如果它是一个寄存器,可以有 32 位,但为什么立即常量只有 12 位?这个数字是从哪里来的?
what does it mean : I have only 12 bits for immediate constants, so can I represent immediate constants only from 0 to 2^12 = 4096 ? Operand 2 , if it's a register, can have 32 bits, but why only 12 bits for immediate constants? Where does this number come from?
推荐答案
它由指令集定义.例如.MOV
指令被编码为
It defined by the instruction set. E.g. the MOV
instruction is encoded as
31 28 | 27 26 | 25 | 24 23 22 21 20 | 19 16 | 15 12 | 11 0 |
cond | 0 0 | I | 1 1 0 1 S | SBZ | Rd | shifter operand |
(see "ARM Architecture Reference Manual, 4.1.29 "MOV")
立即数"常量被编码在只有 12 位的移位器操作数"中.其他指令有类似的定义,有时是其他宽度.
"Immediate" constants are encoded in the "shifter operand" which is 12 bits only. Other instructions have similar definitions are sometimes other widths.
存在此限制是因为——与 x86 不同——ARM 上的指令在使用 Thumb(2) 时始终为 32 位或有时为 16 位.为了支持不能直接用 12 位二进制数字表示的值,移位器操作数允许不同的寻址模式(例如左移、右移、旋转).
This limitation exists because -- unlike on x86 -- instructions on ARM are always 32 bit or sometimes 16 bit when using Thumb(2). To support values which can not be expressed directly by a 12 bit binary digit, the shifter operand allows different addressing modes (e.g. left-shift, right-shift, rotating).
这篇关于ARM:为什么立即数常量只有 12 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!