Project 2: Assembly language
Assembly language is a very low-level representation of programs,
having a direct translation to what the machine actually executes.
(Basically, a compiler translates from a high-level language like C++
to assembly language, which the computer can then interpret quickly and
easily when it runs the program.)
Knowing how assembly language looks is important to programmers
interested in writing very efficient code.
For the project, you will write two short programs in an assembly
language called DLX.
- Implement the Dynamic-Fibonacci algorithm on page 103 of this
year's text using DLX.
- Now, for a bigger challenge, implement the recursive Fibonacci
algorithm on page 102 using DLX. (Don't use procedure calls;
instead, just implement the recursion stack explicitly in your
program. This isn't entirely easy.)
Resources for learning about DLX:
- An excerpt from last year's textbook (PDF)
- This is a very quick introduction to assembly language and DLX
that I included in the textbook last year. You'll probably want to look
over Section 12.1 of this year's textbook before you read this.
- The DLX assembler
- A compiled version this for SUN machines is at
/afs/cs/user/cburch/www/pgss/work/self/dlxsim
This is a Unix-based command-line system, but it's not necessary to
know Unix well to use it.
I recommend that you edit your program from your computer (using
CodeWarrior's built-in editor, perhaps) and save it in your AFS home
directory.
In another window, keep an open telnet connection to a Sun system (like
sun4.andrew) in another window and run the simulator in it.
A TA can help you with this.
- DLX simulator manual (PDF)
- This describes the commands you can use for the DLX simulator.
The most important commands to understand are
load, go, and get.
- My Prime-Test-All implementation
- The DLX assembler allows you to use labels instead of memory
addresses, substantially simplifying address calculation.
The on-line implementation (a translation of the example from last
year's textbook) demonstrates how this works.
- A list of DLX instructions
- In addition to the instructions mentioned here, I added a few to my
simulator. You'll probably not find them useful, but I mention them for
completeness.
| mul, muli, mulu, mului | multiply two integer registers |
| divp, divpi, divpu, divpui | divide two integer registers |
| mod, modi, modu, modui | remainder on dividing two integer registers |
- Computer architecture: A quantitative approach, by
Hennessy and Patterson
- This book is the primary definition of DLX, on pages 96-108. Since
defining the language
isn't a major goal of the book, it is not a very complete or
accessible definition, but it appears to be the best available.
(The library should have some copies of this; Carl Burch also has
one.)
Go to the project index.