| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3859 人关注过本帖
标题:我这个程序为什么用MASM,TASM,NASM编译全都通不过。
只看楼主 加入收藏
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:7 
我这个程序为什么用MASM,TASM,NASM编译全都通不过。
我这个程序为什么用MASM,TASM,NASM编译全都通不过。

.model small

;----------------------------------------------------------------------
;数据段

   
    .data
;

x           db      0
y           db      0
;

win_time    equ    5
chess_state    dw    ?
chess_x        db    ?
chess_y        db    ?
help_x        db    ?
help_y        db    ?
nothing1    db    ?
nothing2    db    ?
nothing3    db    ?
chess_t        db    ?
person1     db      ?
person2     db      ?
person        db    ?
person_first    db    ?
jud        db    ?
;

person1_x    equ    6   
person1_y    equ    3
person1_x1    equ    0   
person1_y1    equ    0
person1_x2    equ    49   
person1_y2    equ    14
;

person2_x    equ    6
person2_y    equ    68
person2_x1    equ    0
person2_y1    equ    64
person2_x2    equ    49
person2_y2    equ    79
;

map_x        equ    6
map_y        equ    20
map_x_end    equ    44
map_y_end    equ    58
map_x1        equ    6
map_y1        equ    15
map_x2        equ    44
map_y2        equ    63
;

answer_x    equ    2
answer_y    equ    28
answer_x1    equ    0
answer_y1    equ    15
answer_x2    equ    5
answer_y2    equ    63
;

end_x        equ    47
end_y        equ    26
end_x1        equ    45
end_y1        equ    15
end_x2        equ    49
end_y2        equ    63
;

map_size    equ     19
map_over    db    ?
map         db      400 dup(0)
;

string_doing    db    ' Want To Peace ! ','$'
string_person1  db      ' P 1 : ','$'
string_person2  db      ' P 2 : ','$'
string_p1    db    ' Person 1 first . ','$'
string_p2    db    ' Person 2 first . ','$'
string_win1     db      ' Person 1 win. ','$'
string_win2     db      ' Person 2 win. ','$'
string_peace    db      ' PEACE !!! ','$'
string_wrong    db      ' You can`t put here.','$'
string_end    db    ' I Want To End The Game ! ','$'
string_lose1    db    ' P1 want to lose? ','$'
string_lose2    db    ' P2 want to lose? ','$'
string_final1    db    ' P1 win the final ! ','$'
string_final2    db    ' P2 win the final ! ','$'
string_thank    db    ' Thank You Very Much !','$'
;

heart        db    0,1,1,0,0,0,1,1,0
        db    1,0,0,1,0,1,0,0,1
        db    1,0,0,0,1,0,0,0,1
        db    0,1,0,0,0,0,0,1,0
        db    0,0,1,0,0,0,1,0,0
        db    0,0,0,1,0,1,0,0,0
        db    0,0,0,0,1,0,0,0,0
heart_size1    db    7
heart_size2    db    9
;


;----------------------------------------------------------------------
;清屏程序,gao_color为颜色,x1,y1,x2,y2为坐标


   
gao_clear_screen    macro    gao_color,x1,y1,x2,y2

        push    ax
        push    bx
        push    cx
        push    dx
;

        mov     ah,6
        mov     al,0
        mov     bh,gao_color
        mov     ch,x1
        mov     cl,y1
        mov     dh,x2
        mov     dl,y2
        int     10h
;

        pop     dx
        pop     cx
        pop     bx
        pop     ax

endm



;----------------------------------------------------------------------
;画出当前状态



;辅助函数 1 , 判断x,y坐标在那个区域

gao_judge    macro    jud,x,y,x1,y1,x2,y2
    local    gao_judge_exit
;

    mov    jud,0
    cmp    x,x1
    jl    gao_judge_exit
    cmp    x,x2
    jg    gao_judge_exit
    cmp    y,y1
    jl    gao_judge_exit
    cmp    y,y2
    jg    gao_judge_exit
