Question

Use MIPS assembly language program to swap two of the integers in an integer array. The...

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.

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a simple ARM assembly language program that finds the mean (as an integer) of all...
Write a simple ARM assembly language program that finds the mean (as an integer) of all values of an integer array. When your program starts, you should assume that r0 contains the address of the array and r1 contains the number of integers in the array. When you program finishes, the mean should be stored in r2. You may use other registers as stack registers.
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure...
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure receives the mulitiplicand and the multiplier and returns the product. IT CANNOT USE A MULTIPLY INSTRUCTION! Write a MIPS assembly language program that demonstrates your multiplication procedure. Your program should ask the user for two integers to multiply. You can assume that the input integers are positive. Adhere to the procedure call convention.
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
Write a program in c++ to Convert an array of inches to an array of centimeters....
Write a program in c++ to Convert an array of inches to an array of centimeters. The program should contain a function called inchesTOcm with three parameters (inches array that contains the values in inches, cm array to save the result in, and an integer variable that defines the length of the array). In the main function: 1. Define an array (inches) of length 3. 2. Initialize the array by asking the user to input the values of its elements....
In this program, you should define an array of 10 elements in your data segment with...
In this program, you should define an array of 10 elements in your data segment with these values: ? = {11, 12,−10, 13, 9, 12, 14, 15,−20, 0} a. Write a function which finds the maximum value of this array. b. Write another function which calculates the summation of this array. c. Call these functions in your main program, and print the outputs of these functions to the user i. “The maximum is 15” ii. “The summation is 56” d....
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
Java : Modify the selection sort algorithm to sort an array of integers in descending order....
Java : Modify the selection sort algorithm to sort an array of integers in descending order. describe how the skills you have gained could be applied in the field. Please don't use an already answered solution from chegg. I've unfortunately had that happen at many occasion ....... ........ sec01/SelectionSortDemo.java import java.util.Arrays; /** This program demonstrates the selection sort algorithm by sorting an array that is filled with random numbers. */ public class SelectionSortDemo { public static void main(String[] args) {...
Lottery The lottery game matches three different integer numbers between 1 and 10. Winning depends on...
Lottery The lottery game matches three different integer numbers between 1 and 10. Winning depends on how many matching numbers are provided by a player. The player provides three different integers between 1 and 10. If there is a match of all 3 numbers, the winning $ 1000. If there is a match with 2 numbers, the winning $ 10. If there is a match with 1 number, the winning $ 1. With no match, the winning is $0. Write...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int fib(int n) { int temp; if (n <= 0)    return 0; else if (n <= 2)    return 1; else {    temp = fib(n – 1);    return temp + fib(n-2); } } int main() {    int num;    cout << "Which fibonacci number? ";    cin >> num;    cout << fib(num) << endl;    return 0; } You must...