About
LPRSemu is a simple emulator and debugger for LPRS1 ISA & CPU. It supports loading programs from assembly text files, binary string representation or by directly writing assembly code in Rust using a macro.
Emulation example
Registers
| R0: 30 | R1: 5 | R2: 0 | R3: 0 |
| R4: 0 | R5: 0 | R6: 0 | R7: 0 |
Flags [ zero: true ] [ sign: false ] [ carry: false ]
Program counter: 7
Runtime counter: 22
Data memory
| 0 | 0
| 1 | 5
| 2 | 6
| ··· | 0
Program memory
| | main:
| 0 | inc R0, R0
| 1 | ld R1, R0
| 2 | inc R0, R0
| 3 | ld R2, R0
| 4 | sub R0, R0, R0
| | loop:
| 5 | add R0, R0, R1
| 6 | dec R2, R2
| 7 | jmpnz 5 (loop) <=
| 8 | st R0, R2
| | shift:
| 9 | shr R0, R0 (*)
| 10 | jmpnz 9 (shift)
| | divide:
| 11 | shl R1, R1
| 12 | jmpnz 11 (divide)
| ··· | nop
lprsemu >>
Usage
-
Clone repository from GitHub
git clone https://github.com/filiparag/ftn-lprsemu && cd ftn-lprsemu
-
Choose one option from the following:
- Write assembly code in an arbitrary text file.
After launching the emulator, typelf <file>
to load the program stored in path of<file>
. - Write assembly code into
ROM_ASM
macro located insrc/asm.rs
, and setDATA_MEMORY
accordingly. - Load binary string into
ROM_BIN
fromoQ
ininstr_rom.vhd
, andsMEM
values fromdata_ram.vhd
intoDATA_MEMORY
.
After launching the emulator, typelb
to load the program stored in binary string form. By default, code is loaded from the macro.
- Write assembly code in an arbitrary text file.
-
Compile and run the emulator
cargo run --release
Note: Release mode provides significantly better performance.
-
Type
h
into the prompt to list all commands
Note: Empty command defaults tostep
. -
Enjoy debugging!