Assembly LC-2 cli simulator written in C, Lex and Yacc.
https://mattiaperfumo.it/compiler-design/
- Linux
- MacOS
- First, You need to install Flex (lexical analyzer) and Yacc. Use brew if You are in MacOS.
# for Linux
sudo apt install flex \
sudo apt install bison
# for MacOS
sudo brew install flex \
sudo brew install bison- clone this repo
- launch the
makecommand
./lc2 example.asm [-e]|[-s]
- -e: executes the entire program and prints all registers
- -s: steps to every instruction in ~=1000 ms
- no options: press enter for next instruction
press r to print the registers:
x3001 AND R2 R2 #0
x3002 LOOP LDR R1 R0 #0
x3003 BRZ END
> r
R0=12297 R1=15 R2=0 R3=0
R4=0 R5=0 R6=0 R7=0
CC=P PC=12291 (x3003)
>
TRAP instructions are not yet implemented. LOAD & STORE functions work perfectly, You just can't see them in the memory during execution.