How to write our VM translator if HACK is the first platform on build.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to write our VM translator if HACK is the first platform on build.

Henoktes722
Now we are actually writing a VM translator for our HACK platform using some other real platform.

But what if HACK is the first and the only platform, which are currently building, so how can we build our VM translator?
Reply | Threaded
Open this post in threaded view
|

Re: How to write our VM translator if HACK is the first platform on build.

ivant
There are already some threads discussing this or very similar questions in the forum. Here is one of them, but I'm sure there are others.
Reply | Threaded
Open this post in threaded view
|

Re: How to write our VM translator if HACK is the first platform on build.

WBahn
Administrator
In reply to this post by Henoktes722
Henoktes722 wrote
Now we are actually writing a VM translator for our HACK platform using some other real platform.

But what if HACK is the first and the only platform, which are currently building, so how can we build our VM translator?
The same question applies to how do we write an assembler if all we have is the CPU hardware.

We have to pull ourselves up by our bootstraps. The first computers had no software -- the programs were built in hardware -- essentially we make a RAM that we can manually configure with wires and/or switches and we configure them based on the machine code directly. We could do the same thing with the Hack if we really wanted to. So we would build a very small program, a loader, that is able to load a stored program from some simple media (the early computers often used a punch-paper tape). Now we can write programs, again in machine code, into the paper tape so we first write a program that can write out to a device the can punch holes in a paper tape as it goes by so that we can use our computer to write programs to a storage device. Next we write a program that can interact with human I/O device, such as a teleprinter. Now we have a means of inputting new text via a keyboard. Now we can write machine code programs much more easily using the keyboard and save them to tape. Next we write an assembler so that we can type more meaningful (to humans) programs more efficiently. Next we write our VM translator, written in assembly language. After that, we write a high-level compiler written in VM code.

Each of these steps is iterative where we would likely first write a very simple, basic version of a tool in the next-lower level language and then, with that, we would write better tools using that same language -- so we would use our basic assembler to write a better assembler written in assembly language. Once we had our VM translator written in assembly we might well write a better assembler written in VM code. Eventually, we get to the point where we have the tools to write everything in a high level language using several programs, such as text editors and such, all of which were written in a high level language.

The Hack doesn't lend itself to this kind of bootstrapping because it lacks any sense of nonvolatile storage. But if we were to built a simple storage device that we could read and write to then we could follow this same progression. While that would be very interesting to do, it is well outside the scope of what the authors wanted to focus on.

Reply | Threaded
Open this post in threaded view
|

Re: How to write our VM translator if HACK is the first platform on build.

Henoktes722
Clear.