csse232_hw1_soln - Fall 2016-2017 CSSE 232 CSSE 232...

This preview shows page 1 - 3 out of 8 pages.

Fall 2016-2017CSSE 232CSSE 232 – Computer Architecture IRose-Hulman Institute of TechnologyComputer Science and Software Engineering DepartmentHomework 1 Solutions1. (10 points) Please pay attention to this question.The goal is to get you to see thebigger picture of what the code is doing. The answer is not to simply explain what eachinstruction is doing. Consider the following code used to implement the instructionsllv $s0, $s1, $s2which uses the least significant 5 bits of the value in register $s2 to specify the amountregister $s1 should be shifted left:.datamask:.word0xfffff83f.textstart: lw$t0, masklw$s0, shifterand$s0, $s0, $t0andi$s2, $s2, 0x1fsll$s2, $s2, 6or$s0, $s0, $s2sw$s0, shiftershifter:sll$s0, $s1, 0Add comments to the code and describe how it works. Note that the twolwinstructionsare pseudoinstructions that use a label to specify a memory address that contains theword of data to be loaded. Why do you suppose that writing “self-modifying code”such as this is a bad idea?
5 September 2016Page 1
Fall 2016-2017CSSE 232Problems: could build an invalid instruction, debugging is difficult, and the instructioncache is invalidated.2. (25 points) As discussed on pages 140–141 (Section 2.12 “Assembler”), pseudoinstruc-tions are not part of theMIPSinstruction set, but often appear inMIPSprograms.For each pseudoinstruction in the following table, produce a minimal sequence of actualMIPSinstructions to accomplish the same thing. You may need to use$atfor someof the sequences. In the following table,bigrefers to a specific number that requires32 bits to represent andsmallto a number that can fit in 16 bits.PseudoinstructionWhat it accomplishesmove $t0, $t1$t0 = $t1clear $t0

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture