Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. data X: . word 1 0 , 4 0 , 4 0 , 1 0 # Initial x - coordinates of robots Y: .
data
X: word # Initial xcoordinates of robots
Y: word # Initial ycoordinates of robots
str: asciiz "Your coordinates:
str: asciiz "Enter move for X for X for Y for Y:
str: asciiz "Your coordinates:
str: asciiz "Robot at
str: asciiz "AAAARRRRGHHHHH... Game over
sp: asciiz
endl: asciiz
text
globl main
main:
li $s # Player's initial X coordinate
li $s # Player's initial Y coordinate
li $s # Game status: continue, game over
la $a str
li $v
syscall
b mainwhile # Jump to main loop
mainwhile:
beq $s mainexit # If game over, exit the loop
# Display move options
la $a str
li $v
syscall
# Get player's move
li $v
syscall
move $s $v
# Update player's coordinates based on input
beq $s incx
beq $s decx
beq $s incy
beq $s decy
j mainwhile
incx:
addi $s $s
j updaterobots
decx:
addi $s $s
j updaterobots
incy:
addi $s $s
j updaterobots
decy:
addi $s $s
j updaterobots
updaterobots:
# Update robot positions and check game status
la $a X
la $a Y
move $a $s
move $a $s
jal moveRobots
move $s $v
# Print current coordinates of the player
la $a str
li $v
syscall
move $a $s
li $v
syscall
la $a sp
li $v
syscall
move $a $s
li $v
syscall
la $a endl
li $v
syscall
# Print current coordinates of the robots
la $t X
la $t Y
li $t
printrobots:
bge $t endprintrobots
la $a str
li $v
syscall
lw $t$t # Load robot X coordinate
move $a $t
li $v
syscall
la $a sp
li $v
syscall
lw $t$t # Load robot Y coordinate
move $a $t
li $v
syscall
la $a endl
li $v
syscall
addi $t $t # Move to next robot X coordinate
addi $t $t # Move to next robot Y coordinate
addi $t $t
j printrobots
endprintrobots:
j mainwhile # Repeat the loop
mainexit:
la $a str # Game over message
li $v
syscall
li $v # Exit the program
syscall
moveRobots:
la $t X # Load base address of X
la $t Y # Load base address of Y
li $t # Loop counter
moveRobotsloop:
bge $t moveRobotsend # If loop counter end loop
lw $t$t # Load current robot X coordinate
lw $t$t # Load current robot Y coordinate
# Move robot X coordinate towards player
sub $t $a $t # $t playerx robotx
bltz $t decrobotx # If playerx robotx decrement robotx
bgtz $t incrobotx # If playerx robotx increment robotx
incrobotx:
addi $t $t
b storerobotx
decrobotx:
addi $t $t
storerobotx:
sw $t$t # Store updated X coordinate
# Move robot Y coordinate towards player
sub $t $a $t # $t playery roboty
bltz $t decroboty # If playery roboty decrement roboty
bgtz $t incroboty # If playery roboty increment roboty
incroboty:
addi $t $t
b storeroboty
decroboty:
addi $t $t
storeroboty:
sw $t$t # Store updated Y coordinate
# Check if robot caught the human Xi s && Yi s
beq $t $a checkycatch
b nextrobot
checkycatch:
beq $t $a humandead
nextrobot:
addi $t $t # Move to next robot X coordinate
addi $t $t # Move to next robot Y coordinate
addi $t $t # Increment loop counter
b moveRobotsloop
humandead:
li $v # Game over
jr $ra
moveRobotsend:
li $v # Continue game
jr $ra
this is the code I have but it does not contain expected output Can you please modify the above code according to this ouput Please provide me every single line of the code. the code you provided is givivng me this error
Error in UsersomshreebharodiyaDownloadsCSC FinalProject.asm line column : Symbol "moveRobots" not found in symbol table.
Assemble: operation completed with errors.
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