Starting from:

$24.99

CSE230 Assignment 5 Solution



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 -> Assignment5, 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:
assignment5.s
Objec ves:

-write assembly language programs to:
-perform decision making using branch instructions.
-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 to perform the functionality of the following C program and print the updated array content, by listing each integer in it.
It should ask a user to enter three integers, an ending index, an integer, and another integer to use for a comparison. It should examine only the elements in the array located from the index 0 to the entered ending index to check if each of them is greater the smallest of the last two entered numbers and is less than the largest of the last two entered numbers, then if it is, then change each such element in the array within the range according to the calculation given in the C program umbers[j] = numbers[j]*num1 + num2. For instance, if a user enters 8, enters 3, then enters 23, then the output will be the following:
2
80
23
-7
68
-17
56
-4
23
-26
27
i.e., the numbers that are located between the index 0 and 7 are examined to see if each of them is greater than 3 and less than 23. then each of such element is changed.
If your program causes an infinite loop, press Control and 'C' keys at the same time to stop it. Name your source code file assignment5.s.
.data numbers_len: .word 11 numbers: .word 2, 19, 23, -7, 15, -17, 11, -4, 23, -26, 27




The following shows how it looks like in a C program:

int numbers_len = 11; int numbers[11] = {2, 19, 23, -7, 15, -17, 11, -4, 23, -26, 27};
int endingIndex, num1, num2, temp;
int j;
printf("Enter an ending index: ");
//read an integer from a user input and store it in endingIndex scanf("%d", &endingIndex);
printf("Enter an integer: ");
//read an integer from a user input and store it in num1 scanf("%d", &num1);

printf("Enter another integer: ");
//read an integer from a user input and store it in num2 scanf("%d", &num2);

//if num1 is larger than num2, swap them if (num1 > num2)
{
temp = num1; num1 = num2; num2 = temp;
}
//At this point num1 will always be less or equals to num2

//changing the array content for (j = 0; j < endingIndex && j < numbers_len; j = j+1)
{
if (numbers[j] > num1 && numbers[j] < num2)
{
numbers[j] = numbers[j]*num1 + num2;
}
}
printf("Result Array Content: "); for (j = 0; j < numbers_len; j = j+1)
{ printf("%d ", numbers[j]); }


The following is a sample output (user input is in bold):


Enter an ending index:
8
Enter an integer:
3
Enter another integer:
23
Result Array Content:
2
80
23
-7
68
-17
56
-4
23
-26 27
--------------------------------------------------
The following is another sample output:

--------------------------------------------------
Enter an ending index:
5
Enter an integer:
14
Enter another integer:
-2
Result Array Content:
10
19
23
-7
15
-17
11
-4
23
-26 27
--------------------------------------------------

What to turn in:
Go to "GradeScope" tab on Canvas -> CSE/EEE230 -> Assignment5, and upload your program file.

Grading Criteria:
____/ 5 Documentation (header with your name, your information, and program description and comments within your code)
____/ 1 Indentation and spacing (easy to read)
____/ 6 Required functions 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.

More products