Discussion:
Lab 1 Grades & Advice
(too old to reply)
A. Karl Kornel
2005-07-26 23:16:39 UTC
Permalink
Dear students,

I have completed the grading of Lab 1. For those of you who
turned in an alias, here are your grades:

Anne: 99
dynastyw4: 99
ochtend: 70
shanghai2k5: 90
Tastethe: 97

Do you want an alias? Talk to me DURING OFFICE HOURS.

16 assignments were submitted. The highest grade was 100. The
lowest grade (if you ignore those who didn't turn it in) was 70. The
average was ~90.94 with a standard deviation of 9.356. The median was
94.5.

Here's an interesting question: What does this program do? When I
asked this question to a few people, nobody was able to give me an
answer! Let's take a look!

The first three instructions multiply 0x80 (the value of mem.
location 0) with with the user-provided number (let's call it x), and
then store the result. So at the end of instruction #3 our result is
(0x80/x). The next two instructions take the result, add in x, and
subtract the stored result, giving us (0x80/x)+x-(0x80/x) as our current
result. Finally, we multiply everything by x, giving us out final
result: [(0x80/x)+x-(0x80/x)]*x. NOTE! Our final result can be
reordered to give us [(0x80/x)-(0x80/x)+x]*x, and we see that (0x80/x)
is cancelled out! This gives us the final result of x*x! So, for most
values of x this program calculates x squared. I say "most values"
because there are certain numbers that will cause the program to give us
bad results (such as 0).

As I graded these labs, I noticed a number of things worth mentioning:

Most of you used the "add" instruction to increment the PC. That's
fine, but there's another way to do it. You can use the "inc"
instruction by writing `inc %r2`. If you look at your reference card,
you'll see that "inc" is a synthetic instruction that replaces "inc"
with "add", so why use "inc"? I suggest using the "inc" instruction
because it only increments. When you use the add instruction, you could
easily mess up and type something like `add %r2, 11, %2` by accident!

Hopefully before lab 2 comes due you should learn about how to use
the call/jump/jumpl and retl instructions to execute the assembly
equivalent of subroutines. That means that you will only have to code
repetitive tasks once, such as the instruction fetch and register
display routines. Start thinking about how you could change lab 1 to do
this.

Almost everyone had used the "set" instruction to copy a hard-coded
address into the MAR register. There is, however, a way to take the
instruction, pull out the address, and put the address into the MAR.
You should be able to replace the "set" with a single instruction to
extract the address and store it into the MAR. Does anybody know what
the instruction is?

Remember, whenever you execute a sdiv instruction you must first
execute a smul instruction! Also, you should know when to use an
unsigned load or a signed load.

As for comments, there is only one place where you do not need to
have a comment for every line. When you are displaying the contents of
the registers, you do not have to have comments on every line. However,
you still need to have comments at the beginning of each group of
instructions, telling me exactly what you are printing!

Finally, regarding the preamble, it should be LONG! It is takes up
half of a sheet of paper, that's fine. When you talk about the problem,
and you say "this program simulates SAM instructions", you must tell me
which SAM instructions are being simulated! Also, your explanation of
the solutions should be very detailed.
--
=============================
| Alfred Karl Kornel
| -- ***@cse.ohio-state.edu
| Member- Europa Research Group
| UNIX / RESOLVE Consultant
=============================
B A Bair
2005-07-27 14:18:16 UTC
Permalink
Good comments. Here are some more thoughts.
Post by A. Karl Kornel
Dear students,
<...>
Post by A. Karl Kornel
Most of you used the "add" instruction to increment the PC. That's
fine, but there's another way to do it. You can use the "inc"
instruction by writing `inc %r2`. If you look at your reference card,
you'll see that "inc" is a synthetic instruction that replaces "inc"
with "add", so why use "inc"? I suggest using the "inc" instruction
because it only increments. When you use the add instruction, you could
easily mess up and type something like `add %r2, 11, %2` by accident!
On the other hand, if you're a purist, you might prefer to avoid synthetic instructions altogether. Do you think that's possible?
Post by A. Karl Kornel
Hopefully before lab 2 comes due you should learn about how to use
the call/jump/jumpl and retl instructions to execute the assembly
equivalent of subroutines. That means that you will only have to code
repetitive tasks once, such as the instruction fetch and register
display routines. Start thinking about how you could change lab 1 to do
this.
You will have to use subroutines for lab3, but for lab2 all you need is high level control structures.
Post by A. Karl Kornel
Almost everyone had used the "set" instruction to copy a hard-coded
address into the MAR register. There is, however, a way to take the
instruction, pull out the address, and put the address into the MAR.
You should be able to replace the "set" with a single instruction to
extract the address and store it into the MAR. Does anybody know what
the instruction is?
HINT - we talked about this in class on Tuesday. Splitting the 8 bit instruction into an opcode and an operand will be a requirement in lab2.
Loading...