Professional Documents
Culture Documents
Microprocessor Systems
Contents
Logical Instructions
2 Arithmetic Instructions
3 Bitfield Instructions
2/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
3/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
4/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
5/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
6/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
7/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
8/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
LSR R4 , R3 , #3 ; R4 = R3 >> 3
ASR R5 , R3 , #3 ; R5 = R3 >> 3
9/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
10/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
After Two
Bit Rotate b1 b0 b31 b30 ... b3 b2 b1
Right
11/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
Logical Instructions
12/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
13/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
14/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
15/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
Rm {, shift}
Barrel
Shifter
ALU
Result
16/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
17/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
Arithmetic Instructions
• Note that ADDW and SUBW cannot affect the status flags
because of the absence of ‘S’ field
18/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
• Implementing y = 32x + c
LSL R2 , R2 , #5 ; Multiplying R2 with 32
ADD R3 , R2 , R1 ; Now perform the addition operation
OR
ADD R3 , R1 , R2 , LSL #5 ; Shift left ( logical ) R2 by five
; bits , add to R1 and finally store
; result in R3 . This operation is
; equivalent to R3 = R1 + ( R2 << 5)
19/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
• Divide Instructions
SDIV{cond} Rd, Rn, Rm
UDIV{cond} Rd, Rn, Rm
20/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
21/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
22/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
23/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
0x1FFFFFFC
3 0x00000124 R0
0x00000000 R1
...
0x00000268
Code
Memory 0x00000264 0xF04F1024 MOV R0, #0x124 2
...
0x00000260
...
0x00000004
1 0x00000264 PC (R15)
0x00000000
24/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
REV{cond} Rd, Rn
REV16{cond} Rd, Rn
REVSH{cond} Rd, Rn
RBIT{cond} Rd, Rn
25/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
REV
REV16
26/36
REV
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
REV16
Byte 1 Byte 0
REVSH
55 77 AA CC 00 00 01 23
27/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
Byte 1 Byte 0
R2 R3
55 77 AA CC 00 00 01 23
55 77 12 3C 00 00 01 23
R2 R3
(Modified) (Unchanged)
28/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
R3 R1
00 00 00 00 AA BB 55 33
00 00 01 54 AA BB 55 33
R3 R1
(Modified) (Unchanged)
R3 R1
(Modified) (Unchanged)
Bitfield Instructions: Bitfield Extract Instructions
R2 R1
00 00 00 00 AA BB 55 33
FF FF AA BB AA BB 55 33
R2 R1
(Modified) (Unchanged)
30/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
31/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
32/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
Saturating Instructions
• Signal saturation due to hardware amplification
Original signal
Amplified signal
33/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
34/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
35/36
Shift, Rotate, and Logical Instructions Arithmetic Instructions Bitfield Instructions Test and Compare Instructions
References
ARM (2014).
ARMv7-M architecture reference manual.
36/36