Question: There are two tests the auto - grader runs when it grades my code. My code passes the first test but fails the second. Here

There are two tests the auto-grader runs when it grades my code. My code passes the first test but fails the second. Here is what I it prints after my code fails the second test: This test will replace your main function with the following:
main:
.data
string_to_change: .asciiz "hi"
bad_s: .asciiz "Your function overwrote an $s register without restoring it!
"
.text
addiu $sp, $sp,-52
sw $ra,48($sp)
sw $s7,44($sp)
sw $s6,40($sp)
sw $s5,36($sp)
sw $s4,32($sp)
sw $s3,28($sp)
sw $s2,24($sp)
sw $s1,20($sp)
sw $s0,16($sp)
li $s0,0xf0f7
li $s1,0x140a
li $s2,0xa481
li $s3,0xff75
li $s4,0x7ca4
li $s5,0x67ab
li $s6,0xa03b
li $s7,0x510a
la $a0, string_to_change
jal replace_start_with_z
bne $s0,0xf0f7, Lmain_bad_s
bne $s1,0x140a, Lmain_bad_s
bne $s2,0xa481, Lmain_bad_s
bne $s3,0xff75, Lmain_bad_s
bne $s4,0x7ca4, Lmain_bad_s
bne $s5,0x67ab, Lmain_bad_s
bne $s6,0xa03b, Lmain_bad_s
bne $s7,0x510a, Lmain_bad_s
la $a0, string_to_change
li $v0,4
syscall
b Lmain_end
Lmain_bad_s:
la $a0, bad_s
li $v0,4
syscall
Lmain_end:
lw $ra,48($sp)
lw $s7,44($sp)
lw $s6,40($sp)
lw $s5,36($sp)
lw $s4,32($sp)
lw $s3,28($sp)
lw $s2,24($sp)
lw $s1,20($sp)
lw $s0,16($sp)
addiu $sp, $sp,52
jr $ra
This test expects your output to contain at least the following:
Zi
This test expects your output to NOT contain the following:
Exception 0
Exception 4
Exception 5
Exception 6
Exception 7
Exception 8
Exception 9
Exception 10
Exception 12
Your function overwrote an $s register without restoring it!
Running test...
*** FAIL ***
--- your output ---
hi
--- output must contain ---
Zi
Here is my code:
.data
my_string: .asciiz "hello"
.text
.globl main
main:
subi $sp, $sp,64
sw $ra,60($sp)
sw $a0,56($sp)
sw $a1,52($sp)
la $a0, my_string
jal replace_start_with_z
la $a1, my_string
jal PrintString
li $v0,0
lw $ra,60($sp)
lw $a0,56($sp)
lw $a1,52($sp)
addi $sp, $sp,64
jr $ra
end_function:
li $v0,10
syscall
jr $ra
replace_start_with_z:
subi $sp, $sp,28
sw $ra,24($sp)
sw $a0,20($sp)
la $a2, my_string
jal strlen
blez $v0, end_function
li $t1,'Z'
sb, $t1,0($a2)
lw $ra,24($sp)
lw $a0,20($sp)
addi $sp, $sp,28
jr $ra
.include "./util.s"
There are two tests the auto - grader runs when

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!