Question: Mips programming below is the mystery code: .text main: li $a0, 0 jal putDec li $a0, ' ' li $v0, 11 syscall li $a0, 1
Mips programming


below is the mystery code:
.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 #
(Exercise) Fill-in PutDec Using mystery.s given in the assignment page, work on putDec function which will take the argument given in $a0 and interprets it as a 2's complement number. Your task is to go figure out character by character of what is the appropriate character to print out. We will be using syscall to accomplish this task For example, if we want to print out character zero we would use: li Sa 0, '0' li 0, 11 syscall $v0 is telling the OS what function to do whereas $ao is supplying the actual character to print out. If we want to print out that is contained in $to then the code would look like li Sa 0, '0' add $a0 0, Sto added 0-9 in Sto to make char li svo, 11 syscall
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
