EECS 370, Introduction to Computer Organization
LC-2K Assembler, Simulator, and Multiplier
A two-pass assembler that turns LC-2K assembly into 32-bit machine code, an instruction-level simulator that executes it, and a shift-and-add multiplier written in LC-2K assembly.
What I built
- Wrote a two-pass assembler: pass one builds a label table, pass two encodes R-type (add, nor), I-type (lw, sw, beq), J-type (jalr), and O-type (halt, noop) instructions plus .fill directives into hex.
- Resolved symbolic and numeric offsets, computed PC-relative beq targets, and exited with errors on undefined or duplicate labels, registers outside 0 to 7, 16-bit offset overflow, and unknown opcodes.
- Wrote a simulator that loads machine code into memory, decodes opcode and register fields, sign-extends 16-bit offsets, and executes until halt while printing machine state.
- Implemented 15-bit multiplication in LC-2K using only add and nor: bit tests through De Morgan AND, shifts through self-add, and a -1 counter made with nor.