Assignment 7 in Cosc 2150: Writing ARC Assembly Language Code for Array Sorting - Prof. Ja, Assignments of Computer Architecture and Organization

Instructions for assignment 7 in cosc 2150, where students are required to write arc assembly language code for sorting an array using the swap subroutine. The document also specifies the rules for using registers and comments, and provides an example of how to implement the swap subroutine. Students must turn in a printed report, a hard copy of the code, and the compiled code.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-8nr
koofers-user-8nr 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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.
1.
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;
}
2. Write the code as is, DO NOT remove the subroutines. Don’t forget to store %r15 and
reload %r15 in each subroutine.
main () {
int a[10], I, j;
for (I=0; I<10; I++) {
if (I==0) {
j =I;
sub3;
} else if (I <=5){
sub1;
} else {
pf2

Partial preview of the text

Download Assignment 7 in Cosc 2150: Writing ARC Assembly Language Code for Array Sorting - Prof. Ja and more Assignments Computer Architecture and Organization in PDF only on Docsity!

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; }

  1. Write the code as is, DO NOT remove the subroutines. Don’t forget to store %r15 and reload %r15 in each subroutine. main () { int a[10], I, j; for (I=0; I<10; I++) { if (I==0) { j =I; sub3; } else if (I <=5){ sub1; } else {

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

  1. title page: Cosc 2150 Homework # your Name in large font at the top of the page. At the bottom of the page, include a non-empty statement of help delivered and help received. It is OK to state that no help was given or received. It is NOT ok to omit the statement of help. 1.Turn in a printed copy of the code and compiled code found in the .lst file for both questions.
  2. put a copy of the code in your course directory \lamont.cs.uwyo.edu\courses\cosc21 50 \students<lastname>\homework7\