Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assembler for the 16-bit Hack Assembly language

This project is part of the nand2tetris course.

Quick Start

Pick a .asm file from hack-examples/ dir

// Computes RAM[0] = 2 + 3
@2
D=A
@3
D=D+A
@0
M=D

Usage

usage: hasm.py [-h] asmfile

positional arguments:
  asmfile     Input .asm file

options:
  -h, --help  show this help message and exit

Run the command:

$ python3 hasm.py simple_add.asm

The binary file is printed:

0000000000000010
1110110000010000
0000000000000011
1110000010010000
0000000000000000
1110001100001000

You can also find the binary executable at testing/simple_add_actual.hack. Now you can run it on hack hardware.

About

Hack Assembler in Python

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.