Description |
Objective: Develop an assembler that translates programs written in Hack assembly language into the binary code understood by the Hack hardware platform. The assembler must implement the Hack machine language specification.
Contract: When loaded into your assembler, a Prog.asm file containing a Hack assembly language program should be translated into the correct Hack binary code and stored in a Prog.hack file. The output produced by your assembler must be identical to the output produced by the assembler supplied with the book.
Testing: We suggest building the assembler in two stages. First write a symbol-less assembler, i.e. an assembler that can only translate programs that contain no symbols. Then extend your assembler with symbol handling capabilities. The test programs that we supply for this project come in two such versions (without and with symbols), to help you test your assembler incrementally.
Test programs:
Each test program except the first one comes in two versions: ProgL.asm is symbols-less, and Prog.asm is with symbols.
Program |
Description |
Symbol-less version |
Add.asm |
This program adds the numbers 2 and 3 and puts the result (5) in ram[0].
|
|
Max.asm |
Computes max(R0,R1) and puts the result in R2.
|
MaxL.asm
|
Rect.asm |
Draws a rectangle at the top left corner of the screen. The rectangle is 16 pixels wide and R0 pixels high.
|
RectL.asm
|
Pong.asm |
A single-player Ping-Pong game. A ball bounces constantly off the screen's "walls." The player attempts to hit the ball with a bat by pressing the left and right arrow keys. For every successful hit, the player gains one point and the bat shrinks a little to make the game harder. If the player misses the ball, the game is over. To quit the game, press ESC .
|
PongL.asm
|
Note: The Pong program was written in the Jack programming language (Chapter 9) and translated by the Jack compiler (Chapters 10-11) into the supplied assembly program. The resulting machine-level program is about 20,000 lines of code, which also include the Sack operating system (Chapter 12).
Requirements: Since this is the first programming project you have, a quick reminder from the guidelines page. You program should be in either Java or C/C++. For any other language - contact the TA. You should supply a makefile to compile your code, and a shell script to run your program, if it is not compiled to an executable (which will probably be the case if you are using Java).
The usage is the same as our Assembler: Assembler Pong.asm should produce a Pong.hack file in the same directory.
You have makefile and shell script templates in the guidelines page. Don't forget to 'chmod +x' your shell script, otherwise it won't work.
Keep your code well organized and documented, as you would in every programming project.
|