ARM Slides Part5
ARM Slides Part5
ARM Slides Part5
2
The 32-bit format
An instruction like
ADD r5, r1, r2
is represented as the string of binary
numbers
1110 00 0 0100 0 0001 0101 000000000010
ADD r3,r3,#4 ; r3 = r3 + 4
14 0 1 4 0 3 3 4
4 bits 2 bits 1 bit 4 bits 1 bit 4 bits 4 bits 12 bits
Will see that 14 in the first field will remain as such for a data transfer
instruction like LDR too
10
What about format for other types
of instructions ?
11
ARM Data Transfer Instruction Format
14 1 24 3 5 8
4 bits 2 bits 6 bits 4 bits 4 bits 12 bits
ENTRY
Main
ADR R3 , Buffer
LDR R5, [R3, #08]
SWI &11
Buffer DCD &12A2E640 ,&F2100123, &001019BF ,&40023F51
END
WHAT WILL R5
HAVE ?
13
R5 will have 001019BF
ADR R3 , Buffer
places the address of Buffer in register R3
15
How are the numbers for LDR obtained ?
L stands for link bit; it is 0 for branch (B) and 1 for NV: stands for
branch with link (BL; used for subroutine call) Never (do not use)
Example 1
ENTRY
Main
MOV R0, #5
MOV R1, #4 What does R2
ADD R2, R0, R1, LSL #2
have now ?
stop b stop
END
19
R2 will be 0x00000015
Why ?
20
Example 2
ENTRY
Main
ADR R3 , Buffer
LDR R5, [R3]
SWI &11
Buffer DCD &12A2E640 ,&F2100123, &001019BF ,&40023F51
END
What will R5 have ?
21
Solution
22
Exercise
23