Problem 1
Problem 2
1
FIB: addi $sp, $sp, -12
sw $ra, 8($sp)
sw $s1, 4($sp)
sw $a0, 0($sp)
siti
beq $t0, $0, L1
addi $v0, $0, 1
j EXIT
L1: addi $a0, $a0, -1
jal FIB
addi $a0, $a0, -2
jal PIB
add $v0, $v0, $s1
EXIT: lw $a0, 0($sp)
lw $s1, 4($sp)
lw $ra, 8($sp)
addi $sp, $sp, 12
ir $ra
For the following characters
hello world
a Translate the strings into hexadecimal ASCII byte values.
68 65 6C 6C 6F 20 77 6F 72 6C 64
b Translate the strings into 16-bit Unicode (using hex notation and the Basic Latin character set).
0068 0065 006C 006C 006F 0020 0077 006F 0072 006C 0064
For the following hexadecimal ASCII character values
414444
c Translate the hexadecimal ASCII values to text
ADD
Problem 3
For the binary data below
0010 0000 0000 0001 0100 1010 0010 0100
a Write the MIPS assembly code that creates the 32-bit constants listed above and stores that value to register $t1.
li $t1, 0x2001424
b If the current value of the PC is 0x00000000, can you use a single jump instruction to get to the PC address as shown in the table above?
No, a single jump instruction cannot be used to get to the PC address as shown in the table above.
c If the current value of the PC is 0x00000600, can you use a single branch instruction to get to the PC address as shown in the table above?
No, a single branch instruction cannot be used to get to the PC address as shown in the table above.
Problem 4
a The MIPS assembly program above computes the Fibonacci of a given input. The integer input is passed through register $a0, and the result is returned in register $v0. In the assembly code, there are a few errors. Correct the MIPS errors.
For the two addressing modes: Base or Displacement Addressing Pseudo-direct Addressing
b For the recursive Fibonacci MIPS program above, assume that the input is 4. Rewrite the Fibonacci program to operate in a non-recursive manner. Restrict your register usage to registers $s0-$s7. What is the total number of instructions used to execute your solution from 2.20.2 versus the recursive version of the factorial program?
e Show the contents of the stack after each function call, assuming that the input is 4.
a Give an example MIPS instruction that shows each of the MIPS addressing modes.
b For the instructions in part a, what is the instruction format type used for each instruction?
c List the benefits and drawbacks of a particular MIPS addressing mode.