;

    mov    jud,1
;

gao_judge_exit:

;

endm



;辅助函数 2 , 输出相应语句的位置

gao_print_string    macro    string,x,y,gao_color
   
    push    ax
    push    bx
    push    cx
    push    dx
;

    mov     dh,x
    mov    dl,y
    mov    bx,offset string
    mov    al,[bx]
    .while    al!='$'
;
        push    bx
;
        mov    bh,0
        mov    ah,2
        int     10h
;
        mov    bl,gao_color
        mov    bh,0
        mov    cx,1
        mov    ah,9
        int    10h
;
        pop    bx
        inc    bx
        inc    dl
        mov    al,[bx]
    .endw
   
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax
   
endm



;辅助函数 3 - 1 , 打印当前棋盘一奇数行

gao_print_map_line1    macro    x,y,gao_color

    local    gao_print_map_line1_repeat
        
    push    ax
    push    bx
    push    cx
    push    dx

;

    mov    dh,x
    mov    dl,y
    mov    bh,0
    mov    ah,2
    int    10h

;

    mov    bh,0
    mov    ah,9
    mov    al,2bh
    mov    bl,gao_color
    mov    cx,1
    int    10h
    inc    dl
    mov    cl,map_size
    mov    ch,0

;

gao_print_map_line1_repeat:

    push    cx
    mov    bh,0
    mov    ah,2
    int    10h

;

    mov    al,2dh
    mov    bh,0
    mov    ah,9
    mov    cx,1
    mov    bl,gao_color
    int    10h
    inc    dl

;

    mov    bh,0
    mov    ah,2
    int    10h

;

    mov    al,2bh
    mov    bh,0
    mov    ah,9
    mov    bl,gao_color
    int    10h
    inc    dl
    pop    cx

;

    loop     gao_print_map_line1_repeat   

;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm
2016-07-22 11:11
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
;辅助函数 3 - 2 , 打印当前棋盘一偶数行
gao_print_map_line2    macro    p,x,y,gao_color

    local    gao_print_map_line2_repeat

;
        
    push    ax
    push    bx
    push    cx
    push    dx
    push    ax
;
   
    mov    dh,x
    mov    dl,y
    mov    ah,2
    mov    bh,0
    int    10h
;

    mov    ah,9
    mov    al,7ch
    mov    bh,0h
    mov    bl,gao_color
    mov    cx,1
    int    10h
;
    pop    ax
    mov    ah,0
    mov    bx,map_size
    push    dx
    mul    bx
    pop    dx
    mov    cx,map_size

;
        
gao_print_map_line2_repeat:
   
    push    cx
    inc    dl
    mov    bx,offset map
    add    bx,ax
;
    push    ax
    push    bx
    mov    ah,2
    mov    bh,0
    int    10h
;
    pop    bx
    mov    bl,[bx]
    .if    bl==0
        mov    al,20h
    .elseif    bl==1
        mov    al,1h
    .else
        mov    al,2h
    .endif
;
    mov    ah,9
    mov    bh,0
    mov    bl,gao_color
    mov    cx,1
    int    10h
;   
    inc    dl
    mov    ah,2
    mov    bh,0
    int    10h
;
    mov    ah,9
    mov    al,7ch
    mov    bh,0
    mov    bl,gao_color
    mov    cx,1
    int    10h
;
    pop    ax
    inc    ax        
    pop    cx
    loop    gao_print_map_line2_repeat

;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm



;辅助函数 3 , 打印当前棋盘状态

gao_print_map    macro    gao_color,x,y
        
    push    ax
    push    bx
    push    cx
    push    dx
;
   
    gao_print_map_line1    x,y,gao_color
    mov    al,0h
    .while    al!=map_size
        mov    bl,al
        add    bl,al
        add    bl,x
        add    bl,1
        gao_print_map_line2    al,bl,y,gao_color
        add    bl,1
        gao_print_map_line1    bl,y,gao_color
        inc    al
    .endw
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm



