zrottman / vmtranslator

Converts high-level VM commands into symbolic Hack assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VM Translator

This is a C port of the VM translator I build in Python for The Elements of Computing Systems (aka Nand2tetris). The VM translator serves as the middle layer between a high-end compiler front end and an assembler back end.

Demo

Overview:

Developed in the context of the nand2tetris computer, this VM translator bridges the gap between a high-level, Java-like source language (Jack) and a low-level target assembly language (Hack). In the context of the Nand2Tetris project, the VM translator plays a pivotal role in the compilation process, bridging the gap between a high-level source language (Java-like) and a low-level target assembly language (Hack assembly). Here's how it fits into the overall compilation pipeline:

High-Level Compiler Front End:

The high-level compiler front end takes as input a Java-like source language and generates Virtual Machine (VM) code. This code represents a higher-level abstraction of the program's logic and functionality.

VM Translator (Middle Layer):

The VM translator operates as an intermediary layer between the high-level compiler front end and the low-level assembler back end. It takes the VM code as input and translates it into Hack assembly language, which is specific to the Nand2Tetris Hack platform. The VM translator is responsible for converting the higher-level VM operations into lower-level Hack assembly instructions.

Assembler Back End:

The assembler back end takes the Hack assembly code generated by the VM translator and produces binary machine code that can be executed on the Hack CPU and hardware.

VM Source Language

The VM source language is a stack-based, high-level, platform-independent language used in the Nand2Tetris project. It includes commands for arithmetic operations (addition, subtraction, etc.), memory access (push and pop), branching (if-goto, goto), and function calling (function, call, return). This language serves as an intermediary representation in the compilation process, making it easier to develop compilers and run programs on various architectures.

About

Converts high-level VM commands into symbolic Hack assembly


Languages

Language:C 98.9%Language:Makefile 1.1%