汇编网首页登录博客注册
yang5731的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
学习动态
最新留言
友情链接

[2011-03-25 20:56] 程序驻留

图片载入中
PUBLIC        time
.model        SMALL
.data
hhhh        db        ?,?,':'
mmmm        db        ?,?,':'
ssss        db        ?,?
.code
;子程序名:time
;入口参数:
;功能:按ctrl+f8显示时间
;出口参数:
;说明:远过程
time        proc        far 
        push        ax
        push        bx
        push        cx
        push        dx
        push        es
        push        bp
        push        ds
        mov        ax,_data
        mov        ds,ax
        mov        es,ax
        mov        bx,10
        mov        ah,2ch                                ;取时间
        int        21h
        mov        ax,cx
        and        ax,0ffh
        div        bl
        add        ax,3030h
        mov        WORD ptr mmmm,ax
        xchg        cl,ch
        mov        ax,cx
        and        ax,0ffh
        div        bl
        add        ax,3030h
        mov        WORD ptr hhhh,ax
        xchg        dl,dh
        mov        ax,dx
        and        ax,0ffh
        div        bl
        add        ax,3030h
        mov        WORD ptr ssss,ax
        mov        ax,1300h
        mov        bx,7
        mov        cx,8
        mov        dx,1848h  ;在24行最后8列显示时间
        mov        bp,offset hhhh
        int        10h       ;为什么用ah=9,int21h就出错
  ;INT21H优先级应该高于INT9H,纠结了好长时间还是没搞明白,悲剧
        pop        ds
        pop        bp
        pop        es
        pop        dx
        pop        cx
        pop        bx
        pop        ax
        ret
time        endp
end
;先把上面time.asm生成目标文件(.obj)
;建立个mylib.lib的子程序库文件
;再lib mylib +time 
;把下面的2-0.asm生成目标文件
;link 2-0,,,mylib;

buff_head=1ah
buff_tail=1ch
ctrl_f8=6500h
.model small
.code
old9        dd        ?
new9:        extrn        time:far     ;声明标号在模块外
        pushf
        call        DWORD ptr cs:old9
        sti
        push        ax
        push        ds
        push        bx
@@1:        mov        ax,40h
        mov        ds,ax
        mov        bx,ds:[buff_head]
        cmp        bx,ds:[buff_tail]
        jz        over
        mov        ax,ds:[bx]
        cmp        ax,ctrl_f8
        jz        yes
over:        pop        bx
        pop        ds
        pop        ax
        iret
yes:        call        time
        jmp        over
start:        
        push        cs
        pop        ds
        cli
        mov        ax,3509h
        int        21h
        mov        WORD ptr old9,bx   ;保存旧中断
        mov        WORD ptr old9+2,es
        mov        dx,offset new9
        mov        ax,2509h        ;置新的中断
        int        21h
        sti
        mov        dx,offset start
        add        dx,15
        mov        cl,4
        shr        dx,cl
        add        dx,10h    ;驻留节数
        mov        ah,31h    ;结束并驻留
        int        21h
end        start
评论次数(0)  |  浏览次数(842)  |  类型(章节要点) |  收藏此文  | 
 
 请输入验证码  (提示:点击验证码输入框,以获取验证码