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 autograder 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
stringtochange: asciiz hi
bads: asciiz "Your function overwrote an $s register without restoring it
text
addiu $sp $sp
sw $ra$sp
sw $s$sp
sw $s$sp
sw $s$sp
sw $s$sp
sw $s$sp
sw $s$sp
sw $s$sp
sw $s$sp
li $sxff
li $sxa
li $sxa
li $sxff
li $sxca
li $sxab
li $sxab
li $sxa
la $a stringtochange
jal replacestartwithz
bne $sxff Lmainbads
bne $sxa Lmainbads
bne $sxa Lmainbads
bne $sxff Lmainbads
bne $sxca Lmainbads
bne $sxab Lmainbads
bne $sxab Lmainbads
bne $sxa Lmainbads
la $a stringtochange
li $v
syscall
b Lmainend
Lmainbads:
la $a bads
li $v
syscall
Lmainend:
lw $ra$sp
lw $s$sp
lw $s$sp
lw $s$sp
lw $s$sp
lw $s$sp
lw $s$sp
lw $s$sp
lw $s$sp
addiu $sp $sp
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
Exception
Exception
Exception
Exception
Exception
Exception
Exception
Exception
Your function overwrote an $s register without restoring it
Running test...
FAIL
your output
hi
output must contain
Zi
Here is my code:
data
mystring: asciiz "hello"
text
globl main
main:
subi $sp $sp
sw $ra$sp
sw $a$sp
sw $a$sp
la $a mystring
jal replacestartwithz
la $a mystring
jal PrintString
li $v
lw $ra$sp
lw $a$sp
lw $a$sp
addi $sp $sp
jr $ra
endfunction:
li $v
syscall
jr $ra
replacestartwithz:
subi $sp $sp
sw $ra$sp
sw $a$sp
la $a mystring
jal strlen
blez $v endfunction
li $tZ
sb $t$a
lw $ra$sp
lw $a$sp
addi $sp $sp
jr $ra
include utils
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
