Below is a MIPS procedure with a mistake in spilling and restoring registers. Following the code is the multiple-choice question.
.data
array: .word 10, 20, 30, 40, 50
.text
main:
addi $sp, $sp, -12 # create space on the stack for three words
sw $s0, 0($sp) # spill $s0
sw $s1, 4($sp) # spill $s1
jal proc # call the procedure
lw $s0, 0($sp) # restore $s0
lw $s1, 4($sp) # restore $s1
addi $sp, $sp, 12 # restore the stack pointer
li $v0, 10 # exit program
syscall
proc:
li $s0, 0 # using $s0
la $s1, array # load base address of array into $s1
lw $t0, 0($s1) # load first element of array into $t0
add $s0, $s0, $t0 # add first element to sum
jr $ra # return from procedure
In the MIPS code snippet above, where is the mistake made in spilling and restoring registers?
Below is a MIPS procedure with a mistake in spilling and restoring registers. Following the code is the multiple-choice question.
.data
array: .word 10, 20, 30, 40, 50
.text
main:
addi $sp, $sp, -12 # create space on the stack for three words
sw $s0, 0($sp) # spill $s0
sw $s1, 4($sp) # spill $s1
jal proc # call the procedure
lw $s0, 0($sp) # restore $s0
lw $s1, 4($sp) # restore $s1
addi $sp, $sp, 12 # restore the stack pointer
li $v0, 10 # exit program
syscall
proc:
li $s0, 0 # using $s0
la $s1, array # load base address of array into $s1
lw $t0, 0($s1) # load first element of array into $t0
add $s0, $s0, $t0 # add first element to sum
jr $ra # return from procedure
In the MIPS code snippet above, where is the mistake made in spilling and restoring registers?
* השאלה נוספה בתאריך: 23-03-2024