Context:FIT1047_MOC · the Assignment 2 “programming interview” skill · machine model + full W3 instruction set + the branching patterns · execution semantics in Fetch-Decode-Execute and RTL (Control)Problem it solves: hand-assemble, hand-trace, and write-from-blank small MARIE programs.
Quick Revision
🎯 Trigger: every instruction = 4-bit opcode + 12-bit address in a 16-bit word; only ONE working register (AC) ➔ everything routes through it.
⚡ Key Constraint:SkipCond skips exactly ONE instruction — if/loops are built as SkipCond + Jump pairs; the condition constants are 000:AC<0, 400:AC=0, 800:AC>0.
🧩 Machine Model
Memory ➔ 16-bit words, 12-bit addresses ⟹ max 212=4096 locations.
Practice 1: hand-assemble Store A where label A sits at address 01F16.
Answer
Opcode Store=0010; address 01F ⟹ word =00100000000111112=201F16.
Key move: first hex digit IS the opcode nibble; remaining three hex digits are the address.
Practice 2: write a MARIE program that inputs two numbers and outputs their difference (first − second).
Answer
Input / AC ← first Store T1 Input / AC ← second Store T2 Load T1 Subt T2 / AC ← first − second Output HaltT1, DEC 0T2, DEC 0
Key move: one accumulator ⟹ park values in labelled memory (Store) before the second Input overwrites AC.
⚠️ Common Mistakes
💡 AC is always in the middle ➔ no memory-to-memory moves; every value passes through the accumulator.
💡 SkipCond skips ONE instruction only ➔ the skipped slot is almost always a Jump — skipping a whole block directly is impossible.
💡 The three condition constants ➔ 000/400/800 for <0,=0,>0 — memorise as hex, they look arbitrary in decimal.
💡 DEC is not an instruction ➔ assembler directive reserving a data word; putting it in the execution path runs garbage as code (stored-program hazard).