Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help me fix any problems in my MIPS / MARS code, in order to get the game to properly run. I have been struggling with
Help me fix any problems in my MIPSMARS code, in order to get the game to properly run. I have been struggling with this for weeks so helping will be appreciated. Thanks!
moveRobots:
addi $sp $sp
sw $ra$sp
li $t
moveloop:
bge $t endmoveloop
li $t
mul $t $t
add $t $a $t
lw $t$t
add $t $a $t
lw $t$t
move $a $t
move $a $a
jal getNew
move $t $v
move $a $t
move $a $a
jal getNew
move $t $v
beq $t $a humandead
beq $t $a humandead
addi $t $t
j moveloop
endmoveloop:
li $v
j moveRobotsexit
humandead:
li $v
moveRobotsexit:
lw $ra$sp
addi $sp $sp
jr $ra
getNew:
addi $sp $sp
sw $ra$sp
sub $v $a $a
lw $ra$sp
addi $sp $sp
jr $ra
text
main:
addi $sp $sp
sw $ra$sp
sw $s$sp
sw $s$sp
li $s
li $s
la $a x
la $a y
mainloop:
li $v
la $a usercoords
syscall
li $v
la $a promptinput
syscall
li $v
syscall
beq $v moveright
beq $v moveleft
beq $v moveup
beq $v movedown
j invalidinput
moveright:
addi $s $s
j updaterobots
moveleft:
addi $s $s
j updaterobots
moveup:
addi $s $s
j updaterobots
movedown:
addi $s $s
j updaterobots
invalidinput:
li $v
la $a invalidinputmsg
syscall
j mainloop
updaterobots:
move $a $s
move $a $s
jal moveRobots
move $t $v
beq $t humandead
j mainloop
moveend:
lw $ra$sp
lw $s$sp
lw $s$sp
addi $sp $sp
li $v
syscall
data
x: space
y: space
usercoords: asciiz "Your coordinates:
promptinput: asciiz "Enter move for x for x for y for y:
invalidinputmsg: asciiz "Invalid input! Please enter or
gameovermsg: asciiz "AAAARRRRGHHHHH... Game over
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