$24.99
Important: This is an individual assignment. Please do not collaborate.
Make sure to follow the academic integrity policies.
It must be submitted on-line (course website).
Go to "GradeScope" tab on Canvas -> CSE/EEE230 -> Assignment6, and upload your program file.
No late assignment will be accepted
Minimal Submi ed Files
You are required to turn in the following source file:
assignment6.s
Objec ves:
-write assembly language programs to:
-define procedures/functions and call them.
-create loops
-use syscall operations to display integers and strings on the console window
-use syscall operations to read integers from the keyboard.
Assignment Description:
Implement a MIPS assembly language program that defines main, readArray, printArray, and changeArrayContent procedures/functions. The readArray takes an array of integers as its parameter, asks a user how many numbers will be entered, then reads in integers from a user to fill the array.
The printArray takes an array of integers as its parameter, prints each integer of the array.
The changeArrayContent procedure/function takes parameters of arrays of integers, an integer that specify how many integers were entered by a user, a maximum array size, and also asks a user to enter an integer. Then it goes through each element of the array, and check if it is divisible by the entered integer, it multiplies it by the entered integer. Then it calls printArray to print out the changed content. (Please see the C program below). The main procedure/function calls readArray function to populate the array, calls printArray to print out its original content, then it asks a user to enter how many times the operation should be repeated, then calls changeArrayContent to change it content,
Please see the following C program to understand how it should work. If your program causes an infinite loop, press Control and 'C' keys at the same time to stop it.
Name your source code file assignment6.s.
You can create an array in the following way:
numbers: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
The following shows how it looks like in a C program:
int num, i = 0; int length; printf("Specify how many numbers should be stored in the array (at most 1 1): "); scanf("%d", &length);
while (i < arraysize && i < length)
{ printf("Enter an integer: ");
//read an integer from a user input and store it in num1 scanf("%d", &num); array[i] = num;
i++;
} return length;
}
//The printArray function prints integers of the array void printArray(int array[], int arraysize, int length)
{ int i; i = 0; while (i < arraysize && i < length)
{ printf("%d ", array[i]); i++;
} return;
}
//The changeArrayContent reads in an integer
//Then it goes through the parameter array, and if an element
//is divisible by the entered integer, then it multiplies the element //by the entered integer.
void changeArrayContent(int numbers[], int arraysize, int length)
{ int i; int num1; printf("Enter an integer: ");
//read an integer from a user input scanf("%d", &num1);
//It goes through each element of array
//and change their values if the condition holds
The following is a sample output (user input is in bold):
Specify how many numbers should be stored in the array (at most 11):
9
Enter an integer:
1
Enter an integer:
-12
Enter an integer:
53
Enter an integer:
-4
Enter an integer:
5
Enter an integer:
32
Enter an integer:
1
Enter an integer:
7
Enter an integer:
-5
Original Array Content:
1
-12
53
-4
5
32
1
7
-5
Specify how many times to repeat:
3
Enter an integer:
4
Result Array Content:
1
-48
53
-16
5
128
1
7
-5
Enter an integer:
2
Result Array Content:
1
-96
53
-32
5
256
1
7
-5
Enter an integer:
5
Result Array Content:
1
-96
53
-32
25
256
1
7
-25
--------------------------------------------------
What to turn in:
Go to "GradeScope" tab on Canvas -> CSE/EEE230 -> Assignment6, and upload your program file.
Each procedure/function needs to have a header using the following format:
############################################################
################
# Procedure/Function readArray
# Description: -----
# parameters: $a0 = address of array , $a1 = size
# return value: $v0 = length
# registers to be used: $s3 and $s4 will be used.
############################################################
################
Grading Criteria:
____/ 5 Documentation (header with your name, your information, and program description and comments within your code, each function needs to have a header that is similar to the one described above.)
____/ 1 Indentation and spacing (easy to read)
____/ 6 Required functions (readArray, printArray, changeArrayContent, main) and functionalities implemented
____/ 8 Produces correct results?
Total points: 20
ASU disclaimer (http://www.asu.edu/asuweb/disclaimer/)
Copying any content of this page will be a violation of the copy right.