0
votes

I was reading in a MIPS manual that: "Notice we use the “unsigned” version of the “add immediate” instruction because we are dealing with an address, which is an unsigned binary number. We wouldn’t want to generate an exception just because a computed address crossed over the mid-point of the memory space."

What does this mean exactly? Specifically crossing over the mid-point of the memory space.

And also, in the following code, I don't understand why it skips from 8($sp) to 20($sp). The code loads from 12($sp) and 16($sp) later but when is it doing something with these portions of memory. I was thinking possible in jal JILL, but there isn't really much explanation given.

addiu $sp, $sp, -24 
sw $t1, 0($sp) 
sw $t2, 4($sp) 
sw $t3, 8($sp) 
sw $ra, 20($sp) 
jal JILL
lw $ra, 20($sp) 
lw $t4, 12($sp) 
lw $t5, 16($sp) 
addiu $sp, $sp, 24
1
it is not an "unsigned addition" it is an addition with an "unsigned overflow exception". The addition operation itself is not aware of the interpretation of the bits.old_timer

1 Answers

1
votes

Assumming a MIPS32 architecture, which has a 32-bit address space, the mid-point of the memory space would be address 0x80000000 (that is 2^31). In 32-bit signed (A2-compliment) arithmetics, integers from 0 to 0x7FFFFFFF are reserved for positive numbers, where integers from 0x80000000 to 0xFFFFFFFF are reserved for negative numbers.

When you issue a signed addition, you would get an overflow exception if the result of the addition "crosses" that midpoint. But in your example, you are really dealing with memory addresses, not signed numbers... therefore the sign of the address (interpreted as a 32-bit number) is meaningless so you should use unsigned addition.

Regarding your second question, you'd have to look into the JILL procedure to see what it does... surely that procedure will store some information in 12($sp) and 16($sp)