asmTron/README.md

2.0 KiB

This Repo contains very uggly code, that may be disturbing to some readers. Reader discretion is advised.

asmTron

asmTron is a compiler / emulator for a 12-bit cpu (4-bit opcodes, 8-bit adresses), that I started building in Minecraft.
I never finished the Minecraft-Build, but this emulator is fully functional and even has integrated debugging capabilities.
This programm is optimized for a very specific terminal-size and a global variable has to be changed to switch between Windows / Linux compatability.

asm.py

The emulator / debugger...

compiler.py / compiler_beta.py

This compiler compiles from 'tronScript' to a binary save-state of the emulator. It has been designed with the main priority of being as easy as possible to compile. Usability was maybe impacted by this decisio. compiler_beta does not work, but contains code to add stack / push / pop functionality to tronScript. More information about tronScript can be found in TronScript_README.txt

mima.py

A variation of asm.py to emulate a MiMa (minimal machine). No, the compiler can not compile for this architecture.

asmCust.py

Does not work (I think...)


I wrote this before learning about compilers or such, accidentally invented some things I learned about later. Making stuff up as I went along led to very bad code, no sensible abstractions. Basis were mostly Minecraft redstone-computer tutorials.

I even made the same mistake with the current compiler implementation as early versions of Pascal: We don't support self recursion (neither direct nor indirect) as we store return addresses for function calls in memory slots specific to functions. Any self recursion thus overrides the return pointer of an outer invocation with the address for the inner invocation. Returning from the outer function call thus steps down again leading to an infinite loop. The beta compiler (if actually functional) solves this the way the Pascal devs did back then: Using a stack for return pointers. The concept of local vars / scoping via stack is still missing thought.