MIPS is an instruction set full of pretty dumb instructions. It's not all bad for the instructions to be so simple, because that leads to very efficient implementations. However, it does mean that it can be a pain to write code for more complex things. Classically, that's fixed by making the assembler smarter: adding some useful macros to fake instructions that are not really there but would be useful.
The classically most annoying "feature" of MIPS is the lack of a 32-bit load immediate. There is a standard fix for it though: most MIPS assemblers fake having a load immediate instruction, li (which they also allow to be called load address, la):
li $t0,1 li $t1,0xf0000 li $t2,12345678
The standard MIPS implementation of li wisely selects the best of three forms for coding li $reg,immediate:
Well, originally, I was going to have you do a second thing -- as described in this section. However, I've dropped this. You don't have to do it. Really. Just ignore this section....
There's one more improvement we'll have you make: adding jbeq and jbne. These two "instructions" should act just like beq and bne... unless the branch target is too far away to encode in the 16-bit offset field. In that case, it should flip the condition and branch over a jump (j) instruction to the actual target. In other words, this:
jbeq $t0,$t1,lab
would be coded like:
beq $t0,$t1,lab
if lab is in range, but otherwise like:
bne $t0,$t1,skip j lab skip:
There's one complication -- you don't make a label (i.e., no skip). If you think about it, you know the offset to skip because you know exactly how big the j lab instruction is.
As described in class, in this project you will modify the MIPS assembler, aikmips, so that it also handles the extensions described above.
When you're testing the MIPS assembler built with AIK, be warned that AIK builds a slightly non-standard MIPS assembler. In particular, comments are taken to start with a ;, not with a #.
Generally, you will be expected to create your own test cases for each project. However, here's a simple test case:
li $t0,1 li $t1,0xf0000 li $t2,12345678
Look familiar? It should. It's near the top of this page. What should it generate? Well, the same output as:
ori $t0,$0,1 lui $t1,0xf lui $t2,(12345678>>16) ori $t2,$t2,(12345678&0xffff)
What is that output? This .text segment:
//generated by AIK version 20070512 @0000 34 08 00 01 3c 09 00 0f 3c 0a 00 bc 35 4a 61 4e //end
The .data segment is empty.
The recommended due date for this assignment is before class, Friday, February 5, 2016. This submission window will close when class begins on Feb 10, 2016. You may submit as many times as you wish, but only the last submission that you make before class begins on Feb. 10, 2016 will be counted toward your course grade.
Note that you can ensure that you get at least half credit for this project by simply submitting a tar of an "implementor's notes" document explaining that your project doesn't work because you have not done it yet. Given that, perhaps you should start by immediately making and submitting your implementor's notes document? (I would!)
For each project, you will be submitting a tarball (i.e., a file with the name ending in .tar or .tgz) that contains all things relevant to your work on the project. Minimally, each project tarball includes the source code for the project and a semi-formal "implementors notes" document as a PDF named notes.pdf. It also may include test cases, sample output, a make file, etc., but should not include any files that are built by your Makefile (e.g., no binary executables). For this particular project, name the AIK source file description of the MIPS instruction set myaikmips.
Before you can submit anything, you must register with the class server.
Submit your tarball below. The file can be either an ordinary .tar file created using tar cvf file.tar yourprojectfiles or a compressed .tgz file file created using tar zcvf file.tgz yourprojectfiles. Be careful about using * as a shorthand in listing yourprojectfiles on the command line, because if the output tar file is listed in the expansion, the result can be an infinite file (which is not ok).