Question
I need the MIPS code filled out #Precondtions: # 1st parameter (a0) address of head node # Postconditions: # Every other node is removed from
I need the MIPS code filled out
#Precondtions: # 1st parameter (a0) address of head node # Postconditions: # Every other node is removed from the list and deleted.
select: addi $sp, $sp, -8 # make space on stack sw $s0, 0($sp) # preserve registers used by this function sw $ra, 4($sp) # preserve return address
move $s0, $a0 # s0 = p = list
while: # while (p != NULL) # t0 = p->next # if (p->next != NULL) # t1 = p->next->next # p->next = p->next->next
# 1st parameter = p->next # 2nd parameter = size of node # delete node
endif: # p = p->next # jump to beginning of loop
return: lw $s0, 0($sp) # restore registers used by this function lw $ra, 4($sp) # restore return address addi $sp, $sp, 8 # restore stack pointer jr $ra # return
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