Administrator
|
Are you trying to write a Jack interpreter that is written in Jack that will run on the Hack?
If so, that is a very tall order, not the least because the Hack platform lacks things that would be pretty important, such as any semblance of a file system.
You could, in principle, write an interpreter that let the user enter code at the terminal and then run that code. That's the way a lot of early microcomputers worked. They commonly had a BASIC interpreter in ROM that served as the OS. You created a program line by line and had the ability to save it to some kind of storage (tape or disk) and could load it later. But my school had some that didn't have that ability and so every time you wanted to run a program you had to type it in from scratch (these were machines that were given to the school because their tape drives (or the associated hardware in the computer) had failed. Since most of the programs were a dozen or so lines long (initial part of the "computer math" course), this wasn't horrible and it actually forced students to gain familiarity with the code details much more quickly.
Most of these machines had 4 KB of RAM. The ROM OS may have been larger, but who knows.
The CPUs (typically 6502 or z80 or something comparable) had significantly more capable instruction sets than the Hack, but not out-of-the-world more capable. So I don't think it is completely unreasonable to do something similar on the Hack.
However, hoping to write the interpreter in Jack may well be going a bridge too far. Even with a very well written compiler and virtual machine translator, getting the code tight enough to run in the amount of ROM available may be biting off too much. I believe all of the OSs and interpreters in those early days (at least for those machines) were written in assembly language. If they weren't, there were almost certainly written in C or a comparable language and compiled on a different computer with very carefully written code that was specifically designed to leverage the compiler's implementation patterns, which were in turn specifically designed for the target processor.
|