What did I build?
I built MINERVA-8, a custom console-based 8-bit assembler written entirely from scratch in C++. MINERVA-8 emulates a complete low level computer system from the command line. It has registers, a hardware stack pointer, flags (CF & ZF), 256 bytes of simulated memory, and full CPU emulation. There is also a compiler which converts assembly code with symbolic names to machine instructions. Implemented in C++.
What Was Challenging?
There were quite a few issues that I ran into when running assembly programs but they were fixable using my ‘step’ flag and watching the CPU states(flags/registers). However, one major hurdle I encountered with forward labels was that my assembler did not support jumping to an undefined label that wasn’t declared yet(forward jumps) used in JMP, CALL, JZ, and JNZ instructions. I could not solve this problem until I learned during my C++ class how V-tables are created during compile time. Thus, I decided on an “unresolved array” which would store the label and not have a resolved address which would be patched later when the label is actually found. My dad also suggested a two pass assembler would be more elegant. During the first pass all labels can be resolved and during the second pass the machine code can be generated. I chose to keep the single pass design because it produced a faster assembler despite requiring a small tracking array.
What are you proud of?
I am more satisfied than being proud of building a functional hardware stack infrastructure capable of handling nested subroutines using low-level PUSH, POP, CALL, and RET commands. It was amazing to watch a processor simulator I wrote entirely by hand successfully use stack memory to jump into subroutines, run math operations, and bounce back to the main program loop cleanly without crashing or corrupting memory boundaries.
How to Test My Project
Go to https://github.com/sudeeps-projects/Minerva-8/blob/master/README.md
look for the section Quick Start & Usage
It describes how to test my project
The compiled executable MINERVA-8.exe is located inside the release folder of this repository.
General Usage
Open your command prompt, navigate to the release folder, and run the executable with your assembly file and optional flags:
MINERVA-8.exe <filename.asm> [options]
Parameters & Options
filename.asm (Required): The path to the MINERVA-8 assembly file you want to execute.
–step (Optional): Step Mode. Displays the current CPU state and next instruction, then waits for ENTER before executing the next step.
–ram (Optional): RAM Mode. Displays the fully assembled machine code stored in the 256-byte RAM.
Command Examples
-
Standard Execution
MINERVA-8.exe DEC.asm -
Running Step Mode
MINERVA-8.exe DEC.asm –step -
Running RAM Mode
MINERVA-8.exe DEC.asm –ram -
Combining Step and RAM Modes The optional flags can be supplied together in any order:
MINERVA-8.exe DEC.asm –step –ram
OR
MINERVA-8.exe DEC.asm –ram –step
Look at my youtube channel on this topic: https://www.youtube.com/watch?v=7CmpW0mE3cQ
- 2 devlogs
- 32h