Käynnissä

Assembly Language

.data

currentState: .asciiz "This is the current state of the GameBoard:\n"

playerOne: .asciiz "Player One won\n"

playerTwo: .asciiz "Player Two won\n"

playerNone: .asciiz "No winners found\n"

CR: .byte '\n

SPACE: .byte 0x20

O: .byte 'o

X: .byte 'x

DOT .byte '.

# enable only one at a time to test your code

# it should detect the win for the designated player

#

gameBoard: .byte 0,0,0,0,0,0,0,0,0 # no winner

#gameBoard: .byte 1,1,1,0,0,0,0,0,0 # player one wins - by row 0

#gameBoard: .byte 0,0,0,-1,-1,-1,0,0,0 # player two wins - by row 1

#gameBoard: .byte 0,0,0,0,0,0,-1,-1,-1 # player two wins - by row 2

#gameBoard: .byte 1,0,0,1,0,0,1,0,0 # player one wins - by col 0

#gameBoard: .byte 0,1,0,0,1,0,0,1,0 # player one wins - by col 1

#gameBoard: .byte 0,0,-1,0,0,-1,0,0,-1 # player two wins - by col 2

#gameBoard: .byte 1,0,0,0,1,0,0,0,1 # player one wins - by diag 0

#gameBoard: .byte 0,0,-1,0,-1,0,-1,0,0 # player two wins - by diag 1

.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:

# ENTER YOUR CODE HERE

done: jr $ra

##########################################################################

# 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:

addi $sp,$sp,-4 # make room on the stack for our variables

sw $ra,0($sp) # save our return address

# ENTER YOUR CODE HERE

doneCFW: lw $ra,0($sp) # restore our return address

addi $sp,$sp,4 # free the room we have taken on the stack

jr $ra # return from function

##########################################################################

# PRINTBOARD

##########################################################################

PrintBoard:

# COPY YOUR PAST IMPLEMENTATION HERE

##########################################################################

# MAIN

##########################################################################

main:

jal PrintBoard

jal CheckForWin

bnez $v0,finished

la $a0,playerNone # if no winners found, for now, just say so and exit

syscall $print_string

finished: syscall $exit

Taidot: Assembly, C-ohjelmointi, C++ -ohjelmointi, tietojärjestelmäarkkitehtuuri, x86/x64 Assembler

Näytä lisää: matrix input assembly language, mips assembly language rational function, function calculator assembly language, dump data segment assembly language, assembly language keyboard input, write mips assembly language program mars simulator prompt user string process string character time display specific informatio, string charactor send lcd assembly language ic pic16f877, input characters array assembly language, using function program mips assembly language, mips assembly language string sort, string characters mips assembly language, read string mips assembly language, counting number characters string assembly language, data entry assembly language 68hc11

Tietoa työnantajasta:
( 0 arvostelua ) United States

Projektin tunnus: #16341530

Myönnetty käyttäjälle:

$25 USD 1 päivässä
(0 Arvostelua)
0.0

3 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön

$25 USD 1 päivässä
(4 arvostelua)
1.9
Mubin17

what exactly you want.

$25 USD 2 päivässä
(0 arvostelua)
0.0