Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please convert this C + + to MIPS. #include int moveRobots ( int * , int * , int, int ) ; int getNew (
Please convert this C to MIPS.
#include
int moveRobotsint int int, int ;
int getNewint int;
int main
int x y i j myX myY move, status ;
x; y;
x; y;
x; y;
x; y;
std::cout "Your coordinates:
;
while status
std::cout "Enter move for x for x for y for y:;
std::cin move;
process user's move
if move
myX;
else if move
myX;
else if move
myY;
else if move
myY;
status moveRobots&x&ymyXmyY;
std::cout "Your coordinates: myX myY
result arg;
else if temp
result arg;
else if temp
result arg;
else if temp
result arg;
else if temp
result arg;
return result;
Please use this template. Coding needs to added from moveRobots function. Please make sure it runs.
#
# A proper program header goes here...
#
#
data
x: word : # xcoordinates of robots
y: word : # ycoordinates of robots
str: asciiz "Your coordinates:
str: asciiz "Enter move for x for x for y for y:
str: asciiz "Your coordinates:
sp: asciiz
endl: asciiz
str: asciiz "Robot at
str: asciiz "AAAARRRRGHHHHH... Game over
#i $s
#myX $s
#myY $s
#move $s
#status $s
#temp,pointers $s$s
text
main: li $s
li $s
li $s
la $sx
la $sy
sw $$s
sw $$s
sw $$s
li $s
sw $s$s
sw $s$s # x; y;
sw $$s
sw $s$s # x; y;
sw $s$s
la $astr # cout "Your coordinates:
;
li $v
syscall
bne $smainexitw # while status
mainwhile:
la $astr # cout "Enter move for x
li $v # for x for y for y:;
syscall
li $v # cin move;
syscall
move $s$v
bne $smainelse# if move
add $s$s # myX;
b mainexitif
mainelse:
bne $smainelse # else if move
add $s$s # myX;
b mainexitif
mainelse:
bne $smainelse # else if move
add $s$s # myY;
b mainexitif
mainelse: bne $smainexitif # else if move
add $s$s # myY;
mainexitif: la $ax # status moveRobots&x&ymyXmyY;
la $ay
move $a$s
move $a$s
jal moveRobots
move $s$v
la $astr # cout "Your coordinates: myX
li $v # myY endl;
syscall
move $a$s
li $v
syscall
la $asp
li $v
syscall
move $a$s
li $v
syscall
la $aendl
li $v
syscall
la $sx
la $sy
li $s # for i;i;i
mainfor: la $astr # cout "Robot at xi
li $v # yi endl;
syscall
lw $a$s
li $v
syscall
la $asp
li $v
syscall
lw $a$s
li $v
syscall
la $aendl
li $v
syscall
add $s$s
add $s$s
add $s$s
blt $smainfor
beq $smainwhile
#
mainexitw: la $astr # cout "AAAARRRRGHHHHH... Game over
;
li $v
syscall
li $v #
syscall
# int moveRobotsint arg int arg int arg int arg
#
# arg $a base address of array of xcoordinates
# arg $a base address of array of ycoordinates
# arg $a xcoordinate of human copy in $s
# arg $a ycoordinate of human copy in $s
# ptrX $s
# ptrY $s
# i $s
# alive $s
# temp $s
#
# moveRobots calls getNew to obtain the new coordinates
# of each robot. The position of each robot is updated.
moveRobots:
li $s # alive ;
move $s$a
move $s$a
move $s$a # ptrX arg;
move $s$a # ptrY arg;
li $s # for i;i;i
loop:
j endfor
inc: #ptr;#ptry;
endfor:
jr $ra #
getNew: #
sub $t$a$a
blt $tgelse
sub $v$a #
j exitgelse
gelse: blez $tgelse
sub $v$a
j exitgelse
gelse: # else if temp
# result arg
gelse: # else if temp
# result arg>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started