Group 3 - Final Project Report
Group 3 - Final Project Report
Hanoi, 2024
2. Curiosity Marsbot
a) Problem:
Curiosity Marsbot runs on Mars, remotely controlled by developers from
Earth by sending control
messages from the key matrix with the following code:
Control code Meaning
1b4 Start moving
After receiving the control code, Curiosity Marsbot does not proceed
immediately but must wait for the activation command from the Keyboard.
There are 3 commands:
Command Meaning
Enter Complete receiving the control code, Marsbot
takes the action.
Delete Clear the receiving control code
b) How to use:
• Compile the program
• Open digital lab sim tool, Keyboard and display MMIO Simulator and
Marsbot run the program.
• Enter code in digital lab and enter command in keyboard MMIO. The
marsbot will perform action base on code and command
The program will in infinite loop, waiting for the input key of keyboard MMIO.
When a button in Digital Lab is pressed, an interrupt will raise and allow the
program to check for key press in Digital Lab.
The program will start with Init function: by rotating to bot to 90 degrees.
Allow it to go to the right when the user makes it move.
WaitForKey function: waiting for the input key of keyboard MMIO. When a key
is pressed, the program will identify the command and perform execution:
If a key in Digital Lab is pressed, the program will be interrupted and run
getCode function to get the input key. The key will be appended to
control_code.
During the runtime, each time a Marsbot performs an action, the coordinate
and angle will be saved in an array history. Allow trace back the action when
the bot has to follow the reverse trace.
d) Demonstration
- The marbot started moving (‘1b4’) and turn left (‘666’).
- “Space” button is pressed three times, allow it to form a rectangle.
2. Simple Calculator
a) Problem:
Use Key Matrix and 7-segments LEDs to implement a simple calculator that
support +, -, *, /, % with
integer operands.
- Press a for addition
- Press b for subtraction
- Press c for multiplication
- Press d for division
- Press e for division with remainder
- Press f to get the result
Detail requirements:
- When pressing digital key, show the last two digits on LEDs. For example,
press 1 → show 01,
press 2 → show 12, press 3 → show 23.
- After entering an operand, press + - * / % to select the operation.
- After pressing f (=) , calculate and show two digits at the right of the result
on LEDs.
- Can calculate continuously (use Calculator on Windows for reference)
b) How to use:
• Compile the program
• Open digital lab sim tool and run the program
• Click the numbers on the keyboard and the corresponding number will
appear on the seven segment display
• Choose the number again, if the user doesn’t click a number key, then
the number will be default to zero
Click f to compute the expression, the last 2 digit of the result will be
display on the seven segment display. The whole equation is printed out in
the console.
• Scan the keyboard and get the code of the pressed keyboard
• Convert the keyboard code to a real number and display on seven
segment code
• Check whether it is a number or an operator
o If it is a number:
▪ Push the number to a stack
▪ Display it on the seven segments display
▪ Exit the handler
o If it is an operator:
▪ Check if the operator is “=” sign, if not, push to operator to
the memory, change $s0 to 1, now the next number will be
second operand and then end the exception
▪ If the operator is “=”, continue
• After pressing the equal sign, the program will display the answer to
the seven segments display.
d) Demonstration
▪ Addition
▪ Subtraction
▪ Multiplication
▪ Division
▪ Modulus
3. Source code
SIMPLE CALCULATOR
.data
.text
main:
li $s6,0 # result
#---------------------------------------------------------
li $t1, IN_ADDRESS_HEXA_KEYBOARD
li $t2, OUT_ADDRESS_HEXA_KEYBOARD
sb $t3, 0($t1)
storefirstvalue:
sb $t7,0($sp)
loop1:
nop
nop
nop
nop
b loop1
endloop1:
end_main:
li $v0,10
syscall
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ktext 0x80000180
process:
nop
jal checkrow2
bnez $t3,convertrow2
nop
jal checkrow3
bnez $t3,convertrow3
nop
jal checkrow4
bnez $t3,convertrow4
checkrow1:
addi $sp,$sp,4
sw $ra,0($sp)
sb $t3,0($t1)
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
checkrow2:
addi $sp,$sp,4
sw $ra,0($sp)
sb $t3,0($t1)
jal getvalue
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
checkrow3:
addi $sp,$sp,4
sw $ra,0($sp)
li $t3,0x84 # enable interrupt for row 3
sb $t3,0($t1)
jal getvalue
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
checkrow4:
addi $sp,$sp,4
sw $ra,0($sp)
sb $t3,0($t1)
jal getvalue
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
getvalue:
addi $sp,$sp,4
sw $ra,0($sp)
lb $t3,0($t2) #load
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
beq $t3,0x21,case_one
beq $t3,0x41,case_two
beq $t3,0xffffff81,case_three
case_zero:
lb $t4,zero #convert
li $t7,0 #t7= t4
j done
case_one:
lb $t4,one
li $t7,1
j done
case_two:
lb $t4,two
li $t7,2
j done
case_three:
lb $t4,three
li $t7,3
j done
convertrow2:
beq $t3,0x12,case_four
beq $t3,0x22,case_five
beq $t3,0x42,case_six
beq $t3,0xffffff82,case_seven
case_four:
lb $t4,four
li $t7,4
j done
case_five:
lb $t4,five
li $t7,5
j done
case_six:
lb $t4,six
li $t7,6
j done
case_seven:
lb $t4,seven
li $t7,7
j done
convertrow3:
beq $t3,0x14,case_eight
beq $t3,0x24,case_nine
case_eight:
lb $t4,eight
li $t7,8
j done
case_nine:
lb $t4,nine
li $t7,9
j done
case_a: #addition
addi $a3,$zero,1
bne $s3,0,setnextoperator
case_b: #subtraction
addi $a3,$zero,2
addi $s0,$s0,1
bne $s3,0,setnextoperator
addi $s3,$zero,2
j setfirstnumber
convertrow4:
beq $t3,0x18,case_c
beq $t3,0x28,case_d
beq $t3,0x48,case_e
case_c: #multiplication
addi $a3,$zero,3
addi $s0,$s0,1
bne $s3,0,setnextoperator
addi $s3,$zero,3
j setfirstnumber
case_d: #division
addi $a3,$zero,4
addi $s0,$s0,1
bne $s3,0,setnextoperator
addi $s3,$zero,4
j setfirstnumber
case_e: #modular
j setfirstnumber
add $s4,$s4,$s1
j done
case_f: #press =
setsecondnumber: #calculate second number that displaying
add $s5,$s5,$s1
beq $s3,2,subtraction
beq $s3,3,multiplication
beq $s3,4,division
addition:
add $s6,$s5,$s4
li $s3,0
j printadd
nop # s6=s5+s4
printadd:
li $v0, 1
syscall
li $v0, 11
li $a0, '+'
syscall
li $v0, 1
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
li $s7,100
div $s6,$s7
nop
subtraction:
li $s3,0
blt $s6,0,subneg
j printsub
nop
printsub:
li $v0, 1
syscall
li $v0, 11
li $a0, '-'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
j splitnumber
nop
multiplication:
li $s3,0
j printmul
nop
printmul:
li $v0, 1
syscall
li $v0, 11
li $a0, '*'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
li $v0, 11
li $a0, '\n'
syscall
li $s7,100
div $s6,$s7
mfhi $s6 # chi lay 2 chu so sau cùng cua ket qua in ra
nop
division:
beq $s5,0,div0
li $s3,0
mflo $s6
mfhi $s7
j printdiv
nop
printdiv:
li $v0, 1
syscall
li $v0, 11
li $a0, '/'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
syscall
li $v0, 11
li $a0, 'r'
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
j splitnumber
nop
modular:
beq $s5,0,div0
li $s3,0
mfhi $s6
j printmod
nop
printmod:
li $v0, 1
syscall
li $v0, 11
li $a0, '%'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
syscall
li $v0, 11
li $a0, '\n'
syscall
j splitnumber
nop
div0:
li $v0, 55
la $a0, mess2
li $a1, 0
syscall
j resetled
subneg:
li $v0, 55
la $a0, mess1
li $a1, 0
syscall
j resetled
li $t8,10
#---------
add $sp,$sp,4
add $sp,$sp,4
#----------
mfhi $t7 #t7= remainder
jal convert
add $sp,$sp,4
add $sp,$sp,4
j resetled
convert:
addi $sp,$sp,4
sw $ra,0($sp)
beq $t7,0,case_0
beq $t7,1,case_1
beq $t7,2,case_2
beq $t7,3,case_3
beq $t7,4,case_4
beq $t7,5,case_5
beq $t7,6,case_6
beq $t7,7,case_7
beq $t7,8,case_8
beq $t7,9,case_9
case_0:
lb $t4,zero #t4=zero
j finishconvert
case_1:
lb $t4,one
j finishconvert
case_2:
lb $t4,two
j finishconvert
case_3:
lb $t4,three
j finishconvert
case_4:
lb $t4,four
j finishconvert
case_5:
lb $t4,five
j finishconvert
case_6:
lb $t4,six
j finishconvert
case_7:
lb $t4,seven
j finishconvert
case_8:
lb $t4,eight
j finishconvert
case_9:
lb $t4,nine
j finishconvert
finishconvert:
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
done:
add $sp,$sp,-4
lb $t8,0($sp)
add $sp,$sp,-4
sb $t6,0($t0) # display
loadtorightled:
sb $t4,0($t5)
add $sp,$sp,4
sb $t7,0($sp)
add $sp,$sp,4
sb $t4,0($sp)
j finish
resetled:
addi $sp,$sp,4
sb $t8,0($sp)
addi $sp,$sp,4
sb $t6,0($sp)
finish:
j end_exception
nop
end_exception:
la $a3, loop1
eret
setnextoperator:
add $s5,$s5,$s1
beq $s3,2,sub1
beq $s3,3,mul1
beq $s3,4,div1
beq $s3,5,mod1
add1:
add $s6,$s5,$s4
j printadd1
nop # s6=s5+s4
printadd1:
li $v0, 1
syscall
li $v0, 11
li $a0, '+'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
li $s7,100
div $s6,$s7
mfhi $s6 # chi lay 2 chu so cuoi cua ket qua de in ra led
nop
sub1:
blt $s6,0,subneg1
j printsub1
nop
printsub1:
li $v0, 1
syscall
li $v0, 11
li $a0, '-'
syscall
li $v0, 1
move $a0, $s5
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
nop
mul1:
j printmul1
nop
printmul1:
li $v0, 1
syscall
li $v0, 11
li $a0, '*'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
li $s7,100
div $s6,$s7
mfhi $s6 # chi lay 2 chu so sau cùng cua ket qua in ra
div1:
beq $s5,0,div01
mflo $s6
mfhi $s7
j printdiv1
nop
printdiv1:
li $v0, 1
syscall
li $v0, 11
li $a0, '/'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
syscall
li $v0, 11
li $a0, 'r'
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '\n'
syscall
mod1:
beq $s5,0,div01
mfhi $s6
j printmod1
nop
printmod1:
li $v0, 1
syscall
li $v0, 11
li $a0, '%'
syscall
li $v0, 1
syscall
li $v0, 11
li $a0, '='
syscall
li $v0, 1
move $a0, $s6
syscall
div01:
li $v0, 55
la $a0, mess2
li $a1, 0
syscall
j resetled1
subneg1:
li $v0, 55
la $a0, mess1
li $a1, 0
syscall
j resetled1
li $t8,10
jal convert1
#---------
add $sp,$sp,4
add $sp,$sp,4
add $s2,$t7,$zero
#----------
mfhi $t7
jal convert1
add $sp,$sp,4
sb $t7,0($sp)
add $sp,$sp,4
sb $t4,0($sp)
add $s1,$t7,$zero
convert1:
addi $sp,$sp,4
sw $ra,0($sp)
beq $t7,1,case_11
beq $t7,2,case_21
beq $t7,3,case_31
beq $t7,4,case_41
beq $t7,5,case_51
beq $t7,6,case_61
beq $t7,7,case_71
beq $t7,8,case_81
beq $t7,9,case_91
case_01: #ham chuyen 0 thanh bit zero hien thi len led
lb $t4,zero #t4=zero
case_11:
lb $t4,one
j finishconvert1
case_21:
lb $t4,two
j finishconvert1
case_31:
lb $t4,three
j finishconvert1
case_41:
lb $t4,four
j finishconvert1
case_51:
lb $t4,five
j finishconvert1
case_61:
lb $t4,six
j finishconvert1
case_71:
lb $t4,seven
j finishconvert1
case_81:
lb $t4,eight
j finishconvert1
case_91:
lb $t4,nine
j finishconvert1
finishconvert1:
lw $ra,0($sp)
addi $sp,$sp,-4
jr $ra
done1:
beq $s0,1,resetled1
resetled1:
li $s0,0
li $t8,0
addi $sp,$sp,4
sb $t8,0($sp)
lb $t6,zero
addi $sp,$sp,4
sb $t6,0($sp)
add $s4,$s4,$s1
beq $a3,1,setadd
nop
beq $a3,2,setsub
nop
beq $a3,3,setmul
nop
beq $a3,4,setdiv
nop
nop
j finish1
nop
j finish1
nop
j finish1
nop
j finish1
nop
j finish1
nop
finish1:
j end_exception1
nop
end_exception1:
la $a3, loop1
eret
Curiosity Marsbot
# eqv for Digital Lab Sim
# 0 : North (up)
#---------------------------------------------------------------------
----------
.data
# CODE
# HISTORY
y_history: .word 0 : 16
# For rotation
a_history: .word 0 : 16
is_tracking: .word 0
# Code properties
.text
main:
li $k0, KEY_CODE
li $k1, KEY_READY
sb $t3, 0($t1)
init:
sw $t7, l_history
li $t7, 90
jal ROTATE
nop
j waitForKey
printError:
li $v0, 4
la $a0, error_msg
syscall
printCode:
li $v0, 4
la $a0, control_code
syscall
j resetInput
repeatCode:
jal strCpy1
j checkCode
resetInput:
jal strClear
nop
# Take input
waitForKey:
nop
readKey:
# go to checkCode label
nop
checkCode:
la $s3, MOVE_CODE
jal strcmp
beq $t0, 1, go
la $s3, STOP_CODE
jal strcmp
la $s3, TURN_LEFT_CODE
jal strcmp
la $s3, TURN_RIGHT_CODE
jal strcmp
jal strcmp
la $s3, UNTRACK_CODE
jal strcmp
la $s3, GOBACKWARD_CODE
jal strcmp
nop
j printError
go:
jal strCpy2
jal GO
j printCode
stop:
jal strCpy2
jal STOP
j printCode
track:
jal strCpy2
jal TRACK
j printCode
untrack:
jal strCpy2
jal UNTRACK
j printCode
turnRight:
jal strCpy2
lw $t7, is_going
lw $s0, is_tracking
jal STOP
nop
jal UNTRACK
nop
la $s5, a_current
jal saveHistory
jal ROTATE
nop
jal TRACK
noTrack1: nop
nop
jal GO
noGo1:
nop
j printCode
turnLeft:
jal strCpy2
lw $t7, is_going
lw $s0, is_tracking
jal STOP
nop
jal UNTRACK
nop
la $s5, a_current
jal saveHistory
jal ROTATE
nop
jal TRACK
noTrack2: nop
nop
jal GO
noGo2:
nop
j printCode
goBackward:
jal strCpy2
sb $zero, 0($t7)
jal UNTRACK
jal GO
goBackward_turn:
sw $s6, a_current
jal ROTATE
nop
goBackward_toTurningPoint:
get_x:
lw $t8, 0($t8)
bne $t8, $t9, get_x # x_current == x_history[i]
nop
get_Y:
lw $t8, 0($t8)
nop
goBackward_end:
jal STOP
jal ROTATE
#-----------------------------------------------------------
# saveHistory()
#-----------------------------------------------------------
saveHistory:
sw $t1, 0($sp)
sw $t2, 0($sp)
sw $t3, 0($sp)
sw $t4, 0($sp)
sw $s1, 0($sp)
sw $s2, 0($sp)
sw $s3, 0($sp)
sw $s4, 0($sp)
lw $s1, WHEREX # s1 = x
lw $s2, WHEREY # s2 = y
sw $s2, y_history($t3)
sw $s4, a_history($t3)
sw $t3, l_history
lw $s3, 0($sp)
lw $s2, 0($sp)
lw $s1, 0($sp)
lw $t4, 0($sp)
lw $t3, 0($sp)
lw $t2, 0($sp)
addi $sp, $sp, -4
lw $t1, 0($sp)
saveHistory_end:
jr $ra
#=====================================================================
==========
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GO()
#-----------------------------------------------------------
GO:
sw $at, 0($sp)
sw $k0, 0($sp)
li $t7, 1 # is_going = 0
sw $t7, is_going
lw $k0, 0($sp) # restore back up
lw $at, 0($sp)
GO_end:
jr $ra
#-----------------------------------------------------------
# STOP()
#-----------------------------------------------------------
STOP:
sw $at, 0($sp)
STOP_end:
jr $ra
#-----------------------------------------------------------
# TRACK()
#-----------------------------------------------------------
TRACK:
sw $at, 0($sp)
sw $k0, 0($sp)
sw $s0, is_tracking
lw $at, 0($sp)
TRACK_end:
jr $ra
#-----------------------------------------------------------
# UNTRACK()
#-----------------------------------------------------------
UNTRACK:
sw $at, 0($sp)
sw $zero, is_tracking
UNTRACK_end:
jr $ra
#-----------------------------------------------------------
# ROTATE()
#-----------------------------------------------------------
ROTATE:
sw $t1, 0($sp)
addi $sp, $sp, 4
sw $t2, 0($sp)
sw $t3, 0($sp)
la $t2, a_current
lw $t2, 0($sp)
lw $t1, 0($sp)
ROTATE_end:
jr $ra
#=====================================================================
==========
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# strcmp()
# - input: $s3 = string to compare with control_code
#-----------------------------------------------------------
strcmp:
sw $t1, 0($sp)
sw $s1, 0($sp)
addi $sp,$sp,4
sw $t2, 0($sp)
sw $t3, 0($sp)
strcmp_loop:
nop
nop
j strcmp_end
strcmp_next:
j strcmp_loop
strcmp_equal:
strcmp_end:
lw $t2, 0($sp)
lw $s1, 0($sp)
lw $t1, 0($sp)
jr $ra
#-----------------------------------------------------------
# strClear()
#-----------------------------------------------------------
strClear:
sw $t1, 0($sp)
sw $t2, 0($sp)
sw $s1, 0($sp)
sw $t3, 0($sp)
sw $s2, 0($sp)
strClear_loop:
nop
lw $t3, 0($sp)
lw $s1, 0($sp)
lw $t2, 0($sp)
lw $t1, 0($sp)
jr $ra
#-----------------------------------------------------------
#-----------------------------------------------------------
strCpy1:
sw $t1, 0($sp)
sw $t2, 0($sp)
sw $s1, 0($sp)
addi $sp, $sp, 4
sw $t3, 0($sp)
sw $s2, 0($sp)
li $t2, 0
la $s1, control_code
la $s2, prev_control_code
strCpy1_loop:
# $t1 as control_code[i]
lb $t1, 0($s2)
sb $t1, 0($s1)
j strCpy1_loop
strCpy1_end:
li $t3, 3
sw $t3, code_length
lw $t3, 0($sp)
lw $s1, 0($sp)
lw $t2, 0($sp)
lw $t1, 0($sp)
jr $ra
#-----------------------------------------------------------
#-----------------------------------------------------------
strCpy2:
sw $t1, 0($sp)
addi $sp, $sp, 4
sw $t2, 0($sp)
sw $s1, 0($sp)
sw $t3, 0($sp)
sw $s2, 0($sp)
li $t2, 0
la $s1, prev_control_code
la $s2, control_code
strCpy2_loop:
# $t1 as control_code[i]
lb $t1, 0($s2)
sb $t1, 0($s1)
j strCpy2_loop
strCpy2_end:
lw $t3, 0($sp)
lw $s1, 0($sp)
lw $t2, 0($sp)
lw $t1, 0($sp)
jr $ra
#=====================================================================
==========
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ktext 0x80000180
#-------------------------------------------------------
backup:
sw $ra, 0($sp)
sw $t1, 0($sp)
sw $t2, 0($sp)
sw $t3, 0($sp)
sw $a0, 0($sp)
sw $at, 0($sp)
sw $s0, 0($sp)
sw $s1, 0($sp)
sw $s2, 0($sp)
addi $sp, $sp, 4
sw $t4, 0($sp)
sw $s3, 0($sp)
#--------------------------------------------------------
# Processing
#--------------------------------------------------------
getCode:
li $t1, IN_ADRESS_HEXA_KEYBOARD
li $t2, OUT_ADRESS_HEXA_KEYBOARD
# scan row 1
li $t3, 0x81
sb $t3, 0($t1)
# scan row 2
li $t3, 0x82
sb $t3, 0($t1)
# scan row 3
li $t3, 0x84
sb $t3, 0($t1)
# scan row 4
li $t3, 0x88
sb $t3, 0($t1)
getCodeInChar:
case_0:
j storeCode
case_1:
li $s0, '1'
j storeCode
case_2:
li $s0, '2'
j storeCode
case_3:
li $s0, '3'
j storeCode
case_4:
li $s0, '4'
j storeCode
case_5:
li $s0, '5'
j storeCode
case_6:
li $s0, '6'
j storeCode
case_7:
li $s0, '7'
j storeCode
case_8:
li $s0, '8'
j storeCode
case_9:
li $s0, '9'
j storeCode
case_a:
li $s0, 'a'
j storeCode
case_b:
li $s0, 'b'
j storeCode
case_c:
li $s0, 'c'
j storeCode
case_d:
li $s0, 'd'
j storeCode
case_e:
li $s0, 'e'
j storeCode
case_f:
li $s0, 'f'
j storeCode
storeCode:
la $s1, control_code
la $s2, code_length
storeCodeLoop:
sb $s0, 0($s1)
#--------------------------------------------------------
#--------------------------------------------------------
next_pc:
#--------------------------------------------------------
#--------------------------------------------------------
restore:
lw $s3, 0($sp)
lw $t4, 0($sp)
lw $s2, 0($sp)
lw $s1, 0($sp)
lw $s0, 0($sp)
lw $at, 0($sp)
lw $a0, 0($sp)
lw $t3, 0($sp)
lw $t2, 0($sp)
addi $sp, $sp, -4
lw $t1, 0($sp)
lw $ra, 0($sp)