Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!