Last updated 05/04/2003
New and updated entries are highlighted.
StorageObject class does contain a function
void backDoor (long x) that allows you to load a value into
any storage object. You are not allowed to use this function, as it is
a hack that exists for testing. Any use of this function will result in
point loss on the lab.
> Thanks, i had another doubt , for the set operations , you had said use > a descion variable d = A - temp > for signed values this will work only if both values are pos. or both are > neg. , im explicity checking for conditions where A = pos. and temp = neg. > and vice versa , for that i need to do A.value() > 0 is this ok .
No, for the set operations
d = A - temp
will work for any value pos. or
neg. work it out a couple time with value to prove to yourself
but in end,
for signed numbers
for unsigned
> I discovered a question during testing of my DLX. It has to do with > the Set Group of instructions; specifically the register-register > unsigned comparisons. Since we're comparing the full width of the > register, we can't just fill the top half of a word with zeros like we > can with the immediate forms of this instruction. > > Comparing the contents of the 2 registers via the alu subtract > operation will always give us a signed comparison. So how do we do an > unsigned comparison?
You can do the subtraction, and look at all the outputs from the ALU:
OUT() | the difference | |
CARRY() | carry/borrow flag: 0 = no, 1 = yes | |
OVERFLOW() | arithmetic overflow flag: 0 = no, 1 = yes |
Signed comparisons have these results:
| equal | OUT() == 0 | |
| less | !equal && sign_of_OUT() != OVERFLOW() | |
| greater | !equal && !less |
where sign_of_OUT() is the most significant bit of the result.
Unsigned comparisons are similar:
| equal | OUT() == 0 | |
| less | !equal && !CARRY() | |
| greater | !equal && CARRY() |
> As an example for thinking about this, I imagine a 4-bit wordsize. > I want to compare these two words: > > (a) 1010 signed value in decimal = -6, unsigned value = 10 > (b) 0010 signed value in decimal = 2, unsigned value = 2
1011 - 0010 = 1000, carry = 1, overflow = 0
| Comparison | Signed | Unsigned | |
|---|---|---|---|
| equal | false | false | |
| less | true | false | |
| greater | false | true |
> (a) < (b) with a signed test
True.
> (a) > (b) with an unsigned test
True.
> I have a doubt, while executing inst. SH do we have to shift the > rd, 16 bits or do we mask the upper order bits? before stoing in MAR. >
Inside the CPU's registers short data should always be kept in the low order bits (so that we can use it correctly in arithmetic operations). In memory short data sits at the address specified. So if you wanted to SH R1 at mem location A with:
R1 = 0000f3f2 mem[A]= 12345678
in the end memory should look like:
mem[A]= f3f25678
i.e. the half word of reg 1 was saved at the memory location A (without destroying any other memory but the 16 bit at mem location A.
So to do this you need to:
temp = R1<<16 MDR = mem[A] MDR = MDR & 0000ffff MDR = MDR | temp mem[A] = MDR
Course Home Page
My Home Page