Question: Write an assembly code for the Tic Tac Toe game ( 6 4 ARM but using 3 2 - bits ( x registers

Write an assembly code for the Tic Tac Toe game (64ARM but using 32-bits ("x" registers)). Following are the instructions:
1) Display an empty grid with 9 cells at the beginning of the game. The grid will have 3 rows and 3 columns. Each row and column will have numbers.
2) There will be two players. Each player takes turns playing the game.
3) To select a cell to place the symbol, the player enters the row and column numbers as Player 1: 11
4) Once a player enters the cell, replace the cell with the corresponding symbol and display the grid.
5) At the end of the game, display the outcome of the game. EXAMPLE of layout build as follows: .global main
main:
// Display prompt
ldr x0,=prompt // Load the address of prompt into x0
bl printf // Call printf to display the prompt
// Read user input
ldr x0,=format // Load the address of format into x0
ldr x1,=number // Load the address of number into x1
bl scanf // Call scanf to read user input
// Perform the SELECT/CASE construct
ldr x1,=number
ldr x2,[x1]// Load the value of 'number' into x2
// Perform the SELECT/CASE construct
cmp x2, #1// Compare x2(number) with 1
beq case_1// Branch to case_1 if equal
cmp x2, #2// Compare x2(number) with 2
beq case_2// Branch to case_2 if equal
b default_case // Branch to default_case if no other cases matched
case_1:
// Statements if number is 1
ldr x0,=msg_case_1// Load the address of msg_case_1 into x0
bl printf // Call printf to display the message
b end_select // Branch to end_select after executing case_1
case_2:
// Statements if number is 2
ldr x0,=msg_case_2// Load the address of msg_case_2 into x0
bl printf // Call printf to display the message
b end_select // Branch to end_select after executing case_2
default_case:
// Statements if not any other case
ldr x0,=msg_default // Load the address of msg_default into x0
bl printf // Call printf to display the message
end_select:
// End of SELECT/CASE construct
// Exit the program
mov x8, #93// Set the syscall number for exit
mov x0, #0// Set the exit status
svc #0// Call the kernel
.data
prompt: .asciz "implement a Select/Case structure:\
1. Case 1 actions\
2. Case 2 actions\
User Input: "
.align 4
msg_case_1: .asciz "case 1 actions will be taken\
"
.align 4
msg_case_2: .asciz "case 2 actions will be taken\
"
.align 4
msg_default: .asciz "input does not match with any case. Else actions\
"
.align 4
number: .byte 0
format: .asciz "%d"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!