. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->CALL和RET指令
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验10-3: source code!  [待解决] 回复[ 1次 ]   点击[ 446次 ]  
cjlchenjilin
[帖 主]   [ 发表时间:2011-07-04 16:00 ]   [引用]   [回复]   [ top ] 
荣誉值:1
信誉值:0
注册日期:2011-05-30 14:33
assume cs:code
data segment
                db 10 dup(0)
data ends

code segment
start:        mov ax,12666
                mov bx,data
                mov ds,bx
                mov si,0
                call dtoc
                
                mov dh,8
                mov dl,3
                mov cl,2
                mov ax,data
                mov ds,ax
                mov si,0
                call show_str
                
                mov ax,4c00h
                int 21h
                
dtoc:        push ax
                push bx
                push cx
                push dx
                push si
                
                
                
                
                
                mov bx,10
        to:        mov dx,0
                div bx
                mov cx,ax
                add dl,30h
                push dx
        
                jcxz good
                inc si
                jmp short to
                
                
good:        inc si
                mov cx,si
                mov si,0
circle:        pop [si]
                inc si
                loop circle

                pop si
                pop dx
                pop cx
                pop bx
                pop ax
                ret
                
show_str:        push ax
                        push bx
                        push cx
                        push dx
                        push si
                        push di
                        push es
                        
        address:        mov ax,0b800h
                                mov es,ax
                                mov ax,160
                                mul dh
                                mov bx,ax
                                dec dl
                                add dl,dl
                                mov dh,0
                                add bx,dx
                                mov di,0
                                
                                mov ah,cl
                                mov ch,0
                show:        mov cl,[si]
                                jcxz ok
                                mov al,[si]
                                mov es:[bx+di],ax
                                inc si
                                add di,2
                                jmp short show
                                
                ok:                pop es
                                pop di
                                pop si
                                pop dx
                                pop cx
                                pop bx
                                pop ax
                                ret
code ends
end start
mmnnn_bb
[第1楼]   [ 回复时间:2011-08-11 23:36 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-08-11 23:23
assume cs:code,ds:data

data segment
        db 10 dup (0)
data ends

code segment
        
        start:        mov ax,0ffffh
                        mov dx,0ffffh
                        mov bx,data
                        mov ds,bx
                        
                        mov si,0                                        ;Index of the string
                        call dtoc
                        
                        mov dh,8                                        ;Line no
                        mov dl,3                                        ;Column no
                        mov cl,00000010b                        ;Color, green
                        call show_str
        
        mov ax,4c00h                                                ;Terminate procerss
        int 21h                                                                ;Call dos interupt
        
        dtoc:        push dx
                        push cx
                        push di
                        push si
                        
                        mov di,0                                        ;Record number of character
                        
                s0:        mov cx,10                                        ;Divisor is 10
                        call divdw
                        
                        add cx,30h                                        ;Covert to ASCII character
                        push cx                                        ;Push character into stack
                        inc di                                                ;Count +1
                        ; mov [si],cl                                ;Save the character
                        ; mov byte ptr [si+1],0                ;Save 0 in the end
                        ; inc si                                        ;Next
                        mov cx,ax
                        jcxz eof0                                        ;Return
                        
                        jmp short s0
                        
                eof0:        mov byte ptr [di],0        ;Set the end of flag
                                
                                mov cx,di                                ;Set the loop times
                                
                        l:        pop bx                                        ;Get the character
                                mov [si],bl                        ;Set the character
                                inc si
                                loop l
                                
                                pop si
                                pop di
                                pop cx
                                pop dx
                                ret
        
        ; Name:         divdw
        ; Desc:         The division will not overflow, the dividend for the dword type,
        ;                        the divisor for the dword type, the result is dword type
        ; Args:         (ax)=dword low 16-bit data type
        ;                        (dx)=dword high 16-bit data type
        ;                        (cx)=divisor
        ; Return:   (dx)=high 16 result
        ;                         (ax)=low 16 result
        ;                         (cx)=remainder
        
        divdw:        push si
                        push bx

                        push ax
                        mov ax,dx
                        mov dx,0
                        div cx
                        
                        mov si,ax
                        pop ax
                        div cx
                        mov cx,dx
                        mov dx,si
                        
                        pop bx
                        pop si
                        ret
                        
        ; Name:                show_str
        ; Desc:                At the special location with the special color, display the string
        ; Args:                (dh)=row number(Range:0~24), (dl)=column number(Range:0~79)
        ;                        (cl)=color, ds:si points to the first address of the string
        ; Return:        void
        show_str:        push ax
                                push bx
                                push cx
                                push si
                                push di
                                
                                mov ax,0b800h
                                mov es,ax
                                
                                mov al,0a0h
                                mul dh                                        ;Offset of the row
                                mov bx,ax                                
                                
                                mov al,2
                                mul dl                                        ;Offset of the column
                                add bx,ax                                ;Ofset of display
                                
                                mov ah,cl                                ;Set the color
                                
                                mov ch,0                                ;High 16-bit is 0
                        
                        s:        mov cl,[si]                        ;Set the character
                                jcxz eof
                                
                                mov al,cl
                                
                                mov es:[bx],ax
                                inc si
                                add bx,2
                                jmp short s
                                
                        eof:        pop di
                                        pop si
                                        pop cx
                                        pop bx
                                        pop ax
                                        
                                        ret
code ends

end start
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved