

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Cosc 2150 Assignment 7 Due: March 23, 2009 Write the assembly language code in ARC (simplified SPARC code). Test it with the simulator and hand in a hard copy of the code and compiled code found in the .lst file. You must use comments or lose half the points.
In the main program, you CAN NOT load the entire array into the registers. You can only work with two elements of the array at a time. You can shorten the swap subroutine, by skipping the temporary (called temp) variable (since registers act as temporary variables anyway), if you want to. You must comment your code. Lastly, the swap subroutine must store the value of register 15 into a variable and reload it, as shown in class and store the array elements back into memory in the subroutine. main () { int a[10] = {10,8,6,4,2,9,7,5,3,1}; int I,j; for (I=0; I<10; ++I) { for (j=0; j<9; ++j) { if (a[ j ] > a[ j+1 ]) { swap (); } } } } swap () { int temp; temp = a[ j ]; a[ j ] = a[ j+1]; a[ j+1] = temp; }
sub2; } } } sub1 () { j = I *2; if ( j >3 ) { sub3; } else { j = 0; sub3; } } sub2 () { j = I/2; if (j <= 2) { j = 0; sub3; } else { sub3; } } sub3 () { a[I] = I +j; } Turn in: A printed report, which includes the following