前模式下的寄存器。
There is no single instruction which will load a 32
bit immediate constant into a register without performing a data load
from memory. The data processing instruction format has 12 bits
available for operand2. Instead it is used to store 8 bit constants,
giving a range 0-255.These 8 bits can be rotated right through an even
umber of positions(ie RORs by 0,2 ,4…,30)
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]
Branch : B{} label
Branch with Link: BL{} sub_routine_label
The offset for branch instructions is calculated by
the assembler:By taking the difference between the branch instruction
and the target address minus 8(to allow for the pipeline). This gives a
26 bit offset which is right shifted 2 bits(as the bottom two bits are
always zero as instructions are word-aligned) and store into the
instruction encoding. This gives a range of 32M bytes
· Multiplication Instructions
The basic ARM provides two multiplication instructions.
Multiply: MUL{}{S} Rd, Rm, Rs ;Rd = Rm * Rs
Multiply Accumulate: MLA{}{S}Rd, Rm,Rs,Rn ;Rd =(Rm*Rs)+Rn
Restrictions on use: Rd and Rm connot be the same
register, can be avoid by swapping Rm and Rs aroud. This works because
multiplication is commutative
乘法指令与乘加指令共有6条:
指令
|
描述
|
格式
|
MUL
|
32位元乘方指令
|
MUL{}{S}Rd,Rm,Rs
|
MLA
|
32位元乘加指令
|
MLA{}{S}Rd,Rm,Rs,Rn
|
SMULL
|
64位元有符号数乘法指令
|
SMULL{}{S}RdLo,RdHi,Rm,Rs
|
SMLAL
|
64位元有符号数乘加指令
|
SMLAL{}{S}RdLo,RdHi,Rm,Rs
|
UMULL
|
64位元无符号数乘法指令
|
UMULL{}{S}RdLo, RdHi, Rm, Rs
|
UMLAL
|
64位元无符号数乘加指令
|
UMLAL{}{S}RdLo,RdHi, Rm,Rs |
阅读(998) | 评论(0) | 转发(0) |