Question
Mips code need questions for helps! mystery.s .text main: li $a0, 0 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, 1
Mips code need questions for helps!
mystery.s
.text
main: li $a0, 0 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, 1 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, 196 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, -1 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, -452 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, 2 jal mystery move $a0, $v0 jal putDec li $a0, ' ' li $v0, 11 syscall
li $a0, 3 jal mystery move $a0, $v0 jal putDec li $a0, ' ' li $v0, 11 syscall
li $v0, 10 # terminate program syscall
putDec: ## FILL IN ## jr $ra # returnv
mystery: bne $0, $a0, recur # li $v0, 0 # jr $ra # recur: sub $sp, $sp, 8 # sw $ra, 4($sp) # sub $a0, $a0, 1 # jal mystery # sw $v0, 0($sp) # jal mystery # lw $t0, 0($sp) # addu $v0, $v0, $t0 # addu $v0, $v0, 1 # add $a0, $a0, 1 # lw $ra, 4($sp) # add $sp, $sp, 8 # jr $ra #
purDec: li $v0,1 syscall li $a1, '_' li $v1 11 #character print syscall li $a1,'1' li $v1, 11 #character print syscall 1 prints the string li $v1, 4 la $a1, str syscall str: .asciiz "-1" -1 prints the integer li $v1, 1 #prints the integer la $a1, -1 syscall
(Exercise) Mystery Figure out what number is being returned by mystery function by examining $v0 or printing it out using putDec as in this lab. Q3. What is the C equivalent code? Q4 What is printed as the result of mystery(7)? 5. What is printed as the result of mystery(32)? Now that you figured out the actual function of mystery, rewrite it so it obeys all the proper register conventions (Exercise) Mystery Figure out what number is being returned by mystery function by examining $v0 or printing it out using putDec as in this lab. Q3. What is the C equivalent code? Q4 What is printed as the result of mystery(7)? 5. What is printed as the result of mystery(32)? Now that you figured out the actual function of mystery, rewrite it so it obeys all the proper register conventions
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started