Question: Write a program in ARM assembly language (which can be executed on ARMSim simulator) to sort a series of integer numbers. Series of integer numbers

Write a program in ARM assembly language (which can be executed on ARMSim simulator) to sort a series of integer numbers. Series of integer numbers are stored in a file named input.txt. Input file contains 0 or more integer numbers. Your program should open the file for reading, read each of the numbers and store them in memory, sort the numbers in ascending order, and store the result in the file named output.txt.

There are many different ways of performing this sorting operation. One of the simplest is to search the sequence for the smallest number and swap it with the first number. Now the first number is the smallest number and it is in correct position. Now apply the same process to the rest of the numbers.

Java code for sorting:

//Outer loop will iterate once through the table. for (int i = 0; i < size; i++) { 
 //Assume next smallest number is at i int min = i; 
 //Inner loop is used to find next smallest number for (int j = i+1; j < size; j++) { 
 if (table [j] < table[min]) { 

min = j; }

}

 //Swap the ith entry with the next smallest value int temp = table[min]; table[min] = table[i]; table[i] = temp; 

}

Example: Before execution of program: Input: 5, 4, 2, 6, 7, 8 Output: 2, 4, 5, 6, 7, 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!