ChaseVaughan

MARIE Simulator Documentation

Registers


Register Mnemonic Description
Program Counter PC The PC is incremented by 1 at the end of each execution step.
Instruction Register IR The IR stores the opcode of the instruction currently being executed.
Accumulator AC The AC stores values currently being operated upon by the CPU.
Memory Address Register MAR The MAR stores the memory address currently in use by the CPU.
Memory Buffer Register MBR The MBR stores values being transfered from memory to the CPU and vice versa.
Input Register IN When an INPUT instruction is executed, the first character in the input area is copied to IN.
Output Register OUT At the end of each execution step, if the value of OUT is nonzero, it is copied to the output area in the form of a Unicode character. The register is then set to 0.
Status Register STA STA shows the status of the currently running program. A value of 0 indicates normal operation, while a value of 1 means execution has halted.

Instructions


Instruction Opcode Mnemonic Description
Load 0x1 LOAD X Loads the value at address X into the AC.
Store 0x2 STORE X Stores the contents of the AC at address X.
Add 0x3 ADD X Adds the value at address X to the value in the AC.
Subtract 0x4 SUBT X Subtracts the value at address X from the value in the AC.
Input 0x5 INPUT Copies the value from the Input register to the AC.
Output 0x6 OUTPUT Copies the value in the AC to the Output register.
Halt 0x7 HALT Halts execution.
Skip Conditionally 0x8 SKIPCOND X Skips the next instruction based on the values of the AC and the highest two bits of X (the bits immediately after the opcode).
Bits Condition
00 AC < 0
01 AC = 0
10 AC > 0
Jump 0x9 JUMP X Loads the value of X into the PC.
Clear 0xA CLEAR Sets the AC to 0.
Add Indirect 0xB ADDI X Adds a value to the AC, where X is an address whose value is the address of the value to add.
Jump Indirect 0xC JUMPI X Loads a value into the PC, where X is an address whose value is the address of the value to load.
Load Indirect 0xD LOADI X Loads a value into the AC, where X is an address whose value is the address of the value to load.
Store Indirect 0xE STOREI X Stores the value of the AC in memory, where X is an address whose value is the address at which to store it.
Jump and Store 0xF JNS X Stores the value of the PC at address X and jumps to address X + 1.

Code

# Any text following '#' in a line is ignored.

0x07F = 0x1234 # This stores the value 0x1234 at memory address 0x007F.
128 = 50 # Numbers without prefixes are interpeted as decimal.
         # Use the prefix '0x' to represent hexadecimal numbers.

LOAD 0x4  # Load the value at address 0x4 into the AC.
ADD 0x5   # Add the value at address 0x5 to the value in the AC.
STORE 0x6 # Store the value in the AC at address 0x6.
HALT      # Halt execution.

0x4 = 0x23   # Explicit memory assignments are executed before program execution
0x5 = 0xFFE9 # starts, regardless of their position in the code.

0xE20 = "some text" # Quotes can be used to assign a string of characters to
                    # a range of memory, starting at the specified address.