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: Loadbintoa
aneed to be writable
bneed to be readable
LEA a, b: Load the address ofbintoa
aneed to be writable
bneed to be addressable
SWP a, b: Swap the value ofaandb
aandbneed to be readable and writable
CMP a, b: Compareaandb, set the zero and the greater flag
CMPUis the unsigned version ofCMPU
aandbneed to be readable
ITU a: Convert a signed integerato an unsigned integeraneed to be readable and writable
ITF a: Convert a signed integerato a floataneed to be readable and writable
UTI a: Convert an unsigned integerato a signed integeraneed to be readable and writable
UTF a: Convert an unsigned integerato a floataneed to be readable and writable
FTI a: Convert a floatato a signed integeraneed to be readable and writable
FTU a: Convert a floatato an unsigned integeraneed to be readable and writable
ADD/ADDF a, b: Addbtoa(a += b)
ADDFis the float version ofADD
aneed to be readable and writable
bneed to be readable
SUB/SUBF a, b: Subtractbtoa(a -= b)
SUBFis the float version ofSUB
aneed to be readable and writable
bneed to be readable
MOD/MODF a, b: store the modulo betweenaandbintoa(a %= b)
MODFis the float version ofMOD
aneed to be readable and writable
bneed to be readable
MUL/MULU/MULF a, b: Multiplybtoa(a *= b)
MULUis the unsigned version ofMUL
MULFis the float version ofMUL
aneed to be readable and writable
bneed to be readable
DIV/DIVU/DIVF a, b: Dividebtoa(a /= b)
DIVUis the unsigned version ofDIV
DIVFis the float version ofDIV
aneed to be readable and writable
bneed to be readable
INC/INCF a: Incrementa(a += 1)
INCFis the float version ofINC
aneed to be readable and writable
DEC/DECF a: Decrementa(a -= 1)
DECFis the float version ofDEC
aneed to be readable and writable
AND a, b: bitwise 'and'a &= b
aneed to be readable and writable
bneed to be readable
OR a, b: bitwise 'or'a |= b
aneed to be readable and writable
bneed to be readable
XOR a, b: bitwise 'xor'a ^= b
aneed to be readable and writable
bneed to be readable
NOT a: bitwise 'not' (one's complement)a ~= a
aneed to be readable and writable
SHL a, b: left shiftabybintoa(a <<= b)
aneed to be readable and writable
bneed to be readable
SHR a, b: right shiftabybintoa(a >>= b)
aneed to be readable and writable
bneed to be readable
RTL a, b: left rotateabybintoa(a <<<= b)
aneed to be readable and writable
bneed to be readable
RTR a, b: right rotateabybintoa(a >>>= b)
aneed to be readable and writable
bneed to be readable
JMP a: Jump toa(set%PCtoa)
aneed to be readable
JMPE a: Jump toaif the zero flag is 1 (set%PCtoa)
aneed to be readable
JMPNE a: Jump toaif the zero flag is 0 (set%PCtoa)
aneed to be readable
JMPG a: Jump toaif the greater flag is 1 (set%PCtoa)
aneed to be readable
JMPGE a: Jump toaif the zero flag or the greater flag is 1 (set%PCtoa)
aneed to be readable
CALL a: Push%PCto the stack then jump toa(set%PCtoa)
aneed to be readable
RET: Pop the stack into%PC
Inverse operation ofCALL
HLT: Halt the program with the return value in%A
PUSH a: Pushato the stack
aneed to be readable
POP a: Pop the last value of the stack toa
aneed to be writable
ETR: Start a new frame
Push%BPand set it to%SP
LVE: Restore the last frame
Set%SPto%BPand Pop the stack into%BP
Inverse operation ofETR
NEW a, b: Allocate a block ofbbytes and store the first address ina
aneed to be writable
bneed to be readable
DEL a: Free a block previously allocated withNEW
aneed to be readable
OUT a: Print the first byte ofaas a character to the standard output
aneed to be readable
DBG a: Printato the standard output
aneed to be readable