assume cs:code
data segment
db 10 dup(0)
data ends
code segment
start:
mov ax,12666
mov bx,data
mov ds,bx
mov di,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
dtoc:
push ax
push cx
GetNumber:
mov cx,10
call divdw
add cx,30h
mov ds:,cl
mov cx,ax
jcxz OK
inc di
jmp short GetNumber
OK:
pop cx
ret                        ; faild
divdw: ;div number dx=hight number ax=low number
push bx
push ax
mov ax,dx
sub dx,dx
div cx
mov bx,ax
pop ax
div cx
mov cx,dx
mov dx,bx
pop bx
ret
show_str: ;show string function
push si
push ax
push es
push di
push bx
push cx
mov ax,0
mov al,10
mul dh
mov bx,0b800h
add bl,al
add bl,dl
mov es,bx
mov di,0
show:
pop dx ;use cx show color
push dx
mov cl,0
mov ch,ds:
jcxz endShow
mov bl,ds:
mov es:,bl
mov es:,dx
inc si
add di,2
jmp short show
endShow:
pop cx
pop bx
pop di
pop es
pop ax
pop si
ret
code ends
end start

I want show a data in 80*25 Character mode!
but !a problem!
when I use Debug to debug this program
I find out that ret instruction is faild!!
the following code is my debug code:

AX=0000  BX=13DB  CX=0000  DX=0000  SP=FFFA  BP=0000  SI=0000  DI=0004
DS=13DB  ES=13CB  SS=13DB  CS=13DC  IP=002B  NV UP EI PL NZ NA PO NC
13DC:002B E303          JCXZ    0030
-t

AX=0000  BX=13DB  CX=0000  DX=0000  SP=FFFA  BP=0000  SI=0000  DI=0004
DS=13DB  ES=13CB  SS=13DB  CS=13DC  IP=0030  NV UP EI PL NZ NA PO NC
13DC:0030 59            POP    CX
-t

AX=0000  BX=13DB  CX=008C  DX=0000  SP=FFFC  BP=0000  SI=0000  DI=0004
DS=13DB  ES=13CB  SS=13DB  CS=13DC  IP=0031  NV UP EI PL NZ NA PO NC
13DC:0031 C3            RET
-t

AX=0000  BX=13DB  CX=008C  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0004
DS=13DB  ES=13CB  SS=13DB  CS=13DC  IP=317A  NV UP EI PL NZ NA PO NC
13DC:317A 0000          ADD    ,AL                        DS:13DB=00
-t

AX=0000  BX=13DB  CX=008C  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0004
DS=13DB  ES=13CB  SS=13DB  CS=13DC  IP=317C  NV UP EI PL ZR NA PE NC
13DC:317C 0000          ADD    ,AL                        DS:13DB=00
-


why ret return faild!!!
I think ret Should be return to "mov dh,8" here!!
but......
Posted on 2008-12-03 21:50:47 by dapro
Make sure your POPs match your PUSHes
Posted on 2008-12-03 22:32:31 by sinsi
Yeah....you are right..
I'm so careless.... :sad: :sad:
thank you very much :)
Posted on 2008-12-04 01:49:03 by dapro