Tool to read and write to an instruction Describe the format
Instructions are 4 bytes long.
| 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
|-----------------------|-----------------------------------|-----------------------------------|
| Instruction ID | Argument 12A | Argument 12B |
| Instruction ID | Argument 24 |
Argument 24bits
| 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|
| Type | Register | Displacement | // case Type in {0x01, 0x02, 0x03, 0x04}
| Type | Address | // case Type in {0x04}
| Type | Value (&3 = sign) | // case Type in {0x06}
Argument 12bits
| 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|
| Type | Register | Displacement | // case Type in {0x01, 0x02, 0x03, 0x04}
| Type | Address | // case Type in {0x04}
| Type | Value (&3 = sign) | // case Type in {0x06}
| Type | | // case Type in {0x05, 0x07}
Register
Value | Register |
---|---|
0x00 | A |
0x01 | B |
0x02 | C |
0x03 | D |
0x04 | E |
0x05 | F |
0x06 | G |
0x07 | H |
0x08 | I |
0x09 | J |
0x0A | K |
0x0B | L |
0x0C | Program counter (PC) |
0x0D | Flags (FG) |
0x0E | Base stack pointer (BP) |
0x0F | Stack pointer (SP) |
Flags in
%FG
:
- zero: 0x01
- greater: 0x02
Type
Value | Readable | Writable | Addressable | Type |
---|---|---|---|---|
0x00 | X | X | Register %X |
|
0x01 | X | X | X | Deferred Register [%X] |
0x02 | X | X | X | Displaced Deferred Register [%X + disp] |
0x03 | X | X | X | Displaced Deferred Register [%X + disp] (Displacement not included in the instruction) |
0x04 | X | X | X | Address [X] |
0x05 | X | X | X | Address [X] (Address not included in the instruction) |
0x06 | X | Value X |
||
0x07 | X | Value X (Value not included in the instruction) |
MOV a, b
: Loadb
intoa
a
need to be writable
b
need to be readable
LEA a, b
: Load the address ofb
intoa
a
need to be writable
b
need to be addressable
SWP a, b
: Swap the value ofa
andb
a
andb
need to be readable and writable
CMP a, b
: Comparea
andb
, set the zero and the greater flag
CMPU
is the unsigned version ofCMPU
a
andb
need to be readable
ITU a
: Convert a signed integera
to an unsigned integera
need to be readable and writable
ITF a
: Convert a signed integera
to a floata
need to be readable and writable
UTI a
: Convert an unsigned integera
to a signed integera
need to be readable and writable
UTF a
: Convert an unsigned integera
to a floata
need to be readable and writable
FTI a
: Convert a floata
to a signed integera
need to be readable and writable
FTU a
: Convert a floata
to an unsigned integera
need to be readable and writable
ADD/ADDF a, b
: Addb
toa
(a += b
)
ADDF
is the float version ofADD
a
need to be readable and writable
b
need to be readable
SUB/SUBF a, b
: Subtractb
toa
(a -= b
)
SUBF
is the float version ofSUB
a
need to be readable and writable
b
need to be readable
MOD/MODF a, b
: store the modulo betweena
andb
intoa
(a %= b
)
MODF
is the float version ofMOD
a
need to be readable and writable
b
need to be readable
MUL/MULU/MULF a, b
: Multiplyb
toa
(a *= b
)
MULU
is the unsigned version ofMUL
MULF
is the float version ofMUL
a
need to be readable and writable
b
need to be readable
DIV/DIVU/DIVF a, b
: Divideb
toa
(a /= b
)
DIVU
is the unsigned version ofDIV
DIVF
is the float version ofDIV
a
need to be readable and writable
b
need to be readable
INC/INCF a
: Incrementa
(a += 1
)
INCF
is the float version ofINC
a
need to be readable and writable
DEC/DECF a
: Decrementa
(a -= 1
)
DECF
is the float version ofDEC
a
need to be readable and writable
AND a, b
: bitwise 'and'a &= b
a
need to be readable and writable
b
need to be readable
OR a, b
: bitwise 'or'a |= b
a
need to be readable and writable
b
need to be readable
XOR a, b
: bitwise 'xor'a ^= b
a
need to be readable and writable
b
need to be readable
NOT a
: bitwise 'not' (one's complement)a ~= a
a
need to be readable and writable
SHL a, b
: left shifta
byb
intoa
(a <<= b
)
a
need to be readable and writable
b
need to be readable
SHR a, b
: right shifta
byb
intoa
(a >>= b
)
a
need to be readable and writable
b
need to be readable
RTL a, b
: left rotatea
byb
intoa
(a <<<= b
)
a
need to be readable and writable
b
need to be readable
RTR a, b
: right rotatea
byb
intoa
(a >>>= b
)
a
need to be readable and writable
b
need to be readable
JMP a
: Jump toa
(set%PC
toa
)
a
need to be readable
JMPE a
: Jump toa
if the zero flag is 1 (set%PC
toa
)
a
need to be readable
JMPNE a
: Jump toa
if the zero flag is 0 (set%PC
toa
)
a
need to be readable
JMPG a
: Jump toa
if the greater flag is 1 (set%PC
toa
)
a
need to be readable
JMPGE a
: Jump toa
if the zero flag or the greater flag is 1 (set%PC
toa
)
a
need to be readable
CALL a
: Push%PC
to the stack then jump toa
(set%PC
toa
)
a
need to be readable
RET
: Pop the stack into%PC
Inverse operation ofCALL
HLT
: Halt the program with the return value in%A
PUSH a
: Pusha
to the stack
a
need to be readable
POP a
: Pop the last value of the stack toa
a
need to be writable
ETR
: Start a new frame
Push%BP
and set it to%SP
LVE
: Restore the last frame
Set%SP
to%BP
and Pop the stack into%BP
Inverse operation ofETR
NEW a, b
: Allocate a block ofb
bytes and store the first address ina
a
need to be writable
b
need to be readable
DEL a
: Free a block previously allocated withNEW
a
need to be readable
OUT a
: Print the first byte ofa
as a character to the standard output
a
need to be readable
DBG a
: Printa
to the standard output
a
need to be readable