飘云阁

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 2306|回复: 0

[C/C++] 关于汇编的传递参数的练习

[复制链接]

该用户从未签到

发表于 2010-12-27 11:43:53 | 显示全部楼层 |阅读模式
;Code by FBI
;2010-12-25
assume cs:code
data segment
            i_int1    dw 12eh,12666,1,8,3,38,0a0dh
                      dw 12eh,345,41,84,34,38,0a0dh
                      dw 12eh,12346,1,86,36,38,0a0dh
                      dw 12eh,666,145,8,33eh,38,0a0dh
            i_int2    dw 1234,567,10249,877,0ffffh
        temp          db 100 dup(0)
data ends
stack        segment
        dw        60 dup(0)
stack        ends
code segment
start:       
        mov         ax,stack
        mov        ss,ax
        mov        sp,100
       
        push         es
        mov        ax,0
        push        ax
       
        mov         ax,data
        mov         ds,ax
               
        mov        ax,offset i_int1
        push        ax
        mov        ax,offset temp
        push        ax
        call        d_to_num
        add        sp,4
       
        call        cls
       
        push        ds
        pop        es
        mov        di,offset temp
        call        display       
       
        mov        dx,offset temp
        mov        ah,09h
        int        21h
       
        retf
;cls
cls        PROC
       
        push cx
        push ds
        mov        cx,320
        mov        ax,0b800h
        mov         ds,ax
        mov         bx,1600
        mov        ax,09f20h
s:        mov        [bx],ax
        inc        bx
        inc        bx
        loop        s
        pop        ds
        pop        cx
        ret
cls        ENDP
;display
display        proc
        push        ds
        push        ax
        push        si
        mov        ax,0b800h
        mov         ds,ax
        mov         bx,1600
        mov        si,0
        xor        ax,ax
_s:        mov        al,es:[di]
        cmp        ax,0dh
        jz        _t
_ttt:        mov        ds:[bx+si],al
        inc        si
        inc        si
        inc        di
        cmp        ax,0
        jz        _end
        jmp        _s
_end:        pop        si
        pop        ax
        pop        ds
        ret
_t:        inc         di
        mov        al,es:[di]
        cmp        ax,0ah
        jz        _tt
        dec        di
        mov        al,0dh
        jmp        _ttt
_tt:        inc        di
        add        bx,160
        mov        si,0
        jmp        _s
display         endp
;dtonum ds:di,ds:si
d_to_num        proc
        mov        bp,sp
        push        bp
        push        di
        push        si
        push        cx
;取地址
        mov        di,[bp+2]
        mov        si,[bp+4]
;开始转换
       
       
d_s:        mov        ax,ds:[si]
        cmp        ax,0ffffh
        jz        d_end
        cmp        ax,0a0dh
        jz        d_enter
d_a:        ;mov        bx,ax
        mov        cx,05
        mov        bx,10       
d_ss:        xor        dx,dx
        div        bx
        add        dl,30h
        push        dx
        loop        d_ss
        mov        cx,05h
d_sss:        pop        dx
        mov        ds:[di],dl
        inc        di
        loop        d_sss
               
        mov        byte ptr ds:[di],20h
        inc        di
        inc        si
        inc        si
        jmp        d_s
       
d_end:        mov        byte ptr ds:[di],0h
        inc        di
        mov        byte ptr ds:[di],24h
        pop        cx
        pop        si
        pop        bx
        pop        bp
        ret
d_enter:mov        byte ptr ds:[di],0dh
        inc        di
        mov        byte ptr ds:[di],0ah
        inc        di
        inc        si
        inc        si
        jmp        d_s
d_to_num        endp

code        ends
end        start
PYG19周年生日快乐!
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表