Engineering
Engineering, 14.02.2020 22:23, ggpro4life3000

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 two integers and they should be stored into variables named, index and num2. Using the first integer, index, it should examine each integer in the array up to the index to see if it is divisible by the second entered integer, num2. (You can divide each integer by the entered integer to see if its remainder is zero) and if it is, then the number should be multiplied by the second number, num2. If the first entered integer, index is less than 0, then no integer in the array should be changed. If the first entered integer, index is more than 10, then all integers in the array should be examined to see if they should be changed (by multiplying by the second number). After modifying the array, each integer in the array should be printed.
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 enters 3, then the output will be the following:
-81
9
46
-7
11
72
-5
14
-18
12
35

i. e., the numbers that are located until the index 5:
(-27, 3, 46, -7, 11, 24) are examined to see if each of them is divisible by the second entered number, 3.
In this case, -27, 3, 24 that are divisible by 3, thus they are multiplied by the second entered number 3, then we get
(-81, 9, 46, -7, 11, 72, -5, 14, -18, 12, 35)
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 -27, 3, 46, -7, 11, 24, -5, 14, -18, 12, 35

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

void main()
{
int numbers[11] = {-27, 3, 46, -7, 11, 24, -5, 14, -18, 12, 35};

int index, num2;
int j;

printf("Enter an integer:\n");

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

printf("Enter another integer:\n");

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

for (j = 0; j < 11 && j <= index; j = j+1)
{
if (numbers[j] % num2 == 0)
{
numbers[j] = numbers[j]*num2;
}
}

printf("Result Array Content:\n");
for (j = 0; j < 11; j = j+1)
{
printf("%d\n", numbers[j]);
}

return;
}

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

Enter an integer:
5
Enter another integer:
3
Result Array Content:
-81
9
46
-7
11
72
-5
14
-18
12
35

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:20, luisgonz5050
Find the kinematic pressure of 160kpa. for air, r-287 j/ kg k. and hair al viscosity of air at a temperature of 50°c and an absolute (10 points) (b) find the dynamic viscosity of air at 110 °c. sutherland constant for air is 111k
Answers: 3
image
Engineering, 04.07.2019 19:10, gabigalvis1091
What is the main objective of using reheat rankine cycle?
Answers: 3
image
Engineering, 04.07.2019 19:10, jimena15
10 kg of co2 is initially contained at 400 kpa and 300 k. the gas constant for carbon dioxide is 189 j/lkg k) and has a specific heat ratio, k, of 1.289. isentropic expansion then occurs until the pressure is 200 kpa. a) determine the initial volume of co2 in m. b) determine the final temperature in k. c) determine the work done by the system during the expansion kl.
Answers: 2
image
Engineering, 04.07.2019 19:10, gabrielaperezcz
Air inially occupying a volume of 1 m2 at 100 kpa, 27 c undergoes three internally reversible processes in series. process 1-2 compression to 500 kpa during which pv constant process 2-3 adiabatic expanslon to 100 kpa process 3-1: constant-pressure expansion to 100 kpa (a) calculate the change of entropy for each of the three processes. (b) calculate the heat and work involved in each process. (c) is this cycle a power cycle or refrigeration cycle?
Answers: 3
Do you know the correct answer?
An array of integers can be assigned to a memory address in the .data section of a MIPS assembly lan...

Questions in other subjects: