Monash University > School of Computer Science and Software Engineering > CSE1303 > Part B > Tutorials > Tutorial B5
This tute covers material from lectures B12 to B13.
Attempt the questions marked (*) like this before the tutorial. If you have specific questions about unmarked questions, you can ask the tutor about them during the tutorial.
if (g < h)
{
/* stuff */
}
Now try to write the same code without inverting the comparison; that is, the only branch you can use is blt (branch if less than). You may need to add additional jump instructions and labels to your code.
Comment on the increase in the length in your program, and its readability.
Suggest why it is not necessary to encode the address in bytes. (Hint: how long are instructions in MIPS?)
Suggest an advantage to encoding the address in words. (Hint: if two of the 26 bits are freed by not counting in bytes, they can be used for another purpose.)
Is the justification for using words (rather than bytes) the same as for jumps (above)?
Suggest why the offset is signed.
Estimate the range of addresses that can be branched to using a 16-bit offset.
Suggest a reason why branches use PC-relative addressing (with an offset) rather than absolute (counting from address zero). (Hint: it has to do with the range you computed above.)
Suggest why the offset counts from the next instruction rather than the current one.
Last modified 2002-01-28