.. (לתיקייה המכילה) | ||
How do I work with spim and qtspim? | |
spim is a linux executable which runs a mips program, and QtSpim is a debugger which you can install for windows, linux or mac. Here are a few pointers for using them. 1. spim.zip needs to be unzipped in your csl2 account, and you will then have access to spim (the simulator you will be tested with). 2. qtspim likes files with a *.s extension. 3. qtspim can set breakpoints in your code. 4. You can always debug with printouts using the syscalls (see the impl of print and printi in the pdf). 5. Both of these only run a "full" assembly program. What does this mean for you? That initially, when all you can handle is, say, basic arithmetic, you will need to wrap that code in a program - an entry point and an exit point. You can take the "wrapper" from either spim's hello world or qtspim's hello world. Until such time as you generate this code yourself, you can take your code and paste it into an existing main, and then run. |
I would like to do <a thing> using an assembly command I found in the mips manual. Can I? Should I? | |
Can you? Yes. However, note that the list of commands at the beginning of the exercise is a match for all the IR commands you learned in class, plus lw and sw that write and read from the stack, and that you don't need more in order to solve the homework. If you're looking outside this list and, at most "syscall", you're probably making your life difficult in some way. |
I would like to do <a thing> which would create more optimized assembly code in case of <a scenario>. Can I do that? | |
NO. STOP. STEP AWAY FROM THE OPTIMIZATION. DO NOT DO THIS. YOU'RE JUST MAKING THINGS HARD FOR YOURSELF. Produce naive code. Naive code is enough. |
When should the default case of a switch be used? | |
If there exists a matching case for the switch expression, that case should be executed. The default case should only be used when no matching case exists. It doesn't matter where in the code the default case appeared. Same logic should apply whether the default case appeared first, last, or any other location. |
What should we do if a function doesn't contain a return? | |
You should always return to the caller at the end of a function, whether it contains a return or not. If the function is supposed to return a value and doesn't, that's not an error. (Same as regular C) |
Should we pass arguments to a function via registers or the stack? | |
Use the stack (also, it's much simpler) |
Dealing with overflows | |
To avoid any overflow exceptions, use addu and subu instead of the add and sub commands respectively. For more information, see http://www.cs.unibo.it/~solmi/teaching/arch_2002-2003/AssemblyLanguageProgDoc.pdf |