This project was submitted for Ray Ontko's "Principles of Computer Organization" class, Fall Semester, 1997-98, Earlham College Computer Science, Richmond, IN
For my programming project I implemented a Mac-1 assembler. Written in Perl, it compiles instructions listed on page 185 of Andrew S. Tanenbaum's, Structured Computer Organization, Third Edition (Prentice-Hall, 1990) into 16-bit binary Mic-1 instructions. It is able to take input such as the program on page 181 of Tanenbaum and produce the appropriate binary code.
It works! The program can successfully take the input of Tanenbaum's Figure 4-11(b) on page 181 and convert it to binary output. Yippee!
Items for the next release:
- Disassembler that will take the binary and output corresponding Mac-1 instructions
- Passing expressions as arguments, e.g. X-1
- Constants, e.g. "C1: 1" is treated as a variable instead of a label. Treating it as a label would require a level of complexity beyond the scope of my problemspace.
- Doesn't handle comments in the input since the necessary formatting of the input file is very delicate; this is acceptable because the assembler itself (as it is not a full-fledged major-league assembler).
There are several things to note in conclusion. When I took this project on, I knew very little about assembling and compiling, let alone optimizing these processes. I now feel like I have a much better grasp on the assembly process, though there is obviously optimization to be had.
I found writing the program in PERL as opposed to the conventional "C" was time-efficient for me, as I was previously quite familiar with the sytax and capabilities of PERL. I think it benefitted my program because PERL is designed to take a given input and transmogrify it in very particular ways, which is exactly what the assembly process is. PERL's language made writing an assembler simple and clear-cut for me.