Homework 1
Homework 1
ii) Translate the following machine code instruction into its equivalent MIPS assembly instruction.
ox8C680030
Q - 2 This question explores 32-bit constants in MIPS. For the following problems, you will be using
the binary data presented below.
0000 1111 1011 1110 0100 0000 0000 0000
i) Write the MIPS assembly code that creates the 32-bit constant listed above (binary data) and stores
the value to register $t1.
ii) If the current value of the PC is 0x00000600, can you use a single branch instruction to get the PC
address as shown above (binary data)?
[HINT: Identify the minimum and maximum addresses, where a brach instruction can target.]
iii) If the immediate field of an MIPS instruction was only 8 bits wide, write the MIPS code that
creates the 32-bit consents listed above (binary data) and stores that value to register $t1. Do not
use the lui instruction.
Q - 3 Consider three diff erent processors P1, P2, and P3 executing the same instruction set. P1 has a 3
GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI of 1.0. P3 has a 4.0 GHz
clock rate and has a CPI of 2.2.
i) Which processor has the highest performance expressed in instructions per second?
ii) If the processors each execute a program in 10 seconds, fi nd the number of cycles and the number
of instructions.
iii) We are trying to reduce the execution time by 30% but this leads to an increase of 20% in the CPI.
What clock rate should we have to get this time reduction?
NOTE: Overflow occurs when a result is too large to be represented accurately given a finite word size.
Underflow occurs when a number is too small to be represented correctly—a negative result when doing
unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two
negative integers is also referred to as underflow by many, but in this textbook, that is considered an
overflow.)
Page 1 of 2
i) What is the sum of A and B if they represent signed 16-bit hexadecimal numbers? The result
should be written in hexadecimal. Show your work. Is there overflow, underflow, or neither.
ii) What is the difference of A and B if they represent signed 16-bit hexadecimal numbers? The result
should be written in hexadecimal. Show your work. Is there overflow, underflow, or neither.
Q - 5 Using 4-bit numbers to save space, multiply -3ten x 3ten, or 1101two x 0011two.
Apply algorithm shown in Figure 3.5 of the textbook.
Q - 6 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that
the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively.
Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.
sll $t0, $s0, 2 # $t0 = f * 4
add $t0, $s6, $t0 # $t0 = &A[f]
sll $t1, $s1, 2 # $t1 = g * 4
add $t1, $s7, $t1 # $t1 = &B[g]
lw $s0, 0($t0) # f = A[f]
addi $t2, $t0, 4
lw $t0, 0($t2)
add $t0, $t0, $s0
sw $t0, 0($t1)
Q - 7 Write down the binary representation of the decimal number (63.25), assuming the IEEE 754
single precision format.
Page 2 of 2