mossprescott / pynand

Nand2Tetris in Python.
Other
12 stars 3 forks source link

Crank out another VM translator #26

Closed mossprescott closed 4 years ago

mossprescott commented 4 years ago

Demonstrates what it takes to try a simple idea in a (mostly) new translator.

Re-uses much of the existing translator, but replaces some opcode handlers and injects a little bit of code into others.

This turned out to be good for about 10% on both code size and cycles, without requiring any analysis or significant debugging. It actually generates slightly worse code in some cases, though, and anyway it's clear that bigger wins are possible by looking at more than one opcode at a time.