Chap 9 intro (compiling/translating/assembling supplied Pong.jack)
I just started reading Chapter 9, and in the intro there are two facts mentioned:
1) .Jack source files for Pong are supplied with the book
2) We can (a) compile them with the supplied JackCompiler, and then run the .vm files straight in the VME, or (b) translate/assemble the .vm code with our own previous projects, and run the machine code on a CPU emu.
However, there is a problem I'm having with #2. Just for fun, before getting further into the rest of the book, I found the .Jack source files for Pong. I compiled them using the JackCompiler, and immediately noticed there is no Sys.init function, which was a strict requirement in our translator program. So it is not even possible for me to try 2(b) as suggested. I did try manually renaming the Main.vm to Sys.vm, renaming the functions within accordingly, and adding a dummy Sys.init function to start the whole thing off. So after that my translator would indeed translate it, however, the CPU emulator, when running the .asm file, has an invalid memory access error eventually, and also never displays anything on the screen.
I am sure if I debugged this for long enough I might get to the bottom of it, but I was wondering if I was missing something more obvious? It is somewhat disappointing that the .vm code output produced by the supplied compiler does not meet the input specs of our translator project (specifically the necessity of a Sys.init function).
Re: Chap 9 intro (compiling/translating/assembling supplied Pong.jack)
Thanks. When I put all the OS/lib .vm's in with the Pong vm's, then when I run on the VME it works fine, with no warnings about using built-in functions instead (since I've of course put them all there in the same directory).
However, now when I assemble that directory to .asm file, it is 59k lines, which is 2x to large to fit in the Hack instruction ROM. So I still can't seem to run the native code just for fun. :-(