Read Chapter 4 and the Assembly Language notes.
- Here are some free chapters: http://www.nand2tetris.org/chapters/
Create a repository on Bitbucket named exactly
csci201-project-04. Invite me (
joshuaeckroth) as a reader.
Write the following programs in the Hack assembly language. Test your programs with the supplied test scripts in the CPU Emulator program.
Programs to write
Add4– adds four numbers (found in
R3equivalently) and stores result in
R0). Your program must finish in 30 cycles or fewer.
Max4– finds the largest value in
R0-R3and stores result in
R0. Your program must finish in 100 cycles or fewer.
Sort4– sorts (ascending) values in
R0-R3. Your program must finish in 200 cycles or fewer.
Search– given a value to find in
R0and a memory address in
R1(>= 2) that indicates the last position in memory of the values to search through, search through
nis the value in
R1) for the value
R0. If the value is found, set
R0to 1. Otherwise, set
R0to 0. Your program must finish in 200 cycles or fewer.
Download ZIP containing test scripts – NOTE:
MoveDot is not included because it will be part of project 5 instead.
If your programs are the shortest among other submissions from our class, you receive extra credit.
- All programs minimal: +2 pts
- At least 2 programs minimal: +1 pt