;辅助函数 4 - 1 , 将现在字符改变底色
gao_print_map_point_change    macro    x,y,gao_color

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    dh,x
    mov    dl,y
;
    mov    bh,0
    mov    ah,2
    int    10h
;
    mov    bh,0
    mov    ah,8h
    int    10h
;
    mov    bh,0
    mov    bl,gao_color
    mov    ah,9
    mov    cx,1
    int    10h
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm
;辅助函数 4 , 如果当前操作的是棋盘 , 将棋盘相应位置的颜色变化为 0e7H 方式

gao_print_map_point    macro    x,y,gao_color
   
    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    dh,x
    mov    dl,y
;
    dec    dh
    dec    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dh
    mov    dl,y
    dec    dl   
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dh
    mov    dl,y
    dec    dl   
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;
    inc    dl
    gao_print_map_point_change    dh,dl,gao_color
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm

;打印当前比分
gao_printf_num    macro    x,y,gao_color,num
   
    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    dh,x
    mov    dl,y
    add    dl,7
    mov    bh,0
    mov    ah,2
    int    10h
    mov    al,num

;

    add    al,30h
    mov    ah,9h
    mov    bl,gao_color
    mov    cx,1
    int     10h   
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-07-22 11:11
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
;辅助函数都不知道多少号了
gao_print_heart    macro    x,y,gao_color,num,word
        
    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    dh,x
    mov    dl,y
    inc    dh
    inc    dh
    mov    bh,0
    mov    ah,2
    int    10h
;
    mov    bl,num
    mov    ch,0
    mov    cl,0
;

    .while    bl>0
        dec    bl
        push    bx
        .while    ch<heart_size1
            .while    cl<heart_size2
            
                push    ax
                push    cx
                mov    bh,0
                mov    ah,2
                int    10h

                mov    al,ch
                mov    ah,0
                mov    bl,heart_size2
                mul    bl
                mov    ch,0
                add    ax,cx
                mov    bx,offset heart
                add    bx,ax
                mov    bl,[bx]

                .if    bl==1
                    mov    al,word
                .else   
                    mov    al,20h
                .endif
            
                mov    ah,9h
                mov    bl,gao_color
                mov    bh,0
                mov    cx,1
                int    10h
        
                pop    cx
                pop    ax
               
                inc    cl
                inc    dl
            
            .endw
            
            inc    dh
            mov    dl,y
            inc    ch
            mov    cl,0
        .endw
        inc    dh
        mov    dl,y
        mov    ch,0
        mov    cl,0
        pop    bx
    .endw

;
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm
   
;打印函数
gao_print    macro
   
    push    ax
    push    bx
    push    cx
    push    dx
;

    gao_judge    [jud],[x],[y],person1_x1,person1_y1,person1_x2,person1_y2
    .if     [jud]==1
        gao_clear_screen    90h,person1_x1,person1_y1,person1_x2,person1_y2
        gao_print_string    string_person1,person1_x,person1_y,90h   
        gao_printf_num        person1_x,person1_y,90h,[person1]
        gao_print_heart        person1_x,person1_y,9ch,[person1],3h
    .elseif    [person]==1
        gao_clear_screen    90h,person1_x1,person1_y1,person1_x2,person1_y2
        gao_print_string    string_person1,person1_x,person1_y,90h   
        gao_printf_num        person1_x,person1_y,90h,[person1]
        gao_print_heart        person1_x,person1_y,9ch,[person1],3h
    .else
        gao_clear_screen    10h,person1_x1,person1_y1,person1_x2,person1_y2
        gao_print_string    string_person1,person1_x,person1_y,10h
        gao_printf_num        person1_x,person1_y,10h,[person1]
        gao_print_heart        person1_x,person1_y,14h,[person1],3h
    .endif   
