Thread: help....

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    2
    Rep Power
    0

    help....


    got this code somewhere and it seems like its not consistent in who should win...can someone help me fix this....thanks

    section .data
    nmbr dw 0
    info1 db "**A project fulfillment in CMSC 131:X-O-X implementation!**",0xa
    game1 db "player_",0xa
    game2 db "enter (0-8): ",0xa
    game3 db "player_ ",0xa
    game4 db "The winner is ",0xa
    displ db "........."
    null db 0xa
    player times 2 dw 0
    section .text
    global asm_main

    asm_main:

    mov eax,0x4
    mov ebx,0x1
    mov ecx,info1
    mov edx,game1-info1
    int 0x80
    push 0x1
    round:
    pop edx
    inc edx
    cmp edx,0x1
    jng dont_rotate_players
    mov edx, 0x0
    dont_rotate_players:
    push edx
    add edx,0x30
    mov [game1+0x06],dl
    mov ax,0x4
    mov bx,0x1
    mov ecx,game1
    mov dx,game2-game1
    int 0x80
    mov ecx,0x03
    write_line:
    push ecx
    mov eax,0x03
    sub eax, ecx
    mov ebx, 0x03
    mul bl
    mov ecx,displ
    add ecx,eax
    mov ax,0x04
    mov bx,0x01
    mov edx,0x03
    int 0x80
    mov ax,0x04
    mov bx,0x01
    mov ecx,null
    mov edx,0x01
    int 0x80
    pop ecx
    loop write_line
    move:
    mov ax,0x4
    mov bx,0x1
    mov ecx,game2
    mov dx,game3-game2
    int 0x80
    mov ax,0x03
    mov bx,0x0
    mov ecx,nmbr
    mov dx,2
    int 0x80
    mov cx, [nmbr]
    sub cx, 0x30
    mov ax, 0001b
    shl ax, cl
    pop edx
    push edx
    mov bx, [player+edx]
    mov cx, bx
    and cx, ax
    cmp cx, ax
    je move
    pop edx
    push edx
    inc edx
    cmp edx,0x1
    jng x1_is_ok
    mov edx, 0x0
    x1_is_ok:
    mov cx, [player+edx]
    and cx, ax
    cmp cx, ax
    je move
    pop edx
    push edx
    or bx, ax
    mov [player+edx], bx
    mov ecx, 0x0
    mov cl, [nmbr]
    mov bl, cl
    sub cl, 0x30
    mov eax, displ
    add eax, ecx
    pop edx
    push edx
    cmp edx, 0x0
    je player_1_is_x
    mov byte [eax], "o"
    jmp verify
    player_1_is_x:
    mov byte [eax], "x"
    verify:
    mov ecx, 0x3
    mov eax, 0111b
    horiz:
    mov bx, [player+edx]
    and bx, ax
    cmp bx, ax
    je endgame
    shl ax, 0x3
    loop horiz
    mov ecx, 0x3
    mov ax, 01001001b
    vertic:
    mov bx, [player+edx]
    and bx, ax
    cmp bx, ax
    je endgame
    shl ax, 0x1
    loop vertic
    mov ax, 00100001001b
    mov bx, [player+edx]
    and bx, ax
    cmp bx, ax
    je endgame
    mov ax, 01010100b
    mov bx, [player+edx]
    and bx, ax
    cmp bx, ax
    je endgame
    jmp round
    endgame:
    mov ax,0x4
    mov bx,0x1
    mov ecx,game4
    mov dx,displ-game4
    int 0x80
    mov ax,0x4
    mov bx,0x1
    mov ecx,game1
    mov dx,game2-game1
    int 0x80
    mov ax,0x4
    mov bx,0x1
    mov ecx,game2
    mov dx,game3-game2
    mov ax,0x1
    mov bx,0x0
    int 0x80

  2. #2
  3. Just another guy
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2003
    Location
    Wisconsin
    Posts
    2,953
    Rep Power
    262
    You really need to be more specific in your question, and post only the relevant code. Also, your subject is not acceptable. Read "how to post a question".
    --Dave--

    U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM=

    My hobby: collecting US coins

IMN logo majestic logo threadwatch logo seochat tools logo