1. 指令功能
- ASR provides the signed value of the contents of a register divided by a power of two. It copies the sign bit into vacated bit positions on the left.
- LSL provides the value of a register multiplied by a power of two. LSR provides the unsigned value of a register divided by a variable power of two. Both instructions insert zeros into the vacated bit positions.
- ROR provides the value of the contents of a register rotated by a value. The bits that are rotated off the right end are inserted into the vacated bit positions on the left.
- RRX provides the value of the contents of a register shifted right one bit. The old carry flag is shifted into bit[31]. If the S suffix is present, the old bit[0] is placed in the carry flag.
2. 指令举例
● <immediate>
MOV R0, #0xFC0 ;令R0的数值为0xFC0
● <Rm>
MOV R0, #1
MOV R1, R0
ADD R2, R0, R1
● <Rm>, LSL #<shift_imm>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, R0, LSL #1
;R0 0xc4000003 = "1100 0100 0000 0000 0000 0000 0000 0011"
;R1 0x88000006 = "1000 1000 0000 0000 0000 0000 0000 0110"
● <Rm>, LSL <Rs>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, #2
MOV R2, R0, LSL R1
;R0 0xc4000003 = "11000100000000000000000000000011"
;R1 0x1000000C = "00010000000000000000000000001100"
● <Rm>, LSR #<shift_imm>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, R0, LSR #1
;R0 0xc4000003 = "11000100000000000000000000000011"
;R1 0x62000001 = "01100010000000000000000000000001"
● <Rm>, LSR <Rs>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, #0x2
MOV R2, R0, LSR R1
;R0 0xc4000003 = "11000100000000000000000000000011"
;R2 0x31000000 = "00110001000000000000000000000000"
● <Rm>, ASR #<shift_imm>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, R0, ASR #1
MOV R2, R0, ASR #2
;R0 0xc4000003 = "11000100000000000000000000000011"
;R1 0xE2000001 = "11100010000000000000000000000001"
;R2 0xF1000000 = "11110001000000000000000000000000"
● <Rm>, ASR <Rs>
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R3, #1
MOV R1, R0, ASR R3
MOV R3, #2
MOV R2, R0, ASR R3
;R0 0xc4000003 = "11000100000000000000000000000011"
;R1 0xE2000001 = "11100010000000000000000000000001"
;R2 0xF1000000 = "11110001000000000000000000000000"
● <Rm>, ROR #<shift_imm>
MOV R0, #0xF1
MOV R0, R0, ROR #6
;R0 0xc4000003 = "11000100000000000000000000000011"
● <Rm>, ROR <Rs>
MOV R0, #0xF1
MOV R1, #6
MOV R0, R0, ROR R1
;R0 0xc4000003 = "11000100000000000000000000000011"
● <Rm>, RRX
MOV R0, #0xF1
MOV R0, R0, ROR #6
MOV R1, R0, RRX
;R0 0xc4000003 = "11000100000000000000000000000011"
;R1 0x62000001 = "01100010000000000000000000000001"