为什么在尝试打开游戏时出现错误?

时间:2019-04-26 20:36:59

标签: assembly x86-16

我在程序集8086中编写了一个小行星游戏。该程序集未显示任何错误,但是当我尝试运行该程序时,无论在实际硬件还是DOSBox上,它都不会运行。使用不同的代码给我一个错误。我无法在代码中发现任何错误。我什至尝试使用debug命令,并查看了向我显示错误消息的地址,但是我无法理解哪个代码在发生冲突或类似问题,但是通常使用db命令显示一个地址,但是我无法理解哪个变量错误。

编辑: 我正在Windows 95上对其进行测试和编码。在开始时它可以工作,但是在对代码进行一些编辑并添加新代码后,它停止了。我没有在代码中看到任何错误。但是我不是专家。我也尝试了一些不同的代码。 错误消息显示:“该程序执行了非法操作,将被终止。退出所有程序,然后重新启动计算机。如果该程序始终遇到问题,请单击“开始”按钮,然后选择“帮助”,“疑难解答”和“如果遇到问题,运行MS-DOS程序”。 在详细信息上,它显示“程序遇到未指定的异常”。 故障位置:1010:48FA 服务中断:无

在调试中,我得到了:

-u 1010:48FA


1010:48FA FB            STI                                    
1010:48FB 40            INC AX                                 
1010:48FC 7503          JNZ 4901                               
1010:48FE E8CC00        CALL    49CD                               
1010:4901 FEC9          DEC CL                                 
1010:4903 75EE          JNZ 48F3                               
1010:4905 B80D0A        MOV AX,0A0D                            
1010:4908 89877742      MOV [BX+4277],AX                       
1010:490C 43            INC BX                                 
1010:490D 43            INC BX                                 
1010:490E E8BC00        CALL    49CD                               
1010:4911 C3            RET                                    
1010:4912 33DB          XOR BX,BX                              
1010:4914 807C0600      CMP BYTE PTR [SI+06],00                
1010:4918 7511          JNZ 492B                               
-q

但是我不太理解我在调试中得到的这段代码。

这是我的游戏代码。我仍然是汇编语言的初学者。

org 100h

_STARTUP:
        call _DEFINE
        call _BACKGROUND
        jmp _MAIN

_MAIN:
        call _KEYCHECK
        call _PLAYER
        call _ASTEROID
        jmp _MAIN       ;Main loop

_BACKGROUND:
        mov ah,13h
        int 10h
        mov cx,2000d
        mov ah,09h
        mov bl,0Fh
        mov al,20h
        int 10h
        ret

_KEYCHECK:
        mov ah,01h
        int 16h
        cmp al,1Bh      ;ESC
        je _QUIT
        cmp al,48h      ;UP
        je _PLAYER.UP
        cmp al,50h      ;DOWN
        je _PLAYER.DOWN
        cmp al,4Bh      ;LEFT
        je _PLAYER.LEFT
        cmp al,4Dh      ;RIGHT
        je _PLAYER.RIGHT
        ret

_PLAYER:
        mov ah,02h
        mov dh,[Player.Y]
        mov dl,[Player.X]
        mov bl,1Fh
        int 10h
        mov cx,01h
        mov ah,09h
        mov dh,[Player.Y]
        mov dl,[Player.X]
        mov bl,1Fh
        int 10h
        ret

_PLAYER.UP:
        cmp [Player.Y],0d
        je _MAIN
        call _BACKGROUND
        sub [Player.Y],1d
        ret

_PLAYER.DOWN:
        cmp [Player.Y],24d
        je _MAIN
        call _BACKGROUND
        add [Player.Y],1d
        ret

_PLAYER.LEFT:
        cmp [Player.X],0d
        je _MAIN
        call _BACKGROUND
        sub [Player.X],1d
        ret

_PLAYER.RIGHT:
        cmp [Player.X],79d
        je _MAIN
        call _BACKGROUND
        add [Player.X],1d
        ret

_ASTEROID:
        call _RANDGEN
        mov ah,02h
        mov dh,[Asteroid1.Y]
        mov dl,[Asteroid1.X]
        mov bl,0xCF
        int 10h
        mov cx,01h
        mov ah,09h
        mov al,20h
        mov dh,[Asteroid2.Y]
        mov dl,[Asteroid2.X]
        mov bl,0xCF
        int 10h
        mov ah,02h
        mov dh,[Asteroid3.Y]
        mov dl,[Asteroid3.X]
        mov bl,0xCF
        int 10h
        mov cx,01h
        mov ah,09h
        mov al,20h
        mov dh,[Asteroid4.Y]
        mov dl,[Asteroid4.X]
        mov bl,0xCF
        int 10h
        mov ah,02h
        mov dh,[Asteroid5.Y]
        mov dl,[Asteroid5.X]
        mov bl,0xCF
        int 10h
        mov cx,01h
        mov ah,09h
        mov al,20h
        mov dh,[Asteroid6.Y]
        mov dl,[Asteroid6.X]
        mov bl,0xCF
        int 10h
        mov ah,02h
        mov dh,[Asteroid7.Y]
        mov dl,[Asteroid7.X]
        mov bl,0xCF
        int 10h
        mov cx,01h
        mov ah,09h
        mov al,20h
        mov dh,[Asteroid8.Y]
        mov dl,[Asteroid8.X]
        mov bl,0xCF
        int 10h
        mov ah,02h
        mov dh,[Asteroid9.Y]
        mov dl,[Asteroid9.X]
        mov bl,0xCF
        int 10h
        mov cx,01h
        mov ah,09h
        mov al,20h
        mov dh,[Asteroid10.Y]
        mov dl,[Asteroid10.X]
        mov bl,0xCF
        int 10h
        call _Asteroids.DOWN
        ret

_Asteroids.DOWN:
        add ch,[Asteroid1.Speed]
        add [Asteroid1.Y],ch
        xor ch,ch
        add ch,[Asteroid2.Speed]
        add [Asteroid2.Y],ch
        xor ch,ch
        add ch,[Asteroid3.Speed]
        add [Asteroid3.Y],ch
        xor ch,ch
        add ch,[Asteroid4.Speed]
        add [Asteroid4.Y],ch
        xor ch,ch
        add ch,[Asteroid5.Speed]
        add [Asteroid5.Y],ch
        xor ch,ch
        add ch,[Asteroid6.Speed]
        add [Asteroid6.Y],ch
        xor ch,ch
        add ch,[Asteroid7.Speed]
        add [Asteroid7.Y],ch
        xor ch,ch
        add ch,[Asteroid8.Speed]
        add [Asteroid8.Y],ch
        xor ch,ch
        add ch,[Asteroid9.Speed]
        add [Asteroid9.Y],ch
        xor ch,ch
        add ch,[Asteroid10.Speed]
        add [Asteroid10.Y],ch
        xor ch,ch
        ret

_RANDGEN:
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid1.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid2.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid3.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid4.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid5.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid6.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid7.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid8.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid9.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,79d
        jg _RANDGEN
        mov [Asteroid10.X],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,10d
        jg _RANDGEN
        xor al,al
        mov [Asteroid1.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid2.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid3.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid4.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid5.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid6.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid7.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid8.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid9.Speed],al
        mov ah,2Ch
        int 21h
        mov ax,dx
        mov ax,0Fh
        mov al,dl
        cmp al,0d
        je _RANDGEN
        cmp al,10d
        jg _RANDGEN
        mov [Asteroid10.Speed],al
        xor al,al
        ret

_DEFINE:

        Player.X db 40d ;Middle of consle
        Player.Y db 24d ;On bottom
        Asteroid1.X db 0d
        Asteroid1.Y db 0d
        Asteroid2.X db 0d
        Asteroid2.Y db 0d
        Asteroid3.X db 0d
        Asteroid3.Y db 0d
        Asteroid4.X db 0d
        Asteroid4.Y db 0d
        Asteroid5.X db 0d
        Asteroid5.Y db 0d
        Asteroid6.X db 0d
        Asteroid6.Y db 0d
        Asteroid7.X db 0d
        Asteroid7.Y db 0d
        Asteroid8.X db 0d
        Asteroid8.Y db 0d
        Asteroid9.X db 0d
        Asteroid9.Y db 0d
        Asteroid10.X db 0d
        Asteroid10.Y db 0d
        Asteroid1.Speed db 0d
        Asteroid2.Speed db 0d
        Asteroid3.Speed db 0d
        Asteroid4.Speed db 0d
        Asteroid5.Speed db 0d
        Asteroid6.Speed db 0d
        Asteroid7.Speed db 0d
        Asteroid8.Speed db 0d
        Asteroid9.Speed db 0d
        Asteroid10.Speed db 0d
        QuitPrompt db 'Quit game?(Y\N): $'
        ret

_QUIT:
        call _BACKGROUND
        mov ah,09h
        lea dx,[QuitPrompt]
        int 21h
        mov ah,00h
        int 16h
        cmp al,59h
        je _EXIT
        cmp al,79h
        je _EXIT
        cmp al,53h
        je _MAIN
        cmp al,73h
        je _MAIN
        jmp _QUIT

_EXIT:
        int 20h

0 个答案:

没有答案