Group specific information which you will need is found under lab1underlag. We will assign you a group number after you have enrolled, and that group number will be posted on the Lab status page, read the General info page carefully. You will have to download the *.s file for your group and save it as "smd137/lab1/lab1.s".
After you have done the tutorial (see SyncSim in the menu), and done your very best at understanding the issue of stack management, you should be ready to go ahead with the first lab. The start-up script has created the directory smd137/lab1 and placed the files "mips.xml" and "linker_script" there. You may also use the Makefile as you did in the prelab, just for convenience. Note that if you saved the "underlag" file with a different name you will have to change the variable FILE in the Makefile. Good Luck!SyncSim Simulator and the MIPS model
In this course we will use the SyncSim toolset to teach the inner workings of a modern microprocessor architecture.
One of the purposes of this course is to introduce the student to what is happening, component by component, bus by bus, inside of a computation structure (in our case, inside of a MIPS processor). The MIPS model has been carefully written to show how the multiplexers are switching, which controlling values are on which bus, what values are presently stored where, and many other details.
If you are running the MIPS model in SyncSim as if it was a "black box" and you are not trying to understand why (for example) a certain multiplexer is being steered one way and not the other for some given instruction, then you are missing the point! Other "dumb" simulators (such as SPIM) do not show any internal details of the structure while it executes.
After your program is working, take the time to single-step through the MIPS model and try to understand how the individual instructions work at the computation structure level. The more of this you do, and the more of this that you understand, then the more capable you are of designing your own computation structures (and I don't mean, just MIPS processors either).
So, this is not just some course in assembly programming!
You will turn in two parts: The first part,
DT_LABNUMMER 1 DT_LABDEL 1
should contain your MIPS assembler code only. We will take what is in this mail, compile it, and load it into the MIPS simulator (in "No Pipe" mode) and watch it run. You may use MIPS pseudo-ops for this lab. The second part,
DT_LABNUMMER 1 DT_LABDEL 2
will contain some summary information, to be described later. You will turn your lab in by electronic mail, the details are found here.
In this lab you will get a crash course in assmbly programming for the MIPS architecture. You will implement a recursive function and learn how to manage the stack, pass parameters, write controlling statements (if/while constructs), and finally perform computer arithmetics (signed/unsigned) and logical operations (and/or/xor etc.).What You Must Write
Your group will be assigned these things:
You must decode the string "coded" and store the result in a byte array called "plain". You will code in MIPS assembler for the "No Pipe" MIPS model (which means, that branches and loads are NOT delayed), and use the frame pointer for your subroutines.
TAKE THE LAB-SPECIFIC FILE FOR YOUR GROUP, AND MODIFY IT BY ADDING YOUR CODE TO IT. LEAVE ALL THE ORIGINAL PSEUDOCODE IN THE FILE, that will help us to grade your lab. Follow all instructions below please; remember to draw the "stack map" together with $fp-relative addresses for all your subroutines, as in the "sum with framepointer" example in "MIPS Programming".
We've also included some example results that your function should compute. You can use these to check that your code is working. The first examples are for your routine "codgen". The second example is a special coded word array which should decode to the string "abc", so that you can test your routine "decode" on a small string.
You are working with BOTH signed and unsigned integers (choose your compare instructions correctly) but don't worry about overflows (choose your arithmetic instructions correctly). THERE ARE NO "MULTIPLY" or "DIVIDE" instructions in the MIPS model, maybe you can use shifts instead ?
You may implement local variables in registers for subroutine
"codgen," but you MUST implement ALL local variables for
subroutine "decode" on the STACK (as practice for the final
exam), not in the registers. This lets you practice $fp-negative
stack accesses. You must use a framepointer for ALL your
subroutines, yes, even for "codgen" even though it is non-recursive.
COMMENTS in your assembler code should explain what you are doing, and why, at a higher level than the instructions themselves. The following comments are stupid and worthless:
.text # set the assembler to ".text" mode j main # jump to program label "main" sum: jr $ra # jump-register through register $ra main: li $a0, 5 # load-immediate constant "5" into register $a0 bal sum # branch-and-link to label "sum"
Here's a hint that some of you might find helpful, from "The C Programming Language" (Kernighan/Ritchie), Exercise 2-9:
In a two's complement number system, x &= (x-1) deletes the rightmost 1-bit in x. Use this observation...Grading
Part One must be your MIPS assembler code file, complete with comments and pseudocode, as discussed above.
Part Two must be a file which you create yourself, and which contains the following information please:
Last modified 2005-11-02 by pln