Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include int main ( ) { int i = 0 ; int h [ 9 ] = { 0 } , x [ 6 ]

#include
int main()
{
int i =0;
int h[9]={0}, x[6]={0}, y[6]={0};
FILE *input = fopen("../input/4.txt","r");
for(i =0; i <9; i++) fscanf(input,"%d", &h[i]);
for(i =0; i <6; i++) fscanf(input,"%d", &x[i]);
for(i =0; i <6; i++) fscanf(input,"%d", &y[i]);
fclose(input);
int *p_x = &x[0];
int *p_h = &h[0];
int *p_y = &y[0];
asm volatile(
" add %[arrayH],%[arrayH],%[point]
\t"
" add %[arrayX],%[arrayX],%[point5]
\t"
"Loop1:
\t"
" add %[count2],%[zero],%[zero]
\t"
" add %[count1],%[count1],%[one]
\t"
" add %[arrayH],%[arrayH],%[point3]
\t"
" add %[arrayX],%[arrayX],%[point4]
\t"
" beq %[count1],%[four],Exit
\t"
"Loop2:
\t"
" add %[count3],%[zero],%[zero]
\t"
" add %[result],%[zero],%[zero]
\t"
"Loop3:
\t"
" lw %[tempX],0(%[arrayX])
\t"
" lw %[tempH],0(%[arrayH])
\t"
" mul %[temp],%[tempX],%[tempH]
\t"
" add %[result],%[result],%[temp]
\t"
" add %[count3],%[count3],%[one]
\t"
" add %[arrayH],%[arrayH],%[four]
\t"
" add %[arrayX],%[arrayX],%[four]
\t"
" add %[arrayX],%[arrayX],%[four]
\t"
" bne %[count3],%[three],Loop3
\t"
" sw %[result],0(%[array])
\t"
" add %[array],%[array],%[four]
\t"
" add %[count2],%[count2],%[one]
\t"
" add %[arrayH],%[arrayH],%[point]
\t"
" add %[arrayX],%[arrayX],%[point2]
\t"
" bne %[count2],%[two],Loop2
\t"
" beq %[count2],%[two],Loop1
\t"
"Exit:
\t"
: [array]"+r"(p_y)
: [point]"r"(-12),[one]"r"(1),[four]"r"(4),[temp]"r"(0),[arrayX]"r"(p_x),[arrayH]"r"(p_h),[count1]"r"(0),[three]"r"(3),[tempX]"r"(0),[i]"r"(0),[tempH]"r"(0),[count2]"r"(0),[result]"r"(0),[zero]"r"(0),[count3]"r"(0),[point2]"r"(-20),[two]"r"(2),[point3]"r"(12),[point4]"r"(-8),[point5]"r"(8)
);
p_y = &y[0];
for(i =0; i <6; i++)
printf("%d ",*p_y++);
printf("
");
return 0;
}
explain the code each and explain it using a table or matrix

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How can these brain centres be discovered?

Answered: 1 week ago