-1 CDA3100 ASSIGNMENT 6 TICTACTOE Objectives: Learn how to write an assembly program that consists of functions, learn the MIPS calling conventions, and learn how to access a two-dimensional array in...

Can you guys do a game of Tic Tac Toe on MIPS Assembly Language?


-1 CDA3100 ASSIGNMENT 6 TICTACTOE Objectives: Learn how to write an assembly program that consists of functions, learn the MIPS calling conventions, and learn how to access a two-dimensional array in assembly language. This will also be an exercise in gaming and game strategy. Your assignment is to write a MIPS program that will allow a person to play TicTacToe against a computer using the QtSpim simulator. The tic-tac-toe game will be played using a primitive ascii character screen. The positions of the grid will be as follows: 1 | 2 | 3 --------- 4 | 5 | 6 --------- 7 | 8 | 9 - For simplicity the Human will always go second and as such will always use the “O” and the computer will always use “X”. - When prompted the user (human) will enter a number between 1 and 9 corresponding to the position grid above. - A valid move will be in a space that has not been occupied by a character X” or “O” AND is between the values 1 and 9 (inclusive). - If it is not a valid move, then you should prompt the player to re-enter the move. - Once the player enters a valid move, print out the state of the board. - You should then check if either the human or the computer has won the game. - A player can win the game by filling in a row, column, or diagonal of the board. If the player has won, then print out a message and quit. If not, select a square for the computer to move to and then print out a prompt for the other human to enter a move. - - - Keep allowing the game to continue until someone wins (human or computer) or all squares are filled which is a tie game. - Print a message in case of a tie. You should have a comment beside each instruction in the assembly program (or at a minimum a comment for a small group of related instructions) to help make your code more -2 understandable. You should also have comments at the top of the file indicating your name, this course, and the assignment. You should submit your assignment as a single file attachment through the Blackboard portal for this assignment. Programming Requirements: You are required to modularize your MIPS assembly program into functions and calls and returns should conform to the MIPS calling conventions, such as: - parameter passing parameters - preserving register values, as presented in class. - In addition, you should not have any conditional branch (e.g. beq or bne) or unconditional jump (e.g. j) instructions that cross function boundaries. In other words do not branch in the middle of a subroutine ( this would be very unusual). Below are suggestions on functions written in C that you may use in your program.: // print the tictactoe board void print_board(); // returns 1 if the position is valied ( between 1 and 9 and an empty space) otherwise returns 0 int valid_position(int pos); // repeatedly prompt player to enter move until it is valid and return // address of entry in tictactoe board char *get_valid_move(char player); // print that the player has won the game and exits program execution void print_winner_and_exit(char player); // checks if a row’s entry values all match the player void row_winner(int row, char player); // checks if a column’s entry values all match the player void col_winner(int col, char player); // checks if either diagonal all match the player void diag_winner(char player); // check if the player has won the game void check_for_win(char player); -3 Programming in Steps: It is strongly suggested that you implement and test this assignment in stages as suggested below. By implementing and testing the assignment in stages, you are more likely to receive partial credit if you are unable to entirely complete the assignment. - Print out a simple message such as welcoming them to game. - Print out the sample board o I would load the storage location with a predefined game board and print it out to make sure my print routine works properly - Start the game - Prompt the user to enter a position. Assume they enter in valid numbers. o Add error checking to make sure the numbers are between 1 and 9 AND o The position they want to move to is empty. - Have the computer pick the first empty square. The computer can play like a dummy and just find the first empty square or you can add intelligence if you wish. - Check for row wins - Check for Column wins - Check for Diagonal wins - Check for a Tie Etc. Grading In order to be graded the program must assemble and allow the grader to start the program. - 10% - Proper declaration of tictactoe board - 10% - Program properly documented - Contains comments that identifies the programmer - Contains comments that describe how the program works. - 25% - Program is modular. Has functions with at least one instance of passing parameters using standard calling conventions and preserving registers. - 55% - Correct implementation. o 10% Prints board and output is done correctly o 15% Identifies a winner as soon as possible. Ties need only be detected when all squares are full. o 15% Identifies correct/incorrect moves o 15% Identifies Winners/Losers .
Nov 05, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here