ms0g / hasm

Assembler for the 16-bit Hack machine language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hasm

Assembler for the machine language built for the virtual hardware platform from From Nand to Tetris MOOC on Coursera.

The machine language is based on two 16-bit command types. The address instruction has the format 0xxxxxxxxxxxxxxx. This instruction causes the computer to load the 15-bit constant xxx...x into the A-register. The compute instruction has the format 111accccccdddjjj. The a and c-bits instruct the ALU which function to compute, the d-bits instruct where to store the ALU output, and the j-bits specify an optional jump condition.

Building

mkdir build && cd build
cmake .. && cmake --build .

Usage

./hasm [inputfile.asm]

Assembling process has two passes.The first pass scans source code,inserts labels and user defined variables into symbol table and creates intermediate file that doesn't include labels,spaces and comments.The second pass scans intermediate file,converts operands to their respective memory addresses via symbol table and mnemonics to equivelant machine instructions,then creates hack executable [inputfile].hex file.

To run hack program, use hvm

About

Assembler for the 16-bit Hack machine language

License:MIT License


Languages

Language:C 89.5%Language:Assembly 4.5%Language:C++ 4.5%Language:CMake 1.5%