Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Translate these two functions into MIPS Language int moveRobots(int *arg0, int *arg1, int arg2, int arg3) { int i, *ptrX, *ptrY, alive = 1; ptrX

Translate these two functions into MIPS Language

int moveRobots(int *arg0, int *arg1, int arg2, int arg3)

{

int i, *ptrX, *ptrY, alive = 1;

ptrX = arg0;

ptrY = arg1;

for (i=0;i<4;i++) {

*ptrX = getNew(*ptrX,arg2); // update x-coordinate of robot i

*ptrY = getNew(*ptrY,arg3); // update y-coordinate of robot i

// check if robot caught user

if ((*ptrX == arg2) && (*ptrY == arg3)) {

alive = 0;

break;

}

ptrX++;

ptrY++;

}

return alive;

}

// move coordinate of robot closer to coordinate of user

int getNew(int arg0, int arg1)

{

int temp, result;

temp = arg0 - arg1;

if (temp >= 10)

result = arg0 - 10;

else if (temp > 0)

result = arg0 - 1;

else if (temp == 0)

result = arg0;

else if (temp > -10)

result = arg0 + 1;

else if (temp <= -10)

result = arg0 + 10;

return result;

}

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_2

Step: 3

blur-text-image_3

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

Students also viewed these Databases questions

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago