2. Main features
The assembler follows a two-pass strategy. At the first pass, the symbol table
is updated with the symbolic branch addresses. At the second pass, full assembly
of the source code is taking place, and the symbol table whenever it is
necessary to determine an address for a named label.
Its differentiating feature is the coding approach so the user can easily add/
replace instructions or modify the existing instruction formats.
A "toy" instruction set is supported in this version of rasm. The "toy"
instruction set is described in the following table:
2.2. Supported instruction set
Instruction format |
OpCode |
Description |
Action |
ADD Rd,Rs1,Rs2 |
0x04 |
Add |
Rd := Rs1 + Rs2 |
CMP Rs1,Rs2 |
0x0B |
Compare |
flags: Rs1 - Rs2 |
LD Rd,Rb,Ro |
0x08 |
Load register |
Rd := m[Rb+Ro] |
MUL Rd,Rs1,Rs2 |
0x0A |
Multiply |
Rd := Rs1 * Rs2 |
ORR Rd,Rs1,Rs2 |
0x11 |
Logical OR |
Rd := Rs1 || Rs2 |
ST Rs,Rb,Ro |
0x10 |
Store register |
m[Rb+Ro] := Rs |
SUB Rd,Rs1,Rs2 |
0x03 |
Subtract |
Rd := Rs1 - Rs2 |
ADDI Rd,Rs,#immed |
0x05 |
Add immediate |
Rd := Rs + immed |
MOV Rd,Rs |
0x12 |
Move register |
Rd := Rs |
MOVI Rd,#immed |
0x09 |
Move immediate |
Rd := immed |
B $target |
0x16 |
Branch uncondit. |
PC := target |
BLT $target |
0x17 |
Branch if less
than |
- if (flags):
- PC := target
|