【原创】DOS下TSR程序的汇编演示代码2--黑屏保护程序

windows提供了屏幕保护程序,当我们在规定的时间内没有对电脑进行操作时,系统会自动运行我们事先指定的屏幕保护程序。
下面我们在DOS实现一个简单的黑屏保护程序。
注意:
1。如果你运行了明伦五笔高手速成,那么本程序将不起作用,可能的原因是明伦五笔高手速成修改了有关的DOS中断,而没有回调。
2。如果想在window 95/98的MS-DOS方式下使用,应将MS-DOS方式窗口设为全屏。
3。win 2000/xp未作测试。

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; 文件名: SafeScr.asm
; 功  能: 在指定时间内未使用键盘则关闭屏幕显示(黑屏)
;
; 作  者: 黄志斌 2003年3月 广西河池
;
;参考: 电脑报 1996年合订本上册243页代码, 软件报 1993年合订本114页代码

; 申  明: 可以自由转载,应保存完整性.且不能用于商业用途
;
; 说  明:
;          1. 第一次运行时常驻内存,再次运行则撤出内存
;          2.如果你运行了明伦五笔高手速成,那么本程序将不起作用,
;             可能的原因是明伦五笔高手速成修改了;有关的DOS中断,而没有回调。
2。如果想在window 95/98的MS-DOS方式下使用,应将MS-DOS方式窗口设为全屏。
3。win 2000/xp未作测试。; Log
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Name     : 
;Function : ;Author   : Purple Endurer
;Reference: Computer paper 1996U243, Software 1993 P114
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

cseg    segment
        assume cs: cseg,  ds: cseg
        org 100h
start:  jmp @Init
        ;====================
        Old1cAddr label dword
        Old1cOff  dw    ?
        Old1cSeg  dw    ?
        Old09Addr label dword
        Old09Off  dw    ?
        Old09Seg  dw    ?
        mcb_evb   dw    ?       ; mcb: Memmory Control Block
        mcb_psp   dw    ?
        show      dw    1
        count     dw    0
        VarLen    equ   $ - Old1cAddr
        time      equ   1000

;///
 new1ch proc far
;///
        ;sti
        push ax
        push bx
        inc cs:[count]
        ;mov ax, cs: [time]
        cmp cs:[count], time
        jne @New1chEnd
        mov bl, 36h
        mov ax, 1201h
        int 10h
        mov cs:[count], 0
        mov cs:[show],  0
@New1chEnd:
        pop bx
        pop ax
        jmp cs:Old1cAddr
new1ch endp

;///
new09h proc far
        ;sti
        push ax
        push bx
        cmp cs:[show], 1h
        je  @New09hEnd
        mov cs:[show], 0h
        mov bl, 36h
        mov ax, 1200h
        int 10h
@New09hEnd:
        mov cs:[count], 0
        pop bx
        pop ax
        jmp cs:Old09Addr
new09h endp
;///

@Init:
        mov ax, 3509h           ; Get current 1ch interrupt vector
        int 21h

        cmp bx, offset new09h   ; Has been Intalled?
        jnz @install            ; No install

        mov  dx, offset strMsgUninstall
        mov  ah, 09h
        int  21h

        mov  bx, 1ch * 04h      ; Restore old 1ch interrupt vector
        xor  ax, ax             ; to System interrupt vector talbe
        mov  ds, ax
        mov  ax, es:[Old1cOff]
        mov  ds:[bx], ax
        mov  ax, es:[Old1cSeg]
        mov  ds:[bx+2], ax

        mov  bx, 09h * 04h      ; Restore old 09h interrupt vector
        mov  ax, es:[Old09Off]  ; to System interrupt vector talbe
        ;xor  ax, ax            
        ;mov  ds, ax            ; ds must equal 0
        mov  ds:[bx], ax        
        mov  ax, es:[Old09Seg]
        mov  ds:[bx+2], ax

        mov  bx, 1              ; Release evirenment parameter block
        mov  ax, es:[mcb_evb]
        mov  ds, ax
        mov  word ptr ds:[bx], 0

        mov  ax, es:[mcb_psp]    ; Release TSR
        mov  ds, ax
        mov  word ptr ds:[bx], 0
        mov  ax, 4c00h
        int  21h

@install:
        ;mov  ax, 3509h         ; Get current 1ch interrupt vector
        ;int  21h
        mov  Old09Seg, es       ; Store current 09h interrupt vector
        mov  Old09Off, bx

        mov  dx, offset new09h  ; Set new 09h interrupt vector
        mov  ax, 2509h
        int  21h

        mov  ax, 351ch          ; Get current 1ch interrupt vector
        int  21h
        mov  Old1cSeg, es       ; Store current 1ch interrupt vector
        mov  Old1cOff, bx

        mov  dx, offset new1ch  ; Set new 1ch interrupt vector
        mov  ax, 251ch
        int  21h

        mov  dx, offset strMsgInstall
        mov  ah, 09h
        int  21h

        ; Store the address of evirenment parameter block
        mov  ax, cs
        dec  ax
        mov  [mcb_psp], ax      ;mov  cs:[mcb_psp], ax
        mov  bx, 2ch
        mov  ax, [bx]           ;mov  ax, cs:[bx]
        dec  ax
        mov  cs:[mcb_evb], ax

        mov dx, offset @Init
        add dx, VarLen + 2
        mov cl, 04h
        shr dx, cl
        mov ax, 3100h
        int 21h
        ;====================
        strMsgInstall   db 07h, "Screensafer installed!$"
        strMsgUninstall db 07h, "Screensafer uninstalled!$"
cseg ends
        end start
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫郢剑侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值