MAC-1 assembly language simulator

Samples: 

Code editor

Memory

CPU - Registers

IR: 0 PC: 0
SP: 0 AC: 0
MAR: 0 MBR: 0

Status

 

Instructions

Group Mnemonic Instruction Meaning
Basic LOCO x Load Constant ac := x;
Direct
addressing
LODD x Load direct ac := m[x]
STOD x Store direct m[x] := ac
ADDD x Add direct ac := ac + m[x]
SUBD x Substract direct ac := ac - m[x]
Indirect
addressing
LODI x Load indirect ac := m[m[x]]
STOI x Store indirect m[m[x]] := ac
ADDI x Add indirect ac := ac + m[m[x]]
SUBI x Substract indirect ac := ac - m[m[x]]
Local
addressing
LODL x Load local ac := m[sp + x]
STOL x Store local m[sp + x] := ac
ADDL x Add local ac := ac + m[sp + x]
SUBL x Substract local ac := ac - m[sp + x]
Stack PUSH Push ono stack sp := sp - 1; m[sp] := ac
POP Pop from stack ac := m[sp]; sp := sp + 1
INSP y Increment sp sp := sp + y
DESP y Decrement sp sp := sp - y
Jumps JUMP a Jump unconditionally pc := a
JPOS a Jump pozitive if ac ≥ 0 then pc := a
JZER a Jump zero if ac = 0 then pc := a
JNZE a Jump nonzero if ac ≠ 0 then pc := a
JNEG a Jump negative if ac < 0 then pc := a
Procedure CALL a Call procedure sp := sp - 1; m[sp] := pc; pc := a
RETN Return pc := m[sp]; sp := sp + 1
Other PSHI Push indirect sp := sp - 1; m[sp] := m[ac]
POPI Pop indirect m[ac] := m[sp]; sp := sp + 1
SWAP Swap ac, sp tmp := ac; ac := sp; sp := tmp

x = 12-bit machine address or value
y = 8-bit constant
a = 12-bit machine address; a label (a string) can also be used

Show
Janez Brezovnik, 2011