Use MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function.
The main function should:
• Pass the starting address of the array in $a0.
• Pass the indices of the two elements to swap in $a1 and $a2.
• Preserve (i.e. push onto the stack) any T registers that it uses.
• Call the Swap function.
The Swap function should:
• Swap the specified elements in the array.
• Preserve any S registers it uses.
• It does not return a value to main.
.text
.globl main
main: la $t0, intA # load the starting address of the integer array into $t0
# Specify your name and the date in the comments above.
# Insert the code for the main function here.
nop # put breakpoint at this line to end program without warning/error.
swap:
# insert the code for the Swap function here.
.data 0x10010000
intA: .word # Specify an array of integers here.
Get Answers For Free
Most questions answered within 1 hours.