Docsity

Assembly Language Instructions - Computer Organization - Homework, Exercises of Computer Architecture and Organization

Toggle sidebar
bg1
Consider some common ARM Assembly language instructions:
Branch to LABEL and Link (save return value to LR (R14))BL LABEL
Always Branch to LABELB LABEL
or BAL LABEL
Unconditional
Branch
Branch to LABEL if condition codes are set for !=BNE LABEL
Branch to LABEL if condition codes are set for =BEQ LABEL
Branch to LABEL if condition codes are set for <=BLE LABEL
Branch to LABEL if condition codes are set for <BLT LABEL
Branch to LABEL if condition codes are set for >=BGE LABEL
Branch to LABEL if condition codes are set for >BGT LABELConditional
Branch
Sets condition codes on R1 - R2CMP R1, R2Comparison Instructions
(set the condition codes, cc)
R1 R2 xor R3
b
ERR R1, R2, R3
R1 R2 and (not R3)
b
BIC R1, R2, R3
R1 R2 or R3
b
ORR R1, R2, R3
R1 R2 and R3
b
AND R1, R2, R3Bit-wise Logical Instructions
R1 R2 - 1
b
SUB R1, R2, #1
R1 R2 + R3 + C
b
ADD R1, R2, #10
R1 (R2 x R3)
[31:0]
b
MUL R1, R2, R3
R1 R2 - R3
b
SUB R1, R2, R3
R1 R2 + R3
b
ADD R1, R2, R3Arithmetic Instruction
(reg. or immediate operands
only)
R1 10
b
MOV R1, #10
R1 R2
b
MOV R1, R2Move
R1 load address of Mem
b
ADR R1, MemAddress
Mem R1 (PC-relative; 32-bit operand)
b
STR R1, Mem
R1 Mem (PC-relative; 32-bit operand)
b
LDR R1, MemMemory Access
Register Transfer Language
Description
ARM Assembly
Language
Type of Instruction
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
Computer Org. Lecture 10 Name:_______________
Lecture 10 Page 1
Docsity.com
pf2

Partial preview of the text

Download Assembly Language Instructions - Computer Organization - Homework and more Exercises Computer Architecture and Organization in PDF only on Docsity!

Consider some common ARM Assembly language instructions:

BL LABEL Branch to LABEL and Link (save return value to LR (R14))

B LABEL Always Branch to LABEL or BAL LABEL

Unconditional Branch

BNE LABEL Branch to LABEL if condition codes are set for !=

BEQ LABEL Branch to LABEL if condition codes are set for =

BLE LABEL Branch to LABEL if condition codes are set for <=

BLT LABEL Branch to LABEL if condition codes are set for <

BGE LABEL Branch to LABEL if condition codes are set for >=

Conditional BGT LABEL Branch to LABEL if condition codes are set for > Branch

Comparison Instructions CMP R1, R2 Sets condition codes on R1 - R (set the condition codes, cc)

ERR R1, R2, R3 R1 bR2 xor R

BIC R1, R2, R3 R1 bR2 and (not R3)

ORR R1, R2, R3 R1 bR2 or R

Bit-wise Logical Instructions AND R1, R2, R3 R1 bR2 and R

SUB R1, R2, #1 R1 bR2 - 1

ADD R1, R2, #10 R1 bR2 + R3 + C

MUL R1, R2, R3 R1 b(R2 x R3)[31:0]

SUB R1, R2, R3 R1 bR2 - R

Arithmetic Instruction ADD R1, R2, R3 R1 bR2 + R

(reg. or immediate operands only)

MOV R1, #10 R1 b 10

Move MOV R1, R2 R1 bR

Address ADR R1, Mem R1 bload address of Mem

STR R1, Mem Mem bR1 (PC-relative; 32-bit operand)

Memory Access LDR R1, Mem R1 bMem (PC-relative; 32-bit operand)

Register Transfer Language Description

ARM Assembly Language

Type of Instruction

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

Computer Org. Lecture 10 Name:_______________

Lecture 10 Page 1Docsity.com

b) for R4 = 0 to 100 by steps of size 10 do

if (R3 < R4) AND (R2 >= 50) then

R2 = R2 + R

end if

end for

c) while (R8 > 20) do

if (R8 < 100) OR (R8 > 200) then

R7 = R

R8 = R8 - 10

else

R8 = R8 - R

end if

R7 = R6 + 4

end while

Computer Org. Lecture 10 Name:_______________

Lecture 10 Page 2Docsity.com