COMP226 Tutorial 3

Hand-in questions

Please remember to put these in the comp226 box on level 1 of E6A by Monday August 19 (the beginning of week 4).
  1. Write a snippet of assembly code, which swaps two 32-bit values stored in memory at locations labelled x and y. Use as few registers as you can.
  2. Why does sethi only load the high 22 bits of a register? Why can't sethi load all 32 bits?
  3. As noted in the previous question, we cannot load all 32 bits in a register using sethi. On the ISEM Reference Card, try find an instruction which we might be able to use to load a 32-bit constant in a register. Can that instructions in fact do so?
    (This question is asking you to think laterally about alternatives that could work on some machines, and then think about whether they really would work on SPARC as implemented according to the reference card.)
  4. What are some different ways in which you might usefully use the branch delay slot?

Kate and Mike, 2013. COMP226 home page