The difference between MOV and LDR

来源:互联网 发布:wow 3.3数据库 编辑:程序博客网 时间:2024/06/08 18:22

Although the MOV/MVN mechansim will load a large range of constants

into a register, sometimes this mechansim will not generate the required

constant.

*Therefore, the assembler also provides a method which will loadANY32bit constant:

LDR rd,=numeric constant

*If the constant can be constructed using either a MOV or MVN then thiswill be the instruction actually generated.

*Otherwise, the assembler will produce an LDR instruction with a PC relativeaddress to read the constant from a literal pool.

LDR r0,=0x42 ; generates MOV r0,#0x42

LDR r0,=0x55555555 ; generate LDR r0,[pc, offset to lit pool]

*As this mechanism will always generate the best instruction for a givencase, it is the recommended way of loading constants.

mov指令限制了立即数的长度为8位,也就是不能超过512。而ldr伪指令没有这个限制。如果使用ldr伪指令时,后面跟的立即数没有超过8位,那么在实际汇编的时候该ldr伪指令是被转换为mov指令的。

http://blog.csdn.net/tommy123_woo/article/details/7456006