Discussion:
Lab 2 Question
(too old to reply)
Ryan McNeeley
2005-11-08 19:43:39 UTC
Permalink
A relatively simple question I think--
Why in the lab input example does the user specify M[0] = 0x9a? And
likewise for M[1] = 0x4f and so on...

I understand that M[0x1a] refers to M[26], and that the decimal value of 1
is stored there, likewise I understand for M[0x19] and that this refers to
M[25] and storing of 1 there as well.

I think my question is best stated--how is it possible to distinguish
between when the user is inputting values to be stored somewhere and when
they are inputting opcodes along with addresses? Basically, can it be
assumed that a user will input in a M[0],M[1],M[2],...etc. format always?
And that the 0-9 (or some arbitary decimal value) refer to the order that
the operations should be executed? Thanks in advance.
--
Ryan McNeeley
***@osu.edu
Ryan McNeeley
2005-11-08 20:00:30 UTC
Permalink
Is it safe to just initiate a loop to grab memory locations (in hexadecimal)
along with values to be stored at those locations until you receive a memory
address input that is in non-hexadecimal format (such as M[0])? And when
you get this non-hexidecimal value for memory, you just assume it is
denoting that the value inputted after it will be a full instruction
complete with opcode and address?
Post by Ryan McNeeley
A relatively simple question I think--
Why in the lab input example does the user specify M[0] = 0x9a? And
likewise for M[1] = 0x4f and so on...
I understand that M[0x1a] refers to M[26], and that the decimal value of 1
is stored there, likewise I understand for M[0x19] and that this refers to
M[25] and storing of 1 there as well.
I think my question is best stated--how is it possible to distinguish
between when the user is inputting values to be stored somewhere and when
they are inputting opcodes along with addresses? Basically, can it be
assumed that a user will input in a M[0],M[1],M[2],...etc. format always?
And that the 0-9 (or some arbitary decimal value) refer to the order that
the operations should be executed? Thanks in advance.
--
Ryan McNeeley
Brandon
2005-11-08 20:08:55 UTC
Permalink
M[0] stands for SAM memory location 0. Remember that SAM has memory
locations 0-31. When the user enters M [0x1a] = 1, all they are doing is
storing 1 to SAM memory location 26. On the other hand, M [0] = 0x9a instead
stores 100 11010 to SAM memory 0, which of course is SAM for Load 26.

The user is responsible for loading everything, including SAM instructions
and data. You should keep looping until the user enters a negative value
for the memory location.
Post by Ryan McNeeley
A relatively simple question I think--
Why in the lab input example does the user specify M[0] = 0x9a? And
likewise for M[1] = 0x4f and so on...
I understand that M[0x1a] refers to M[26], and that the decimal value of
1 is stored there, likewise I understand for M[0x19] and that this refers
to M[25] and storing of 1 there as well.
I think my question is best stated--how is it possible to distinguish
between when the user is inputting values to be stored somewhere and when
they are inputting opcodes along with addresses? Basically, can it be
assumed that a user will input in a M[0],M[1],M[2],...etc. format always?
And that the 0-9 (or some arbitary decimal value) refer to the order that
the operations should be executed? Thanks in advance.
--
Ryan McNeeley
Ryan McNeeley
2005-11-08 20:36:26 UTC
Permalink
Ok, so when they input M[0], they really are just saying M[0x0]? and
likewise for M[1] = M[0x1]? After the user enters a negative number, I'll
stop looping. At this point I will have a bunch of memory locations 0-31,
some with values in them and some with instructions. How am I supposed to
distinguish whether the data stored in a memory location is just a value to
be used in computation or an instruction? Moreover, how do I tell my
program where to begin with the instructions?
Brandon
2005-11-08 20:47:08 UTC
Permalink
As in Lab 1, the prelim section should initiate the PC (%r2) to 0 and the
beginning of SAM memory (MEM) to %r7. The fetch command looks the same also,
with ldub [%r7 + %r2]. This causes the information at SAM memory location
PC to be loaded, and since the PC was initialized to 0, whatever instruction
the user loaded at location 0 will be executed. As long as you properly
increment your PC and load correctly, the instructions will be up to the
user to make sure they work properly. The only thing you have to worry
about is decoding the opcode, obtaining the correct addr to move to the MAR,
and then performing the correct operation based on the opcode, before
returning to the FETCH cycle again.

I hope that helps some; I didn't want to give away so much as to be
cheating.
Ryan McNeeley
2005-11-08 21:14:03 UTC
Permalink
Thanks for your help! That clears up a lot for me, I guess I was expecting
to have to cover cases where the user wasn't obeying the rules. I think I
should be moving along quite swiftly now. Thanks again.
B A Bair
2005-11-09 01:34:54 UTC
Permalink
It is perfectly okay for the user to use instructions as data and vice
versa. That's part of the fun of programming at a low level!
Post by Ryan McNeeley
Thanks for your help! That clears up a lot for me, I guess I was
expecting to have to cover cases where the user wasn't obeying the rules.
I think I should be moving along quite swiftly now. Thanks again.
Ryan McNeeley
2005-11-09 01:30:21 UTC
Permalink
Is it ldub [%r7 + %r2] in the Fetch? or ldub [%r7 + %r2]? Thanks.
B A Bair
2005-11-09 01:36:32 UTC
Permalink
I don't think that it is ever %r7+%r2... Why would you use the PC this way?
That's what the MAR is for.

In any case you should use ldub when you are reading non-integer information
(like an instruction or a character).
Post by Ryan McNeeley
Is it ldub [%r7 + %r2] in the Fetch? or ldub [%r7 + %r2]? Thanks.
Ryan McNeeley
2005-11-09 02:02:59 UTC
Permalink
Thanks!

Loading...