Computer Science

9/7/2017 Assignment

https://courses.eas.asu.edu/cse230/current/assignments/assignment5.html 1/3

CSE/EEE230 Assignment5

Due Date

Friday, September 8th, 5pm

Important: This is an individual assignment. Please do not collaborate.

It must be submitted on-line (Blackboard).

No late assignment will be accepted

Minimal Submitted Files

You are required to turn in the following source file:

assignment5.s

Objectives:

-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: An array of integers can be assigned to a memory address in the .data section of a MIPS assembly language program as show below. Here the length of the array is stored first, and then the elements of the array numbers next. You are given the following C program that will ask a user to enter one integer and it will filter all integers in the array into the ones that are less than or equals to the entered integer and the ones that are greater. 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.

For instance, if a user enters 5, then the output will be the following: -42

3 -6 -18 -27 -28 11

45 12 24 35 14

i.e., the number that are less than 5, (-42, 3, -6, -18, -27, -28) are swapped so that they are located towards the beginning of the array, and the number that are greater than 5,

(11, 45, 12, 24, 35, 14) are located towards the end of the array. 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.

9/7/2017 Assignment

https://courses.eas.asu.edu/cse230/current/assignments/assignment5.html 2/3

.data numbers_len: .word 12

numbers: .word -42, 11, 24, 3, -6, 14, -18, 45, 12, -27, 35, -28

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

void main() { int numbers[12] = {-42, 11, 24, 3, -6, 14, -18, 45, 12, -27, 35, -28};

int num1, num2; int i = -1; int j;

printf(“Enter an integer:\n”);

//read an integer from a user input and store it in num1 scanf(“%d”, &num1);

for (j = 0; j < 12; j = j+1) { if (numbers[j] <= num1) { i = i + 1; num2 = numbers[i]; numbers[i] = numbers[j]; numbers[j] = num2; } }

for (j = 0; j < 12; j = j+1) { printf(“%d\n”, numbers[j]); }

return; }

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

Enter an integer: 5

-42 3

-6 -18 -27 -28 11

45 12 24 35 14

————————————————– The following is another sample output:

9/7/2017 Assignment

https://courses.eas.asu.edu/cse230/current/assignments/assignment5.html 3/3

————————————————– Enter an integer:

-20 -42 -27 -28 3

-6 14 -18 45

12 11 35 24

————————————————– What to turn in: -Upload your assignment5.s file through the assignment submission link in the Blackboard by the assignment deadline. You must have your name, email address, program description, and other information in the header block as it was described in the assignment 1, and your programs should be well commented. Grading Criteria: ____/ 4 Documentation (header and comments) ____/ 1 Indentation (easy to read) ____/ 1 Spacing (easy to read) ____/ 4 Required procedures — just main for this assignment ____/ 2 Does it assemble? ____/ 8 Produces correct results? Total points: 20

Order now and get 10% discount on all orders above $50 now!!The professional are ready and willing handle your assignment.

ORDER NOW »»