4. Assembly Arithmetics Given that a is a byte, x\'s are words and y\'s are doub
ID: 1867008 • Letter: 4
Question
4. Assembly Arithmetics Given that a is a byte, x's are words and y's are double words. Declare appropriate variables and translate the following from Pseudojava to assembly. You may choose the values such that the results of your operations never exceed 32 bits Display your results. eax-a+8 ebx-x1+a*x3 yl4]-y[5] * (-yly.lastElem])/(3+eax) 5. Arrays Declare in1 and in2 arrays of words and out-the array of double words. The lengths of in1 and in2 are equal. Write a program that does the following: out [x]-inl[x]+in2[x] out [x]-inl[x]*in2[x] For ax s.t. 0xExplanation / Answer
5. Solution
#include<stdlib.h>
#include<stdio.h>
#define len 5 //length of array
int main()
{
//input array
double in1[len];
double in2[len];
//output array
double out[len];
int i;
//asking user input for array 1
for(i = 0; i < len; i++)
{
printf("Enter element of input array 1: ");
scanf("%lf", &in1[i]);
}
//asking user input for array 2
for(i = 0; i < len; i++)
{
printf("Enter element of input array 2: ");
scanf("%lf", &in2[i]);
}
for(i = 0; i < len; i++)
{
//if index is odd then multiply array
if(i % 2)
{
out[i] = in1[i] * in2[i];
}
//if index is even then add array
else
out[i] = in1[i] + in2[i];
}
printf(" Output array is ");
for(i = 0; i < len; i++)
{
printf("%lf ", out[i]);
}
return 0;
}
PLEASE REFER BELOW OUTPUT
Enter element of input array 1: 1.1
Enter element of input array 1: 3.4
Enter element of input array 1: 2.3
Enter element of input array 1: 67.2
Enter element of input array 1: 31.1
Enter element of input array 2: 2.7
Enter element of input array 2: 3.9
Enter element of input array 2: 4.7
Enter element of input array 2: 3.33
Enter element of input array 2: 4.5
Output array is
3.800000 13.260000 7.000000 223.776000 35.600000
Process returned 0 (0x0) execution time : 33.800 s
Press any key to continue.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.