Assembly Language Instruction Set
Assembly Language Instruction Set
SUB Ra, Rb, <operand> Subtract value in SUB R2, R1, #102 Subtract 102 from the value in
perand from register SUB R2, R1, R3 register R1 and store the
Rb load result in result in register R2 Control
register Ra subtract the value stored in R3 Instruction Description
from the value in R1 and store CMP R, <operand> Compare value in register R with <operand> value
the result in R2 B <label> Branch to position <label>
The <operand> can be a register or a data value. The register is indicated by R and a data value is preceded by a #. BEQ <label> Branch to position <label> if result of last comparison between R and <operand>
was equal
BNE <label> Branch to position <label> if result of last comparison was not equal between R and
<operand>
Logical shift operations BGT <label> Branch to position <label> if R was greater than <operand> in the last comparison
Instruction Description Example Example description comparison
LSL Ra, Rb, <operand> Logical shift left value LSL R1, R1, #2 Logical shift left value in R1 by BLT <label> Branch to position <label> if R was less than <operand> in the last comparison
in register Ra by 2 and store in register R1 HALT Terminate execution of program
<operand> value LSL R1, R1, R2 Logical shift left value in R1
and store in register by value in R2 and store in
Ra register R1
Examples
LSR Ra, Rb, <operand> LSR R1, R1, #2 Selection (if …) Selection (if .. else ..) Iteration
Logical shift left value Logical shift right value in R1 by
in register Ra by 2 and store in register R1
LSR R1, R1, R2 MOV R1, #10 MOV R1, #10 MOV R0, #0
<operand> value Logical shift right value in R1 by CMP R1, #10 CMP R1, #10 loop:
and store in register value in R2 and store in BNE end BEQ IF ADD R0 R0 #1
Ra register R1 MOV R2, #20 MOV R2, #20 CMP R0 #4
end: B ELSE BNE loop
Eg 310 << 210; 310 = 0112; 011002 = 1210 HALT IF: HALT
MOV R2, #30
ELSE:
HALT