General Structure

Marie supports binary twos complement numbers.
Memory is 16 bit wide word addressable (not byte).
Simulator provides 4K words (12 bit address)
Instructions are 16 bit 
  (4 bits opcode, 12 bits operand - usually an address)

Observable registers

16 bit registers
  AC - accumulator - work register.
  IR - instruction register - holds instruction being decoded.
  MBR - holds data being transfered between cpu and system, bi-directional.

12 bit registers
  PC - points to next instruction to be decoded.
  MAR - holds current address to be accessed.
      Uni-directional, address always placed on address bus via MAR by CPU.

8 bit registers
  InREG - input register accessed with the "input" instruction.
  OutREG - output register accessed with the "output" instruction.
    Registers themselves not shown. However a field "input" is provided when
    an input is required and a scrollable "OUTPUT" window is provided for
    displaying output.

ISA - instruction set architecture.

4 bit opcode - up to 16 different instructions.
12 bit operand - not always used.
Uses big-endian order meaning 
  bits 15-12 contain opcode and 11-0 contain operands.

Instructions

* * * * *
JnS X    Bin 0000     Hex 0     Dec 0

Action:
Jump to subroutine located at memory address X + 1 after placing 
current PC in location X.

MBR <- PC       Transfer the PC to the MBR
MAR <- X        Transfer the specified address to the MAR
M[MAR] <- MBR   Store the current MBR at the memory addressed by MAR
MBR <- X        Place specified address in MBR (use as temp register)
AC <- 1         Set accumulator to 1
AC <- AC + MBR  Add the MBR to accumulator (increment address by 1)
PC <- AC        Set the PC to the newly calculated address.

* * * * *
Load X   Bin 0001     Hex 1     Dec 1

Action:
Load the data found at memory location X into the AC. (AC implied).

MAR <- X        Transfer the specified address to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
AC  <- MBR      Forward it to the AC

* * * * *
Store X  Bin 0010     Hex 2     Dec 2

Action:
Store the contents of the AC into memory at location X.

MAR <- X        Transfer the specified address to the MAR
MBR <- AC       Transfer the contents of the accumulator to the MBR
M[MAR] <- MBR   Write the data into the specified memory location.

* * * * *
Add X    Bin 0011     Hex 3     Dec 3

Action:
Add the data found at memory location X to current contents of the AC.
Changes in high bit will be interpreted as a sign change (overflow)

MAR <- X        Transfer the specified address to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
AC  <- AC + MBR Add the MBR to accumulator (increment address by 1)

* * * * *
Subt X    Bin 0100     Hex 4     Dec 4

Action:
Subtract the data at memory location X from current contents of the AC.
Changes in the high bit will be interpreted as a sign change (overflow)

MAR <- X        Transfer the specified address to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
AC  <- AC - MBR Add the MBR to accumulator (increment address by 1)

* * * * *
Input    Bin 0101     Hex 5     Dec 5

Action:
Input value from the keyboard (the input field) and store in AC. Any
operand specified is ignored.  The processing of input will be 
determined by the setting of the pull down menu.

AC <- InREG     Transfer from the input register to the AC.

Menu pulldown choices

  Dec - signed number consisting of the digits 0 - 9. Any other 
  characters will cause input to be 00.

  Hex - signed number consisting of the digits 0 - 9 and A - F.

  ASCII - any string of characters. However only the 1st will be used.

* * * * *
Output   Bin 0110     Hex 6     Dec 6

Action:
Output value in the AC to the "OUTPUT" window.  Any operands will be
ignored.  The output window has several dropdown configuration choices.

OutREG <- AC    Transfer data from the AC to the output register.

Menu pulldown choices

  Hex and Dec will display the output as the actual numeric values 
  written to the output area.

  ASCII will convert any output to the ascii equivalent.

  Control -

  Use Linefeeds - each write to the output will be on a separate line.

  No Linefeeds - all output written on a single line. If running with 
  ASCII display, decimal 13 or decimal 10 used to trigger linefeed.

  Clear Output - clears the output message box.

  Print - prints the current contents of the message box.

* * * * *
HALT     Bin 0111     Hex 7     Dec 7

Action:
Formally terminate the program.

* * * * *
Skipcond Bin 1000     Hex 8     Dec 8

Action:
Skips next instruction on specified condition - used to create 
branching conditions.  Usually the next instruction would be a jump 
or indirect jump.  Because the branch is predetermined, the operand 
can be used to specify the specific condition. For Marie, only 3 
conditions are used and the two bits closest (bits 10, 11) to the 
opcode bits will be used to specify condition.

  bits 11-10                      operand value
  00 - skip if AC is negative <   hex 00
  01 - skip if AC is zero =       hex 40
  10 - skip if AC is positive >=  hex 80  (zero is positive).

PC <- PC + 1 - when appropriate, increment the PC by one.

Note that the PC is already pointed to the next instruction, so with 
an additional increment, the next instruction is skipped.

* * * * *
Jump X   Bin 1001     Hex 9     Dec 9

Action:
Load the address X into the PC. Execution of the next instruction 
will start at memory location X.

PC <- IR[11-0] - Copy the lower 12 bits (the operand) of the current
        instruction to the PC.

* * * * *
Clear    Bin 1010     Hex A     Dec 10

Action:
Zero the accumulator.

AC <- 0 Set the AC to zero.

* * * * *
AddI X   Bin 1011     Hex B     Dec 11

Action:
Add data from the location specified by address stored at location X.
This instruction allows the use of memory location X to function as 
a pointer or index.

MAR <- X        Transfer the specified address to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
MAR <- MBR      Transfer the contents of the MBR to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
AC  <- AC + MBR Add the MBR to accumulator (increment address by 1)

* * * * *
JumpI X  Bin 1100     Hex C     Dec 12

Action:
Jump to the location specified at memory location X.  This instruction 
allows the use of memory location X to function as a pointer or index.

MAR <- X        Transfer the specified address to the MAR
MBR <- M[MAR]   Transfer the data addressed by the MAR into the MBR
PC  <- MBR      Transfer the contents of the MBR to the PC

* * * * *
1101-1111 ignored (but no error).