xu123456 发表于 2018-1-17 19:27:53

实验十.编写子程序(3)数值显示


        代码如下:
assume cs:code

data segment
        db 10 dup(0)
data ends

code segment
start:        mov ax,12667 ;12666 = 317ah
                mov bx,data
                mov ds,bx
                mov si,1 ;使得12666中1前边为0
                call dtoc
               
                mov dh,8
                mov dl,3
                mov cl,2
                call show_str
               
                mov ax,4c00h
                int 21h
               
               
               
dtoc:       
                mov dx,0
                mov bx,10
        s:        mov cx,ax
                divbx
                add dl,30h
                mov ,dl
                mov dl,0
                jcxz return
               
                inc si               

                loop s
               
return: ret
       
show_str:
                dec si
                mov ax,0b800h
                mov es,ax
                mov ch,0
               
                mov bx,cx;sava cx value to bx
               
                mov al,0a0h
                mul dh      ;address of row in ax
                add dl,dl   ;address of column in dl
                mov dh,0
                add ax,dx
                mov bp,ax
               
                mov ch,0
        s1:        mov cl,
                jcxz re    ;Is the value in zero
       
                mov es:,cl
                mov es:,bl
               
                dec si
                add bp,2
                inc cx
                loop s1
               
        re:        ret               
               
code ends
end start
页: [1]
查看完整版本: 实验十.编写子程序(3)数值显示