- Status: In Progress
- Github link
tlvmContext* ctx = NULL; tlvmInitContext(&ctx, TLVM_CPU_8080); tlvmSetClockspeed(ctx, TLVM_MHZ(4,0)); tlvmByte mem; // load something into here tlvmSetMemory(vm, mem, 0, 256, TLVM_FLAG_READ | TLVM_FLAG_WRITE); tlvmRun(vm); tlvmTerminateContext(&ctx);
Let me begin with saying that I know very very little about this level of development. I’ve done a small amount of incredibly low level programming, but writing a virtual machine is always a bit alien to me. As such I’m making a lot of (largely incorrect) assumptions as I write this but then realising and correcting as I go along.
The original plan was to write a programmable computer that could be used in a game similar to the DCPU in 0x10c. I was considering designing the processor and instruction set myself, but quickly realised that as I have no experience with this, it would be a huge mess and practically unusable. So I decided to read up a bit and base the library on a generic 8 bit processor, and the instruction set on an existing one, so I came to the Intel 8080.
Unlike my other virtual machine, tlvm will not contain a parser/compiler, as writing even an assembler for 8080 is a little too much for what I want from my Tiny Little Libraries. I hope that any existing 8080 assemblers should work for tlvm, otherwise I’ve failed at my task. I might even attempt to write an 8080 assembler within the VM.
At this point, I cannot provide any readily assembled 8080 programs as I cannot find any with a license that would allow me to share it. I have, although, found something called cpudiag which was designed for systems running CP/M, however the only thing it required was the bdos 5 system call, which prints to the console. I hand rolled some 8080 machine code to emulate bdos 5 though.
Also, I realised that the Space Invaders arcade machines used Taito 8080 boards which almost works. I found a few peculiarities with the processor, and the setup of the board. I have not yet got the entire arcade cabinet emulated, it appears to have a shift register attached to the CPU ports which handles the animation of the invaders. The Implementation of the Space Invaders/Taito 8080 board currently stands at 200 lines on top of the tlvm libary and uses SDL to draw to the screen. Eventually I may try to get this running on a smaller computer, perhaps a VoCore, and hook it up to a small screen to create a mini arcade cabinet clone.
Adding new processors to tlvm is relatively straightforward. References need to be added to the public header, the internal header, and hook up the initialisation function to an internal, processor specific intialisation. After that, obviously the processor needs to be implemented, which is not far more difficult than hooking up function pointers for each valid instruction. I’ve got four processors at various stages of support
- 8080 – Completed
- z80 – I have a branch and processor type set up, but not implemented the z80 specific instructions
- 6502 – I have a branch and a processor type set up, but not implemented any 6502 instructions
- 6303 – I have a branch and a processor type set up. I have begun implementing some of the core instructions.
When the processors have been completed and tested, they will be merged back to master.