Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MIPS assembly language program : Tic Tac Toe Using this template, copy in all your implemented functions. Then implement the main routine of the program
MIPS assembly language program: Tic Tac Toe Using this template, copy in all your implemented functions. Then implement the main routine of the program to play the game by using the function: .data currentState: .asciiz "This is the current state of the GameBoard: " playerOne: .asciiz "Player One won " playerTwo: .asciiz "Player Two won " playerNone: .asciiz "No winners found " enterMove: .asciiz " Enter a board position (0-8) to make move: " invalidMove: .asciiz " Invalid move - try again. " CR: .byte ' SPACE: .byte 0x20 O: .byte 'o X: .byte 'x DOT .byte '. player: .byte 0x01 gameBoard: .byte 0,0,0,0,0,0,0,0,0 # fresh clean empty gameboard .code .globl main ########################################################################## # CheckTriplet # Check the gameboard positions matching the triplet passed in # to determine either player has won that specific triplet. # # Input: # $a0 : first position to check on gameboard # $a1 : second position to check on gameboard # $a2 : third position to check on gameboard # # Output: # $v0 : 0 = no winner found # $v0 : 1 = player one won # $v0 : -1 = player two won # AS WELL AS an appropriate message if player one or player two has won # ########################################################################## CheckTriplet: # COPY YOUR PAST IMPLEMENTATION HERE ########################################################################## # CheckForWin # Invoke CheckTriplet against the 8 possible winning combinations # to determine if anyone has won the game yet # row 0 # row 1 # row 2 # col 0 # col 1 # col 2 # diagonal 0 # diagonal 1 # # Output: # $v0 : 0 = no winner found # $v0 : 1 = player one won # $v0 : -1 = player two won ########################################################################## CheckForWin: # COPY YOUR PAST IMPLEMENTATION HERE ########################################################################## # PRINTBOARD ########################################################################## PrintBoard: # COPY YOUR PAST IMPLEMENTATION HERE ########################################################################## # RequestMove # # ToDo: # return $v0 = player's choice to move to that is valid # ########################################################################## RequestMove: # COPY YOUR PAST IMPLEMENTATION HERE ########################################################################## # CheckForMoreMoves # # ToDo: # return $v0 = 0 if no more moves left on gameBoard # return $v0 = 1 if yes there are more moves left on gameBoard # ########################################################################## CheckForMoreMoves: # COPY YOUR PAST IMPLEMENTATION HERE ########################################################################## # TOGGLEPLAYER ########################################################################## TogglePlayer: lb $t0,player sub $t0,$zero,$t0 sb $t0,player jr $ra # return from function call ########################################################################## # MAIN ########################################################################## main: # Print the board # request the move # apply the move to the board & toggle player # check for win # check for more moves # loop until win or draw # if no winners found, say so and exit # print the board one last time before exiting # 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