The original implementation of the state machine support was pretty poor. In order to support NEXT,PUSH & POP a significant amount of boiler plate code was output. I’ve now changed the compiler significantly to optimise away much of this boiler plate code.
In essence the original state machine would maintain variables to track sub states seperately to the parent. This would result in problems when a PUSH needed to be compiled, since all the sub state variables would have to be fixed up. POP was even worse, this would need to work out which of the sub states we used to be in, in order to be able to restore the state.
States and sub states are now tracked by a single variable, this makes perfect sense as you could never be in more that one sub state simultaniously. The change does mean that the order of iterations through states and sub states has altered (but the prior implementation never made sense anyway). The docs have been updated to reflect this, and hopefully the new way makes more sense.
The original assembled i8080 pin accurate emulation would produce an llvm assembler file nearly 2Megabytes in length. After the state machine changes, this file is down to 700Kilobytes.
I have added FUNCTIONs + the INTERNAL modifier mentioned in the previous post. I also then proceeded to shrink the simple 8080 emulation file some more by using these new fangled things.
I’ve had a quick play around with another arcade machine (ShuffleBoard) which ran on the same hardware as space invaders. A few changes to the invaders emulation were needed because the port interface is very different. Had to spend some time debugging the rom to see why it would infinite reboot, turned out to be one of the ports not returning a correct value. I’ve not pushed this code upstream yet, it was more a curiousity to see if the 8080 would handle it.
The next problem to tackle is multiple files, as has been discussed before, each file should be treated as a standalone black box (micro chip?). In order to link multiple files together I need to extend the parser to allow the interfaces to be usuable from within another file. For now I`ll probably go a similar route to C (having a header file).