ARM 学习笔记之16: Syntax of Operand2 as a constant

本文详细介绍了ARM指令集中Operand2常量的使用范围与语法。内容涵盖A32与T32指令集的不同特性,包括常量的数值限制、表达形式及特殊指令如MOVS、ANDS等如何更新进位标志。此外还讨论了当所需常量不可用时,编译器如何通过替代指令来实现相同功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

An Operand2 constant in an instruction has a limited range of values.
Syntax
        #constant
where constant is an expression evaluating to a numeric value.
Usage
In A32 instructions, constant can have any value that can be produced by rotating an 8-bit value right by any even number of bits within a 32-bit word.
In T32 instructions, constant can be:
        • Any constant that can be produced by shifting an 8-bit value left by any number of bits within a 32-bit word.
        • Any constant of the form 0x00XY00XY.
        • Any constant of the form 0xXY00XY00.
        • Any constant of the form 0xXYXYXYXY.
------------------------- Note --------------------------
In these constants, X and Y are hexadecimal digits.

-----------------------------------------------------------
In addition, in a small number of instructions, constant can take a wider range of values. These are
listed in the individual instruction descriptions.
When an Operand2 constant is used with the instructions MOVS, MVNS, ANDS, ORRS, ORNS, EORS, BICS, TEQ
or TST, the carry flag is updated to bit[31] of the constant, if the constant is greater than 255 and can be
produced by shifting an 8-bit value. These instructions do not affect the carry flag if Operand2 is any other constant.
Instruction substitution
If the value of an Operand2 constant is not available, but its logical inverse or negation is available, then
the assembler produces an equivalent instruction and inverts or negates the constant.
For example, an assembler might assemble the instruction CMP Rd, #0xFFFFFFFE as the equivalent
instruction CMN Rd, #0x2.
Be aware of this when comparing disassembly listings with source code.
You can use the --diag_warning 1645 assembler command line option to check when an instruction
substitution occurs
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值