MOV, LDR只能使用8位位图立即数,这8位立即数可以由0-255之间的数循环右移(ror)而来。即这个数除以4,一直除,直到0-255范围内它为整数即可!例如0xF0000001是由0x1F循环右移4位而来。这样做是因为指令长度限制,不可能把32位立即数放在32位指令中,移位偶数也是此原因。例如合法常量有:0x3FC, 0xF0000000, 200, 0xF0000001;非法常量:0x1FE, 511, 0xFFFF, 0x1010, 0xF0000010等。但是MOV r0, #0xFFFFFFFF是合法的,因为等同于MVN r0, #0.
MOV r0,#4096是合法的,是因为4096可由0x40 ror 26而来。只要这些常量可由循环右移或者MVN产生,就是合法的。
If the required constant cannot be generated, an error will be reported.
Although the MOV/MVN mechanism will load a large range of constants into a register, sometimes this mechanism will not generate the required constant. Therefore, the assembler also provides a method which will load ANY 32 bit constant: LDR rd, = numeric constant.这种情况下,如果该常数可由MOV或MVN来实现,则会产生效果等同的MVN/MOV指令。Otherwise, the assembler will produce an LDR instruction with a PC-relative address to read the constant from a literal pool.
LDR r0, =0x42 ;generates MOV r0, #0x42
LDR r0, =0x55555555 ;generate LDR r0, [pc, offset to literal pool]