Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Latest commit

 

History

History
38 lines (29 loc) · 603 Bytes

README.md

File metadata and controls

38 lines (29 loc) · 603 Bytes

hack-assembler

Ruby implementation of an assembler for the Hack machine language

Takes Hack assembly code as input:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/06/add/Add.asm

// Computes R0 = 2 + 3

@2
D=A
@3
D=D+A
@0
M=D

And when passing along to the ruby assembler script:

ruby hack_assembler.rb add.asm

Maps the Hack assembly language to machine code:

0000000000000010
1110110000010000
0000000000000011
1110000010010000
0000000000000000
1110001100001000