Mips
print1:
lw $t8, 0($a1)
addi $a1, $a1, 4
la $a0, output4
syscall
beq $t8, $zero, dash
beq $t8, $a2, X
O: la $a0, output7
syscall
addi $s0, $s0, -1
bgtz $s0, hdash
j nline
X: la $a0, output6
syscall
addi $s0, $s0, -1
bgtz $s0, hdash
j nline
dash:
la $a0, output8
syscall
addi $s0, $s0, -1
bgtz $s0, hdash
j nline
hdash:
la $a0, output5
syscall
j print1
nline:
la $a0, output3
syscall
addi $s1, $s1, -1
addi $s0, $s0, 3
bgtz $s1, print1
beq $t9, $zero, main2
j main3
win1: li $v0, 4 #Same thing as print, except it also prints that player1 wins.
la $a1, grid
prin1: lw $t8, 0($a1)
addi $a1, $a1, 4
la $a0, output4
syscall
beq $t8, $zero, dash1
beq $t8, $a2, X1
O1: la $a0, output7
syscall
addi $s0, $s0, -1
bgtz $s0, hdash1
j nline1
X1: la $a0, output6
syscall
addi $s0, $s0, -1
bgtz $s0, hdash1
j nline1
dash1: la $a0, output8
syscall
addi $s0, $s0, -1
bgtz $s0, hdash1
j nline1
hdash1: la $a0, output5
syscall
j prin1
nline1: la $a0, output3
syscall
addi $s1, $s1, -1
addi $s0, $s0, 3
bgtz $s1, prin1
la $a0, output9
syscall
j cont
win2: li $v0, 4 #Same thing as print, except it also prints that player2 wins.
la $a1, grid
prin2: lw $t8, 0($a1)
addi $a1, $a1, 4
la $a0, output4
syscall
beq $t8, $zero, dash2
beq $t8, $a2, X2
O2: la $a0, output7
syscall
addi $s0, $s0, -1
bgtz $s0, hdash2
j nline
X2: la $a0, output6
syscall
addi $s0, $s0, -1
bgtz $s0, hdash2
j nline2
dash2: la $a0, output8
syscall
addi $s0, $s0, -1
bgtz $s0, hdash2
j nline2
hdash2: la $a0, output5
syscall
j prin2
nline2: la $a0, output3
syscall
addi $s1, $s1, -1
addi $s0, $s0, 3
bgtz $s1, prin2
la $a0, output10
syscall
j cont
draw: li $v0, 4 #Same thing as print, except it also prints that it was a draw.
la $a1, grid
prinw: lw $t8, 0($a1)
addi $a1, $a1, 4
la $a0, output4
syscall
beq $t8, $zero, dashw
beq $t8, $a2, Xw
Ow: la $a0, output7
syscall
addi $s0, $s0, -1
bgtz $s0, hdashw
j nlinew
Xw: la $a0, output6
syscall
addi $s0, $s0, -1
bgtz $s0, hdashw
j nlinew
dashw: la $a0, output8
syscall
addi $s0, $s0, -1
bgtz $s0, hdashw
j nlinew
hdashw: la $a0, output5
syscall
j prinw
nlinew: la $a0, output3
syscall
addi $s1, $s1, -1
addi $s0, $s0, 3
bgtz $s1, prinw
la $a0, output11
syscall
j cont