MARIE Instruction Set (with Opcodes) - MARIE-js/MARIE.js GitHub Wiki
In MARIE, each instruction is 16 bits long with the first 4 bits representing the opcode and the remaining 12 bits are being used to represent the address.
For example the instruction CLEAR
, the Opcode is A in HEX and 1010 in binary so the instruction will look something like `1010............`
Type | Instruction | Hex Opcode | Summary |
---|---|---|---|
Arithmetic | Add X | 3 | Adds value in AC at address X into AC, AC ← AC + X |
Subt X | 4 | Subtracts value in AC at address X into AC, AC ← AC - X | |
AddI X | B | Add Indirect: Use the value at X as the actual address of the data operand to add to AC |
|
Clear | A | AC ← 0 | |
Data Transfer | Load X | 1 | Loads Contents of Address X into AC |
Store X | 2 | Stores Contents of AC into Address X | |
I/O | Input | 5 | Request user to input a value |
Output | 6 | Prints value from AC | |
Branch | Jump X | 9 | Jumps to Address X |
Skipcond (C) | 8 | Skips the next instruction based on C: if (C) = - 000: Skips if AC < 0 - 400: Skips if AC = 0 - 800: Skips if AC > 0 |
|
Subroutine | JnS X | 0 | Jumps and Store: Stores value of PC at address X then increments PC to X+1 |
JumpI X | C | Uses the value at X as the address to jump to | |
Indirect Addressing | LoadI | D | Loads value from indirect address into AC e.g. LoadI addresspointer Gets address value from addresspointer, loads value at the address into AC |
StoreI | E | Stores value in AC at the indirect address. e.g. StoreI addresspointer Gets value from addresspointer, stores the AC value into the address |
|
Halt | 7 | End the program |