如何在具有立即数作为第二个操作数的ARM中使用MOV指令 [英] How to use MOV instruction in ARM with an immediate number as the second operand

查看:194
本文介绍了如何在具有立即数作为第二个操作数的ARM中使用MOV指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是开始学习ARM汇编语言,还不清楚如何使用MOV将立即数传输到寄存器中.

I just begin to study ARM assembly language, and am not clear about how to use MOV to transfer an immediate number into a register.

从ARM参考手册和我的教科书中都可以看出,MOV指令后的立即数范围是0-255.但是,当我在ADS 1.2 IDE中在自己的PC上进行测试时,说明

From both the ARM reference manual and my textbook, it's said that range of immediate number following MOV instruction is 0-255. But when I test on my own PC in ADS 1.2 IDE, instruction

MOV     R2, #0xFFFFFFFF

表现良好.数字0xFFFFFFFF是否超出规范范围?

performs well. Isn't number 0xFFFFFFFF out of range according to the specification?

希望有人可以帮我

致谢.

推荐答案

请记住,作为合并到ARM操作码中的桶形移位器的一部分,ARM可以对立即数执行一组特定的操作.

Remember that the ARM can perform a certain set of manipulations on the immediate value as part of the barrel shifter that is incorporated into the ARM's opcodes.

这篇小文章对ARM汇编程序可用于将大量立即数放入ARM指令的较小可用空间中的一些技巧进行了最清晰的解释:

This little article has one of the clearest explanations of some of the tricks that an ARM assembler can use to fit a large immediate number into the small available space of an ARM instruction:

本文讨论了在生成MVN操作码以加载即时值的按位补码的特定示例中可能使用的技巧.

The article discusses the trick likely used in your specific example of generating a MVN opcode to load the bitwise complement of the immediate value.

无法用所有立即数完成这些类型的操作,但是ARM汇编程序据称非常聪明(C编译器当然可以).如果无法执行移位/补码技巧,则通常将从相对于PC的位置加载该值,或者可能通过从几条指令中累积"该值来加载.

These kinds of manipulation can't be done with all immediate values, but the ARM assemblers are supposedly pretty smart about it (and C compilers certainly are). If no shift/complement tricks can be performed, the value will generally be loaded from a PC-relative location or maybe by 'building up' the value from several instructions.

这篇关于如何在具有立即数作为第二个操作数的ARM中使用MOV指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