Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thisisnic/pyhackassembler
A project as part of Nand2Tetris (part 1) to turn Hack assembly code into binary machine code
https://github.com/thisisnic/pyhackassembler
Last synced: 1 day ago
JSON representation
A project as part of Nand2Tetris (part 1) to turn Hack assembly code into binary machine code
- Host: GitHub
- URL: https://github.com/thisisnic/pyhackassembler
- Owner: thisisnic
- Created: 2024-03-09T18:46:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-09T20:20:50.000Z (11 months ago)
- Last Synced: 2024-12-03T18:52:07.406Z (about 2 months ago)
- Language: Assembly
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pyhackassembler
This repo contains my implementation of the final project from Nand2Tetris (part 1), which converts Hack assembly code into binary machine code.
Takes a Hack assembly (`.asm`) file containing e.g.
```
// 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 (R0 refers to RAM[0])
@2
D=A
@3
D=D+A
@0
M=D
```and produces the equivalent binary code as a `.hack` file:
```
0000000000000010
1110110000010000
0000000000000011
1110000010010000
0000000000000000
1110001100001000```
## Example usage
To run the code:
```py
python3 ./assembler/assembler.py ./add/Add.asm
```