Homework 2: MIPS, instruction encoding, data representation
CSE 410, Autumn 1999
Due in class, October 11th

Reading

H+P Chapter 3, sections 4, 6, and 8-10.

To do on your own

Fill in this chart:
binary hexadecimal decimal
    293
    1708
  0x87a4  
  0xff0c  
1100 1010 1111 1110    
1111 1010 1101 1110    

To be turned in

1. Suppose $a0 contains 200 and $a1 contains 4. Also suppose that part of memory contains these values:

Trace through the following code. What does the memory range above look like after the code executes? What does the program do? 2. In the instruction formats we saw in class, the opcode had six bits. How many operations can be encoded using the opcode alone?

For some op values, other fields in the instruction are used in combination with the opcode. For example, when op=0, the last six bits of the instruction -- the "funct" field in R-format -- further specify the operation. How many operations can be encoded using either opcode alone or (opcode=0 and funct)?

3. H+P 3.4 and 3.5

Note: For problem 3.5, you need to load a 32-bit constant into a register. See the example on page 147.

4. As discussed on page 157 and summarized in Figure 3.37, pseudoinstructions are not part of the MIPS instruction set but often appear in MIPS programs. For each pseudoinstruction in the following table, produce a minimal sequence of actual MIPS instructions to accomplish the same thing. You may need to use $at for some of the sequences. For the beq line, assume that "number" is a number that can be represented with 16 bits.

Note: You may need to use the "li" instruction, which stands for load immediate. See page A-59.