Homework 4
|
Modified: |
A high-level algorithm in pseudocode (that strongly resembles Java or C++) is given below.The algorithm performs a bubble-sort on an array and displays the sorted array.
int A[] = { 400, 200, 100, 700, 500, 800, 600, 300 }; int B[] = { 5555, 3333, 8888, 7777, 1111, 6666, 2222, 4444 };void bubbleSort( int X[] ) { for(int pass=1; pass < 8; pass++) for(int j=0; j < 8-pass; j++) if(X[ j ] > X[ j+1 ]) { int temp=X[ j ]; X[ j ]=X[ j+1 ]; X[ j+1 ]=temp; } }void print(int X[]) { for(int i=0; i<8; i++) { printDec( X[i] ); println(); } } void main() { bubbleSort( A ); print(A); bubbleSort( B ); print(B); }
Implement the high-level algorithm as an Assembler language solution.
Give program listing of solution.
Test output using both A and B array values given in the pseudocode.
To capture the output window:
For documentation and as helpful reminder of algorithm when debugging assembly code, include pseudo code comments to the right of assembly instructions.