ARM 的 MOV 指令如何以大数作为第二个操作数? [英] How can ARM's MOV instruction work with a large number as the second operand?

查看:23
本文介绍了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.但是当我在自己的 PC 上使用 ADS 1.2 IDE 进行测试时,说明

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天全站免登陆