sarthak wrote
I just completed the software hierarchy described in the book. I really enjoyed building all the software elements (assembler, compiler) but I think there are some gaps.
Suppose we built a machine understanding only machine code, if we want to write an assembler for it should it be written in the machine code too. How did we made the leap from machine language to assembly language? Similarly, should compliers be written in assembly language so that they can be implemented on our machine? I wanted to know how we implement a new language in any machine, I want to know what language the translator speak.
The Hack computer is a lot like the embedded systems I program in that respect. There are no compilers or assemblers that run on them. All the programs I develop for embedded systems are developed using tools that run on PCs, and only the machine code is programmed into the ROM on the microcomputers.
This thread has info about early assemblers.
These days we use tools to make other tools.
On your PC:
Use a C compiler to write a Hack assembler.
Use a C compiler to write a C compiler (c2hack) that generates Hack assembler.
Use c2hack to compile itself and you get a C compiler that runs on the Hack computer.
This assumes that you've already written a lot of infrastructure for the Hack computer so that the standard C library functions are there...
--Mark