;
   
    gao_judge    [jud],[x],[y],person2_x1,person2_y1,person2_x2,person2_y2
    .if     [jud]==1
        gao_clear_screen    0b0h,person2_x1,person2_y1,person2_x2,person2_y2
        gao_print_string    string_person2,person2_x,person2_y,0b0h
        gao_printf_num        person2_x,person2_y,0b0h,[person2]
        gao_print_heart        person2_x,person2_y,0bch,[person2],5h
    .elseif    [person]==2
        gao_clear_screen    0b0h,person2_x1,person2_y1,person2_x2,person2_y2
        gao_print_string    string_person2,person2_x,person2_y,0b0h
        gao_printf_num        person2_x,person2_y,0b0h,[person2]
        gao_print_heart        person2_x,person2_y,0bch,[person2],5h
    .else
        gao_clear_screen    30h,person2_x1,person2_y1,person2_x2,person2_y2
        gao_print_string    string_person2,person2_x,person2_y,30h
        gao_printf_num        person2_x,person2_y,30h,[person2]
        gao_print_heart        person2_x,person2_y,34h,[person2],5h
    .endif        
;

    gao_judge    [jud],[x],[y],map_x1,map_y1,map_x2,map_y2
    .if    [jud]==1   
        gao_clear_screen    0d0h,map_x1,map_y1,map_x2,map_y2
        gao_print_map        0d0h,map_x,map_y
    .else
        gao_clear_screen    050h,map_x1,map_y1,map_x2,map_y2
        gao_print_map        050h,map_x,map_y   
    .endif   
;

    gao_judge    [jud],[x],[y],answer_x1,answer_y1,answer_x2,answer_y2
    .if     [jud]==1
        gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
        gao_print_string    string_doing,answer_x,answer_y,0c0h
    .else
        .if    [map_over]==5
            gao_clear_screen    40h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_doing,answer_x,answer_y,40h   
        .elseif    [map_over]==1
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_win1,answer_x,answer_y,0c0h
        .elseif    [map_over]==2
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_win2,answer_x,answer_y,0c0h
        .elseif    [map_over]==3
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_peace,answer_x,answer_y,0c0h
        .elseif    [map_over]==4
            gao_clear_screen    40h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_wrong,answer_x,answer_y,40h
        .elseif    [map_over]==6
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_p1,answer_x,answer_y,0c0h
        .elseif    [map_over]==7
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_p2,answer_x,answer_y,0c0h
        .endif
;

        .if    [y]<=person1_y2
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_lose1,answer_x,answer_y,0c0h
        .elseif    [y]>=person2_y1
            gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
            gao_print_string    string_lose2,answer_x,answer_y,0c0h
        .endif
    .endif   
;

    gao_judge    [jud],[x],[y],end_x1,end_y1,end_x2,end_y2
    .if     [jud]==1
        gao_clear_screen    0a0h,end_x1,end_y1,end_x2,end_y2
        gao_print_string    string_end,end_x,end_y,0a0h
    .else
        gao_clear_screen    20h,end_x1,end_y1,end_x2,end_y2
        gao_print_string    string_end,end_x,end_y,20h
    .endif        
;

    gao_print_map_point    [x],[y],0e0h
;


    .if    [person1]==win_time        
        gao_clear_screen    90h,person1_x1,person1_y1,person1_x2,person1_y2   
        gao_print_string    string_person1,person1_x,person1_y,90h   
        gao_printf_num        person1_x,person1_y,90h,[person1]
        gao_print_heart        person1_x,person1_y,9ch,[person1],3h   
;
        gao_clear_screen    0b0h,person2_x1,person2_y1,person2_x2,person2_y2
        gao_print_string    string_person2,person2_x,person2_y,0b0h
        gao_printf_num        person2_x,person2_y,0b0h,[person2]
        gao_print_heart        person2_x,person2_y,0b4h,[person2],5h   
;   
        gao_clear_screen    0d0h,map_x1,map_y1,map_x2,map_y2
        gao_print_map        0d0h,map_x,map_y
;
        
        gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
        gao_print_string    string_final1,answer_x,answer_y,0c0h
