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 ARM but using bits x registers Following are the instructions:
Display an empty grid with cells at the beginning of the game. The grid will have rows and columns. Each row and column will have numbers.
There will be two players. Each player takes turns playing the game.
To select a cell to place the symbol, the player enters the row and column numbers as Player :
Once a player enters the cell, replace the cell with the corresponding symbol and display the grid.
At the end of the game, display the outcome of the game. EXAMPLE of layout build as follows: global main
main:
Display prompt
ldr xprompt Load the address of prompt into x
bl printf Call printf to display the prompt
Read user input
ldr xformat Load the address of format into x
ldr xnumber Load the address of number into x
bl scanf Call scanf to read user input
Perform the SELECTCASE construct
ldr xnumber
ldr xx Load the value of 'number' into x
Perform the SELECTCASE construct
cmp x # Compare xnumber with
beq case Branch to case if equal
cmp x # Compare xnumber with
beq case Branch to case if equal
b defaultcase Branch to defaultcase if no other cases matched
case:
Statements if number is
ldr xmsgcase Load the address of msgcase into x
bl printf Call printf to display the message
b endselect Branch to endselect after executing case
case:
Statements if number is
ldr xmsgcase Load the address of msgcase into x
bl printf Call printf to display the message
b endselect Branch to endselect after executing case
defaultcase:
Statements if not any other case
ldr xmsgdefault Load the address of msgdefault into x
bl printf Call printf to display the message
endselect:
End of SELECTCASE construct
Exit the program
mov x # Set the syscall number for exit
mov x # Set the exit status
svc # Call the kernel
data
prompt: asciz "implement a SelectCase structure:
Case actions
Case actions
User Input:
align
msgcase: asciz "case actions will be taken
align
msgcase: asciz "case actions will be taken
align
msgdefault: asciz "input does not match with any case. Else actions
align
number: byte
format: asciz d
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
