https://github.com/amdzy/hackassembler
https://github.com/amdzy/hackassembler
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/amdzy/hackassembler
- Owner: amdzy
- Created: 2022-12-18T06:14:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-18T06:24:39.000Z (over 2 years ago)
- Last Synced: 2025-01-22T02:28:32.424Z (4 months ago)
- Language: Assembly
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HackAssembler
An assembler for the hack language written in java
The program takes as an input an assembly file and outputs a hack file
* **Symbols**
* *Label symbols* (In the program above *LOOP* and *END* are label symbols) are used to mark the memory location of the next instruction in the program. Label symbols are used for *control flow* in the program.
* *Variable symbols* (In the program above *i* and *sum* are variable symbols) are treated as *variable*. Variables are mapped to consecutive memory locations.
* **Symbols table**: Since Hack instructions can contain symbols, the symbols must be resolved into actual addresses.| Symbol | Memory location |
| :------- | :----------: |
| i | 16 |
| sum | 17 |
| LOOP | 4 |
| END | 18 |The table above is the symbol table for the program above. Since in Hack system we allocate memory for variable from memory 16 so the memory location for variable *i* will be 16 and *sum* will be 17. To specify label *LOOP* and *END* we count the number of instructions in the program so that *LOOP* will be4 and *END* will be 18.