;        
        gao_clear_screen    0a0h,end_x1,end_y1,end_x2,end_y2
        gao_print_string    string_thank,end_x,end_y,0a0h
;
        mov    bh,0
        mov    ah,0h
        int    16h
        gao_exit
;
    .elseif    [person2]==win_time
        gao_clear_screen    90h,person1_x1,person1_y1,person1_x2,person1_y2   
        gao_print_string    string_person1,person1_x,person1_y,90h   
        gao_printf_num        person1_x,person1_y,90h,[person1]   
        gao_print_heart        person1_x,person1_y,94h,[person1],3h
;
        gao_clear_screen    0b0h,person2_x1,person2_y1,person2_x2,person2_y2
        gao_print_string    string_person2,person2_x,person2_y,0b0h
        gao_printf_num        person2_x,person2_y,0b0h,[person2]
        gao_print_heart        person2_x,person2_y,0bch,[person2],5h        
;   
        gao_clear_screen    0d0h,map_x1,map_y1,map_x2,map_y2
        gao_print_map        0d0h,map_x,map_y
;
        
        gao_clear_screen    0c0h,answer_x1,answer_y1,answer_x2,answer_y2
        gao_print_string    string_final2,answer_x,answer_y,0c0h
;        
        gao_clear_screen    0a0h,end_x1,end_y1,end_x2,end_y2
        gao_print_string    string_thank,end_x,end_y,0a0h
;   
        mov    bh,0
        mov    ah,0h
        int    16h
        gao_exit
;
    .endif
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-07-22 11:11
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
;----------------------------------------------------------------------
;每局的开始预处理


gao_build    macro
   
    local    gao_build_repeat
;

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    [x],map_x
    mov    [y],map_y
    inc    [x]
    inc    [y]
    mov     al,18
    add    [x],al
    add    [y],al
    mov    ax,map_size
    mov    bx,map_size
    mul    bx
    mov    cx,ax
    dec    cx
;

gao_build_repeat:
    mov    ax,cx
    dec    ax
    mov    bx,offset map
    add    bx,ax
    mov    [bx],0000h
    loop    gao_build_repeat
;

    .if    [map_over]==1
        add     [person1],1
    .elseif    [map_over]==2
        add    [person2],1
    .endif
;
   
    .if    [person_first]==2
        mov    [person_first],1
        mov    [person],1
        mov    [map_over],6
    .else
        mov    [person_first],2
        mov    [person],2
        mov    [map_over],7
    .endif
   
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm



;----------------------------------------------------------------------
;将两个人的胜利局数都清零,并且做一些简单初始化



gao_init    macro   

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    ax,@data
    mov    ds,ax
    mov    [person1],0
    mov    [person2],0
    mov    [person_first],2
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm



;----------------------------------------------------------------------
;结束程序



gao_exit    macro

    push    ax
    push    bx
    push    cx
    push    dx
;
    gao_clear_screen    07h,0,0,49,79
    mov    ah,4ch
    int    21h
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm



;----------------------------------------------------------------------
;输入函数


;辅助函数 1 , 坐标转换
gao_give_change    macro    state,x,y,xx,yy

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    al,x
    sub    al,map_x
    mov    ah,0
    mov    bl,2
    div    bl
    mov    xx,al
    mov    ah,0
    mov    bl,map_size
    mul    bl
;
    mov    cx,ax

;
    mov    al,y
    mov    ah,0
    sub    al,map_y
    mov    bl,2
    div    bl
    mov    yy,al
    mov    ah,0
    add    cx,ax        
    mov    state,cx

;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm


;辅助函数 2 - 1 , 坐标转换
gao_judge_over_change macro    xx,x,y
   
    push    ax
    push    bx
    push    cx
    push    dx
;   

    mov    bl,map_size
    mov    al,x
    mov    ah,0
    mul    bl
    mov    bl,y
    mov    bh,0
    add    ax,bx
    mov    xx,ax

;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm


