The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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. A C program that will ask a user to enter two integers and compute the sum of numbers in the array that are between those two integers (inclusive). Implement a MIPS assembly language program to compute the sum of numbers in the array that are between the entered integers. 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    14
numbers:            .word    11, 24, 3, -6, 14, -18, 21, 45, 12, -27, 35, -7, 44, -28
The following shows how it looks like in a C program:
void main()
{
int numbers[14] = {11, 24, 3, -6, 14, -18, 21, 45, 12, -27, 35, -7, 44, -28};
int num1, num2, min, max, sum = 0;
int i;
printf("Enter an integer:n");
//read an integer from a user input and store it in num1
scanf("%d", &num1);
printf("Enter another integer:n");
//read an integer from a user input and store it in num2
scanf("%d", &num2);
//check which number is larger and set the max and min
if (num1 < num2)
{
min = num1;
max = num2;
}
else
{
min = num2;
max = num1;
}
for (i = 0; i < 14; i++)
{
if (numbers[i] >= min && numbers[i] <= max)
sum = sum + numbers[i];
}
printf( "The sum of numbers that are inbetween: %dn", sum);
return;
}
-----------