-1

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
sasha199568
  • 1,143
  • 1
  • 11
  • 33

2 Answers2

0

You've got a pop instruction that doesn't correspond to a push:

    push ax
    ...
    pop ax
    inc al
    ...
    int 10h
    pop ax    <-- HERE
con_loop:

That last pop should be removed.

Michael
  • 57,169
  • 9
  • 80
  • 125
0

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:
Sep Roland
  • 33,889
  • 7
  • 43
  • 76