Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. I have this homework to do and I need help. Can you please help me convert this C code to Assembly P3 ? #include

Hello. I have this homework to do and I need help. Can you please help me convert this C code to Assembly P3?

#include #include

int manhantan (int vetor[16]){ int pos=-1; int x=-1; int y=-1; int distance=-1; for (int i=0; i<16; i++){ if (vetor[i] == 0){ pos=i; break; } } if (pos>=0 && pos<=3){ y=4; } if (pos>=4 && pos<=7){ y=3; } if (pos>=8 && pos<=11){ y=2; } if (pos>=12 && pos<=15){ y=1; } if (pos==0 || pos==4 || pos==8 || pos==12){ x=1; } if (pos==1 || pos==5 || pos==9 || pos==13){ x=2; } if (pos==2 || pos==6 || pos==10 || pos==14){ x=3; } if (pos==3 || pos==7 || pos==11 || pos==15){ x=4; }

distance = abs(x-4) + abs(y-1); printf("%d", distance); return distance;

}

int main(){ int vetor[16]; for (int i=0; i<16; i++) { scanf("%d", &vetor[i]); } manhantan(vetor); }

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

Students also viewed these Databases questions

Question

The Functions of Language Problems with Language

Answered: 1 week ago

Question

The Nature of Language

Answered: 1 week ago