Answered step by step
Verified Expert Solution
Question
1 Approved Answer
.data enterMove: .asciiz Enter a board position (0-8) to make move: youChose: .asciiz You chose: invalidMove: .asciiz Invalid move -
.data enterMove: .asciiz " Enter a board position (0-8) to make move: " youChose: .asciiz " You chose: " invalidMove: .asciiz " Invalid move - try again. " CR: .byte ' # enable each one (turning off the other) to confirm your code works in both cases # gameBoard: .byte -1,0,-1,0,1,0,-1,1,-1 # pos 1, 3 and 5 are valid moves .code .globl main ########################################################################## # requestMove # # ToDo: # return $v0 = player's choice to move to that is valid # ########################################################################## requestMove: la $t0,gameBoard li $t1,0x00 # reset to starting index on game board li $v0,0xFF # convenience to say - hey not implemented # prompt player # read their choice (in $v0) # be sure it is less than 9 check: # your check logic here # You'll need to calcuate the address belonging # to the position the user entered. Then load # byte of that position. Then check that it is # currently empty - hence allowing the user to # choose it. If valid, return the position. # If invalid, do not return. Instead, tell the # user and have them try choosing again. done: jr $ra # return from function call ########################################################################## # MAIN ########################################################################## main: jal requestMove la $a0,youChose syscall $print_string move $a0,$v0 syscall $print_int lb $a0,CR syscall $print_char syscall $exit
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