;辅助函数 2 - 2 , 计算连子数量
gao_judge_over_add macro    t,x,y,change_x,change_y,person
   
    local    gao_judge_over_add_end
;

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    dl,map_size
    dec    dl
;

    .while    [nothing1]==0

        .if    x==0
            .break    .if    change_x==0
        .endif

        .if    y==0
            .break    .if    change_y==0
        .endif

        .if    x==dl
            .break    .if    change_x==1
        .endif

        .if    y==dl
            .break    .if    change_y==1
        .endif

        .if    change_x==1
            inc    x
        .elseif    change_x==0   
            dec    x
        .endif   

        .if    change_y==1
            inc    y
        .elseif    change_y==0   
            dec    y
        .endif   

        gao_judge_over_change    [chess_state],x,y
   
        mov    bx,offset map
        mov    ax,[chess_state]
        add    bx,ax
        mov    bl,[bx]
   
        .break    .if    bl!=person   
        inc    t
    .endw

   
gao_judge_over_add_end:
;

    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm


其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-07-22 11:12
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
;辅助函数 2 , 判断是否完满
gao_judge_over    macro    jud,x,y,person

    local    gao_judge_over_end
;

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov    [nothing1],0
    mov    [nothing2],1
    mov    [nothing3],2
;

    mov    [chess_t],1
    mov    ah,x
    mov    al,y
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing3],[nothing1],person
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing3],[nothing2],person
    .if    [chess_t]>=5
        mov    jud,2   
        jmp    gao_judge_over_end
    .endif
;

    mov    [chess_t],1
    mov    ah,x
    mov    al,y
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing1],[nothing3],person
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing2],[nothing3],person
    .if    [chess_t]>=5
        mov    jud,2   
        jmp    gao_judge_over_end
    .endif
;


    mov    [chess_t],1
    mov    ah,x
    mov    al,y
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing1],[nothing1],person
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing2],[nothing2],person
    .if    [chess_t]>=5
        mov    jud,2   
        jmp    gao_judge_over_end
    .endif
;


    mov    [chess_t],1
    mov    ah,x
    mov    al,y
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing1],[nothing2],person
    mov    [help_x],ah
    mov    [help_y],al
    gao_judge_over_add    [chess_t],[help_x],[help_y],[nothing2],[nothing1],person
    .if    [chess_t]>=5
        mov    jud,2   
        jmp    gao_judge_over_end
    .endif
;



gao_judge_over_end:   
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm

   
;辅助函数 3 , 判断复杂情况
gao_give_judge    macro    jud,x,y,person

    local    gao_give_judge_end
;

    push    ax
    push    bx
    push    cx
    push    dx
;

    mov        bx,offset map
    gao_give_change    [chess_state],x,y,[chess_x],[chess_y]
    mov        ax,[chess_state]
    add        bx,ax
    mov        al,[bx]
    .if    al!=0
        mov    jud,1
        jmp    gao_give_judge_end
    .endif
;

    mov    al,[person]
    mov    [bx],al

    mov    jud,0
    gao_judge_over    jud,[chess_x],[chess_y],[person]
    .if    jud!=0
        mov    jud,2
        jmp    gao_give_judge_end
    .endif
;

gao_give_judge_end:
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm

   

;辅助函数 4 , 判断能不能放子

gao_give    macro    jud,x,y,person
    local    gao_give_end
;

    push    ax
    push    bx
    push    cx
    push    dx
;
   
    mov    jud,0   
    gao_judge    jud,x,y,map_x1,map_y1,map_x_end,map_y
;        
        
    .if    jud==1
        mov    [map_over],4
        jmp    gao_give_end
    .endif
;

    mov    jud,0                    
    gao_judge    [jud],x,y,map_x,map_y_end,map_x2,map_y2
;        
        
    .if    jud==1
        mov    [map_over],4
        jmp    gao_give_end
    .endif
;
   
    mov    jud,0
    gao_give_judge    jud,x,y,person
