title: Tic Tac Toe Game in Assembly Language
body: <p>I am trying to make Tic Tac Toe in Assembly Language How can I switch Players?
  Here is my code.</p>
  
  <pre><code>.686 
  .MODEL flat, stdcall
  .STACK
  INCLUDE Irvine32.inc
  
  .data
  tic BYTE "TIC TAC TOE GAME"
  player BYTE "PLAYER 1 (X) : PLAYER 2 (O)"
  myarray1 BYTE '1' , ' ' , '|' , ' ' , '2' , ' ' , '|' ,' ' ,'3'
  myarray2 BYTE '4' , ' ' , '|' , ' ' , '5' , ' ' , '|' ,' ' ,'6'
  myarray3 BYTE '7',  ' ' , '|' , ' ' , '8' , ' ' , '|' ,' ' ,'9'
  choise BYTE 'X','O'
  player1 BYTE "Player 1 select your position ",0
  player2 BYTE "Player 2 select your position ",0
  info byte ?
  turn BYTE 2
  
  .code 
  main PROC
  mov bl,1
  mov ecx,9
  L13:
  push ecx        
  call BOARD
  call GAME
  pop ecx
  call clrscr         
  loop L13
  
  BOARD proc
  
  
  ;TO DISPLAY TIC TAC TOE GAME
  mov ecx, LENGTHOF tic
  mov esi,Offset tic
  L0:
  mov al,[esi]
  call writechar
  inc esi
  loop l0
  call crlf
  call crlf
  
  
  ;TO DISPLAY PLAYER INFO
  mov ecx,LENGTHOF player
  mov esi,OFFSET player
  l6:
  mov al,[esi]
  call writechar
  inc esi
  loop L6
  call crlf
  call crlf
  
  
  ;LOOP TO DISPLAY FIRST ARRAY
  mov ecx,LENGTHOF myarray1
  mov esi,OFFSET myarray1
  L1:
  mov al,[esi]
  call writechar
  inc esi
  loop L1
  call crlf
  
  ;LOOP TO DISPLAY SECOND ARRAY
  mov ecx,LENGTHOF myarray2
  mov esi,OFFSET myarray2
  L2:
  mov al,[esi]
  call writechar
  inc esi
  loop L2
  call crlf
  
  ;LOOP TO DISPLAY THIRD ARRAY
  mov ecx,LENGTHOF myarray3
  mov esi,OFFSET myarray3
  L3:
  mov al,[esi]
  call writechar
  inc esi
  loop L3
  call crlf
  call crlf 
  
  ret
  BOARD endp
  
  GAME proc
  mov ecx,LENGTHOF player1
  mov esi,OFFSET player1
  L4:
  mov al,[esi]
  call writechar
  inc esi
  loop L4
  call crlf
  
  
  call readint
  mov info,al
  
  cmp al,1
  je one
  
  cmp al,2
  je two
  
  cmp al,3
  je three
  
  cmp al,4
  je four
  
  cmp al,5
  je five
  
  cmp al,6
  je six
  
  cmp al,7
  je seven
  
  cmp al,8
  je eight
  
  cmp al,9
  je nine
  
  one:
  mov al,choise
  xchg al,[myarray1]
  ret
  
  two:
  mov al,choise
  xchg al,[myarray1+4]
  ret
  
  three:
  mov al,choise
  xchg al,[myarray1+8]
  ret
  
  four:
  mov al,choise
  xchg al,[myarray2]
  ret
  
  five:
  mov al,choise
  xchg al,[myarray2+4]
  ret
  
  six:
  mov al,choise
  xchg al,[myarray2+8]
  ret
  
  seven:
  mov al,choise
  xchg al,[myarray3]
  ret
  
  eight:
  mov al,choise
  xchg al,[myarray3+4]
  ret
  
  nine:
  mov al,choise
  xchg al,[myarray3+8]
  ret
  
  
  GAME endp
  
  exit
  main endp
  end main
  </code></pre>