Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
