The GHOST Simulator set
Quick preface: this description describes the program as it was a couple years ago, and I haven't had time to update it as fully as I would like to. It's close, but most components have been completely rewritten since then and operate with significant changes.
Ghost is a computer archecture I made as a thought experiment, and also as an easy way to introduce people to the ideas of assembly. It's both the definitions I've created, and a collection of python/c++ scripts including an assembler and simulator.
The assembler runs in two passes: the first pass clears comments, resolves shorthand, validates the instructions, and records labels. The second pass fills in the labels, does math, and validates each byte to ensure the hex is ready to be output. Then it's output in a variety of formats. Additionally, the compiler supports basic definitions, data definition, labels/names, 5 different output formats, and a dictionary called 'debugging' that allows you to configure the differrent debugging features.
The other main program is the simulator. It loads each instruction from memory, converts it to it's mnemonic, and executes it in an el/if tower. It automatically process writes to screen memory, key inputs, reads from the random IO device, halts, and breaks. Other assorted tools are: Sublime Text syntax highlighting, downloader to get current information from the notion document, and a few example assembly programs.
Complete Rewrite!
After loads of incremental changes, a complete rewrite, and then even more changes we've arrived at Release 3!
- More features in the assembler (Org, sketchy macros, better data types)
- Include other binary/assembly files in assembler
- There's only one stack
- Better interrupts
- Better documentation included in the repo in markdown
- Wrote a kernel thing! malloc!
- Some more programs, but now snake is broken
Efficiency and speed greatly improved
Mostly just performance changes.
- Changed instructionSet to remove the 'R' prefix, so that integers can be directly compared in C# later
- Added configuration options via settings.ini
- binColor uses math instead of string manipulation, which was stupid in the first place
- Uses match/state, which is slightly faster
- Uses ctypes.c_ushort for the MEMORY, which much faster
Upload of old version: Ghost 18!
This is an upload of an old version, but it's special enough to deserve an upload because it comes with a bit of a bonus: it has a circuit simulator to go with it. Attatched is a circuitverse file that will let you watch how the computer works in real-time! However, I cannot remember how many of the instructions are implemented, nor how effectivly. Nevertheless, it was an amazingly fun project that whiled away many hours.
Also attached is a very cool piece of what I'm calling 'live documentation'. Attatched is a python script that has some pretty cool capabilities, listed below:
Index
This is the most interesting one! Loops through the whole database and reads the information from it to store in the reference file. However, it also recompiles the micro ASM, a simple simple language, into the microcode. The micro ASM is a list of symbols seperated by commas that are intended to be human readable, where an arrow designates a move from one location to another, and special codes are 4 bit data prefixed with the code 'area'. There are two areas, MF for math flags, and MC for mini commands. The mini commands are commands that don't need a 'to' and 'from' section, so can be seperated from the rest. The microcode architecture is built such that the first four bits are the 'from' or the area code, while the last four bits are the 'to' section or, if in an area, the instruction within the area. This 'index' command validates the microcode, checks the unique assembly name, and saves all of it to the reference file.
ROM Creator
The rom creator takes information stored in the reference file and compiles the microcode into a ROM for the simulated computer
Compiler
Missnamed by ignorance, this assembler uses the reference file to assemble into a hex format that can be pasted into the circuitverse simulator.
Simulator
Because it doesn't have a screen, this release of Ghost uses a beautiful python-curses terminal simulator that can display tons of information at once, including decoding the microcode instructions for each instruction and a cool scrolling memory dump.
First release of GHOST!
Running todo list:
- Rename the project, ghost is too generic
- Handle errors better in all aspects of the program
- Simplify the confusion between addresses and values, especially in the JMP and DD commands
- Clean up Readmes
- Add keybind to toggle power button
Changlog:
- Assembler outputs to hex by default, and the simulator can read it
- Finished the snak game demo
- Added register dump on an exception
- Added JumpRegister to support conditionals
- Added function to update just the GUI or Stack sections of the screen
- Better conditionals for jumps, calls, and returns
- Fixed syntax highlighting