;

    .if    jud==1

        mov    [map_over],4
        jmp    gao_give_end

    .elseif    jud==2
   
        mov    bl,person
        mov    [map_over],bl
        jmp    gao_give_end

    .else
        
        mov    [map_over],5
        .if    person==1
            mov    person,2
        .else
            mov    person,1
        .endif

    .endif   
;


gao_give_end:
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm
   


;主输入函数

gao_scanf    macro    x,y
   
    local    gao_scanf_end
;

    push    ax
    push    bx
    push    cx
    push    dx
;
   
    mov    dh,x
    mov    dl,y
    mov    ah,2
    mov    bh,0
    int    10h
;

    mov    ah,0h
    int    16h
    mov    bl,2
;

    .if    ah==4bh
        sub    y,bl
    .elseif ah==4dh
        add    y,bl
    .elseif    ah==48h
        sub    x,bl
    .elseif    ah==50h
        add    x,bl
    .elseif    ah==01h
        gao_exit
;
   
    .elseif    (ah==1ch)||(ah==39h)
;

        gao_judge        [jud],x,y,person1_x1,person1_y1,person1_x2,person1_y2
            .if    [jud]==1
                mov    [map_over],2
            .endif
;
        gao_judge        [jud],x,y,person2_x1,person2_y1,person2_x2,person2_y2
            .if        [jud]==1
                mov    [map_over],1
            .endif
;
        gao_judge        [jud],x,y,answer_x1,answer_y1,answer_x2,answer_y2
            .if    [jud]==1
                mov    [map_over],3
            .endif
;
        gao_judge        [jud],x,y,end_x1,end_y1,end_x2,end_y2
            .if    [jud]==1
                    gao_exit
            .endif
;
        gao_judge        [jud],x,y,map_x1,map_y1,map_x2,map_y2
            
            .if    [jud]==1               
                gao_give    [jud],x,y,[person]
            .endif
;


    .endif
;
gao_scanf_end:
;

    mov    bl,2

    .if    x<2
        add    x,bl
    .endif   

    .if    y<2
        add    y,bl
    .endif

    .if    x>47
        sub    x,bl
    .endif

    .if    y>77
        sub    y,bl
    .endif
;
   
    pop    dx
    pop    cx
    pop    bx
    pop    ax

endm
   

   



;----------------------------------------------------------------------
;主函数   




    .code
main    proc     far
   
    gao_init
;

    mov    cx,0
        .while cx==0
        
        gao_build
        gao_print
;
        .while    [map_over]>3
            gao_scanf [x],[y]
            gao_print
        .endw
    .endw
;
   

    gao_exit
;

main    endp
        end     main   
   


;----------------------------------------------------------------------

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-07-22 11:12
Valenciax
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:11
帖 子:340
专家分:2482
注 册:2016-5-15
收藏
得分:20 
这是dos版的五子棋?

修正这一句
gao_build_repeat: 之下第五句
    mov  [bx],0000h
    改为
    mov   word ptr  [bx],0000h
才可以通过编译,且须用masm 6.x(我用6.15)  , ml xxxx.asm 即可
图片附件: 游客没有浏览图片的权限,请 登录注册


若是楼主写的,那是挺不错了,但代码好大部份用宏,改为invoke的话,比宏要省空间、容易维护和侦错;还有就是介面和操作不太理想,变色的设定不太讨好……这些应该不难修正。



五子棋我也写过,那是win32的汇编。

图片附件: 游客没有浏览图片的权限,请 登录注册


[此贴子已经被作者于2016-7-22 16:53编辑过]

2016-07-22 15:51
zhulei1978
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
不是我写的,从网上下的,想下来学习一下,压缩包里有可执行文件,但是编译通不过,原来是我的MASM版本低了

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-07-22 19:08
Alar30
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:10
帖 子:988
专家分:1627
注 册:2009-9-8
收藏
得分:0 
MASM版本的问题吧。。
2016-08-22 11:53
快速回复:我这个程序为什么用MASM,TASM,NASM编译全都通不过。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032700 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved