Search code examples
debuggingassemblydosbiostasm

a program works in Turbo Debugger when I step through it, but when I run it in TD or DOS it stops and Ctrl+Alt+Delete becomes the only option


The program was meant to display char table using BIOS int 10h, and it does it but only when I step through it in td. I thought that maybe while in debugger uninitialized registers contain zero, but while running they can possibly contain trash, therefore I put mov ax, 0003h instead of mov al, 3 and added xor dx, dx; but it does not works either.

.model tiny
.code
org 100h
start:
    mov ax, 0003h
    int 10h
    xor dx, dx
    mov si, 256
    mov ax, 0900h
    mov cx, 1
    xor bh, bh
    mov bl, 00011111b
cloop:
    int 10h
    push ax
    mov ah, 2
    inc dl
    int 10h
    mov ax, 0920h
    int 10h
    mov ah, 2
    inc dl
    int 10h
    pop ax
    inc al
    test al, 0Fh
    jnz con_loop
    mov ah, 2
    inc dh
    xor dl, dl
    int 10h
    pop ax
con_loop:
    dec si
    jnz cloop
    ret
end start

Solution

  • You need an additional PUSH. You should never trust BIOS/DOS/others to preserve AX even if it is not an output register.

     test    al,0Fh
     jnz     con_loop
     push    ax        ;You forgot this!!!
     mov     ah,2
     inc     dh
     xor     dl,dl
     int     10h
     pop     ax
    con_loop: