Homework # 2 FAQ

      Problem 1: Does the fact that this is Java and not C code change anything?

Yes, please remember that Java arrays must know their size and do a check whenever an array access is performed in order to ensure that the index is within the array bounds.

Problem 1: Where is the size of arrays A and B stored?

With Java, 0 to 100 is mapped as 2 to 102, with address 1 storing the size.

Problem 1: What is a memory data reference?

A "memory data reference" is referring to both loads and stores.  It says "data" to differentiate it from an "instruction" reference (since instructions also need to be fetched from memory), which we are disregarding.

Problem 1: What happens when an exception is thrown?

You can create a label that you can jump to if an exception is thrown which will exit the loop.
 

     Problem 2: The average CPI for logical instructions is not included.  How should I calculate this?

Logical instructions are included in the category of arithmetic instructions.

Problem 2: The numbers do not add to 100%.  What should I do?

Use the numbers given and do not worry that they do not add to 100%.

Problem 5: When it says we do not have a register whose contents we may destroy, does that imply that we
can use the stack to store values?

You can use this address in the stack: temp($r0).
 

      Problem 7: What is the jalr $rd, $rs instruction?

This is the jump and link register instruction. It is used to link to a function, where the start address of the function is in $rs and the return address is in $rd. For this problem you should ensure that the program execution jumps to $rs and returns to $rd after the function completes.

      Problem 7: It seems that there are no existing datapaths that could get PC+4 to write-data in the register module, are we allowed to add more wires, gates or multiplexers to the microprocessor design to add this "jal" functionality?

Yes, you may add any additional gates, wires, multiplexers and control signals as you see fit, as long as the processor remains a single cycle one.