Questions and Answers
- Could you explain in personal email how FOO works?
- I (bsy) do not want to type in long explanations in email.
I have tendonitis, and would prefer to avoid typing unnecessarily.
If you have a question, come by my office and ask it to me face to face;
I can get better feedback on what your confused about,
and avoid typing explanations on parts that you already know and
give more details on what you don't.
- What if I keep the calculator stack in registers? Is
It's okay to use registers, but you have to use separate functions for
the binary operators; that's one of the requirements for this assignment.
The standard calling convention do not allow you
to assume anything about the contents of the s registers,
nor can you change them in the functions -- when functions return,
the s registers must have the same values that they had before
the function is called. Similarly, the caller is not allowed to make
any assumptions about what the called function did with the t
If you had stuck with the standard register usage / calling conventions
as required, and you kept the calculator stack in registers, then the
only function that could possibly know how the stack is implemented is
your main function, which would satisfy the abstraction requirement to
limit knowledge about the stacks implementation to a few functions.
- Can the stack be global?
- The stack can be global, but it should be abstract: the details
of how it works should be
isolated to main or to push/pop routines -- the functions
implementing the calculator's binary operators should not know the
details of how the stack is implemented.
- What sort of illegal commands do we have to detect?
- We are pretending that we are implementing a circa 1970 HP
calculator. Keystrokes are always single characters. (Numeric input
is multicharacter only because it would be too painful to type in numbers
with a ``Enter'' after every digit.) You can just look at the first
character of the input and ignore the rest for the non-numeric input. For
numeric input you must check that every character is valid and generate an
error message if an invalid character is detected. See
~/../public/calc for the I/O behavior that I expect your program
- Do I have to have variables named x, y, z, and w, or can I have
an explicit stack or a pointer to the top of the stack or ....
- You may do it any way you please, except that your program
must satisfy the I/O requirements of the assignment
(do the operations, be able to output negative numbers, etc), use separate
functions for each of the binary operators, and obey the standard calling
- In assignment 4, do we need to manipulate the stack in the
functions or can we do it in the main loop? Likewise, can we detect
errors such as division by zero in the main loop?
- That can be in the main loop.
- In assignment 4, do we have to turn in our C or C++ version,
or is turning in the MIPS version ``good enough''.
- You should have C, C++, or at least high level pseudo-code
to document your MIPS assembly code. I strongly
recommend that you get your code working as C or C++ code first, before
translating it to MIPS. This avoids conceptual bugs and makes debugging
easier. You should turn in the C or C++ version as part of the
documentation for your MIPS program; it does not have
- How are expanded ble, bgtu, mul, la, etc... ?
- Write a short asm program using them (it doesn't have to
make any sense). Then load it into SPIM and check the code panel. It
will show how these pseudo-instructions were expanded.
- In assignment 4, do we have to have a jump table?
- No. I talked about jump tables because there was a question
about how to translate switch statements. While you should know
how to use jump tables -- this was part of the reading assignment -- I do
not require that you use them for this assignment. In this assignment,
you are given the functional specifications, and you must design the overall
software architecture -- with the exception that I require you to use separate
functions for each binary operator (+, -, *, /, ^) of the calculator. Your
design should be reasonably clean and well documented, so it is easy to
understand / modify.
- In assignment 3, when I enter in test cases with large values,
e.g., 100100, the MIPS emulator tells me that exception 9 was
caught and ignored. Should I worry about this?
- You should worry about the size of the MIPS registers instead.
You should answer the following questions yourself: (1) how many bits are
in a MIPS R2000 register? (2) How many bits would be required to represent
the answer to 100100? (3) What are overflows anyway?
Understanding this would be helpful in many situations, including the
- What's the difference between the branch instructions and
the jump instruction?
- Read page 148 of Patterson & Hennessey. This was part
of the Chapter 3 reading.
- Do I have to handle hexidecimal input for assignment 3?
- You are just supposed to write the exp routine.
You should not modify the main code at all -- that is where the
I/O is handled.
- I see that you are logged on ieng9. I am trying to use
talk. Why don't you ever answer?
- The fact that you see me logged on with w or other
commands doesn't mean that I am actually sitting in front of my computer.
- Can I use spim at home?
- Yes. You can use the text-only version (spim)
through any connection to ieng9 (even a very slow modem). If
you want to use the X-Windows version (xspim), you need an X
server on your home machine (there might be freely available X servers
for Windows 95 and the Mac). You can't run xspim across the
wire without it (it will say that it can't find a DISPLAY).
I am told that there is also a native Windows version of spim
available through FTP (see the book, page A-40). This is certainly
going to be easier, and you won't need to be connected at all. In
case you are using it, make sure that your solution runs the same on
ieng9, as we won't go to your place to see it work.
NOTE: PCs are little-endian machines, whereas the
Suns are big-endian machines. If your code has endian dependencies,
then you will definitely have problems getting it to work on the Suns
if you first get it to work on a PC.
- Can I use the mult instruction in assignment 3?
- How do I include my test cases in assignment 3?
- As comments in your .asm file (close to your
code). It doesn't matter exactly where, just make sure it's clear.
- How do I run the turnin program?
- Go to a shell and type in help turnin for
instructions provided by ACS.
- When is the midterm?
- Nov 3rd.
- Is this going to be on the (midterm, final)?
- Will we need to know how to do related base conversions fast?
- Yes. On the test there will be base conversion problems. If
you have to convert first to base 10 and then to the target base, you
will take much too much time doing those problems. My tests are hard
and have too many questions, and you will not be allowed calculators.
- Does our assignment 2 have to handle 00?
- Yes. It may return either 0 or 1.
(Mathematically, it is not well defined: look at various limits of
- In a subroutine call, couldn't we just move the complete
return instruction into where it should go rather than generating it in
- Yes, that would be better. The dynamic generation method
is illustrative: it can be used to create a switch statement,
or to implement a read/write array.
- Should assignment 2 use two subroutines, i.e., one for mult
and another for add, or is one enough.
- Having a single subroutine for mult is enough.
CSE home |
CSE talks |
bsy's home page |
webster i/f |
pgp key svr |
email@example.com, last updated Mon Nov 17 21:29:47 PST 1997.email bsy