Download Computer Org. Lecture 10 Name:_______________ Consider some common ARM Assembly language instructions:

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Org.
Lecture 10
Name:_______________
Consider some common ARM Assembly language instructions:
Type of Instruction
Memory Access
ARM Assembly
Language
LDR R1, Mem
STR R1, Mem
Address
ADR R1, Mem
Move
MOV R1, R2
MOV R1, #10
ADD R1, R2, R3
SUB R1, R2, R3
MUL R1, R2, R3
ADD R1, R2, #10
SUB R1, R2, #1
AND R1, R2, R3
ORR R1, R2, R3
BIC R1, R2, R3
ERR R1, R2, R3
CMP R1, R2
Arithmetic Instruction
(reg. or immediate operands
only)
Bit-wise Logical Instructions
Comparison Instructions
(set the condition codes, cc)
Conditional
Branch
Unconditional
Branch
BGT LABEL
BGE LABEL
BLT LABEL
BLE LABEL
BEQ LABEL
BNE LABEL
B LABEL
or BAL LABEL
BL LABEL
Register Transfer Language
Description
R1 b Mem (PC-relative; 32-bit operand)
MembR1 (PC-relative; 32-bit operand)
R1b load address of Mem
R1b R2
R1b 10
R1b R2 + R3
R1b R2 - R3
R1b (R2 x R3)[31:0]
R1b R2 + R3 + C
R1b R2 - 1
R1b R2 and R3
R1b R2 or R3
R1b R2 and (not R3)
R1b R2 xor R3
Sets condition codes on R1 - R2
Branch to LABEL if condition codes are set for >
Branch to LABEL if condition codes are set for >=
Branch to LABEL if condition codes are set for <
Branch to LABEL if condition codes are set for <=
Branch to LABEL if condition codes are set for =
Branch to LABEL if condition codes are set for !=
Always Branch to LABEL
Branch to LABEL and Link (save return value to LR (R14))
1. Translate the following high-level language code segment to ARM assembly language. Use the registers
indicated in the code.
a)
if X < Y then
min = X
else
min = Y
end if
Lecture 10 Page 1
Computer Org.
Lecture 10
Name:_______________
b) for R4 = 0 to 100 by steps of size 10 do
if (R3 < R4) AND (R2 >= 50) then
R2 = R2 + R3
end if
end for
c) while (R8 > 20) do
if (R8 < 100) OR (R8 > 200) then
R7 = R8
R8 = R8 - 10
else
R8 = R8 - R7
end if
R7 = R6 + 4
end while
Lecture 10 Page 2