📄 sr.asm
字号:
code segment
assume cs:code
run_flag db 0 ;运行标志
key_flag db 0 ;按键标志
wait_time db 0 ;自上次修改经过的时间
bak_417 db 0 ;保存原始数据
caution_flag db 0 ;提示出现标志
Temp dw 0 ;保存闪烁样式序号
time_span db 6h ;闪烁间隔时间 1秒=18.2
enabled_time db 36d ;此时间内无按键就激活程序
old_int_1ch dd 0 ;指向中断1Ch
old_int_15h dd 0 ;指向中断15h
garrison_flag dw 5777h ;驻留标志
;======================================================================
; time 替换 int 1ch 中断
;======================================================================
Time: push ax
push bx
push si
push ds
push es
push cs
pop ds
mov ax,0
mov es,ax
cmp run_flag,0
jz not_run
mov al,wait_time
cmp al,[time_span]
jz flicker
inc [wait_time]
jmp finish_int_1ch
flicker: mov wait_time,0
lea bx,index0
mov si,temp
mov al,byte ptr [bx+si]
mov es:[417h],al
inc si
cmp byte ptr [bx+si],0ffh
jnz again
mov si,0
again: mov temp,si
jmp finish_int_1ch
not_run: mov al,key_flag
cmp al,[enabled_time]
jz enabled
Inc [key_flag]
jmp finish_int_1ch
enabled: mov key_flag,0
mov run_flag,1
mov al,es:[417h]
mov bak_417,al
finish_int_1ch:
pop es
pop ds
pop si
pop bx
pop ax
jmp old_int_1ch
;======================================================================
; key 替换 int 15h 中断
;======================================================================
key:
push bx
push ds
push es
push cs
pop ds
mov bx,0
mov es,bx
cmp ah,4fh
jne finish_int_15h
cmp al,53h ; Del key
je ctrl_alt
cmp al,0d3h
jne key_test
ctrl_alt: mov bh,es:[417h]
and bh,0ch
cmp bh,0ch
jne key_test
mov caution_flag,1
mov al,0h
clc
jmp old_key
key_test: cmp caution_flag,1
jne old_key
hoot_key_test: cmp al,10h ; Q key scan code
je off
cmp al,13h ; R key scan code
je restart
mov caution_flag,0
old_key: cmp run_flag,0
jz anew_wait
mov run_flag,0
mov temp,0
mov bh,bak_417
mov es:[417h],bh
jmp finish_int_15h
anew_wait: mov wait_time,0
finish_int_15h:
pop es
pop ds
pop bx
jmp old_int_15h
index0 db 20h,40h,10h,0ffh ;闪烁样式,必须以0ffh结尾
;======================================================================
; restart 系统重启
;======================================================================
restart: mov ax,0
push ax
pop ds
mov word ptr ds:[0472],1234h
mov ax,0ffffh
push ax
mov ax,0
push ax
retf
;======================================================================
; off 关闭系统
;======================================================================
off:
mov ax,5300h
xor bx,bx
int 15h ; Chack APM install
jnb @@1
jmp ExitSys
@@1:
cmp bx,504Dh ; bx==PM?
jz @@2
jmp ExitSys
@@2:
cmp ax,101h
jnb @@3
jmp ExitSys
@@3:
push cx
mov ax,5400h
xor bx,bx
int 2Fh
xor ax,ax
cmp bx,504Dh
jnz @@4
push ax
mov ax,5401h
mov bx,100h
int 2Fh
pop ax
jb @@4
inc ax
@@4:
pop cx
push ax
push bx
push cx
mov ax,5301h
xor bx,bx
int 15h
mov ax,530Eh
xor bx,bx
mov cx,101h
int 15h
mov ax,530Fh
mov bx,1
mov cx,bx
int 15h
mov ax,5308h
mov bx,1
mov cx,bx
int 15h
mov ax,5307h
mov bx,1
mov cx,3
int 15h ; off power
pop cx
test cl,8
jz @@5
push cx
mov ax,5308h
mov bx,1
xor cx,cx
int 15h
pop cx
@@5:
test cl,10h
jz @@6
mov ax,530Fh
mov bx,1
xor cx,cx
int 15h
@@6:
mov ax,5304h
xor bx,bx
int 15h
pop bx
pop ax
test ax,ax
jz ExitSys
mov ax,5401h
mov bl,bh
mov bh,1
int 2Fh
ExitSys:
jmp old_key
;======================================================================
; start 主程序安装驻留部分
;======================================================================
start: mov ax,code
mov ds,ax
mov ax,351ch
int 21h
mov ax,[garrison_flag]
cmp word ptr es:[bx-2],ax
jnz install
mov dx,es:[bx-10]
mov ax,es:[bx-8]
mov ds,ax
mov ax,251ch
int 21h
mov dx,es:[bx-6]
mov ax,es:[bx-4]
mov ds,ax
mov ax,2515h
int 21h
jmp quit
install: mov dx,offset help
mov ah,9h
int 21h
mov word ptr old_int_1ch,bx
mov word ptr old_int_1ch+2,es
mov ax,3515h
int 21h
mov word ptr old_int_15h,bx
mov word ptr old_int_15h+2,es
lea dx,time
mov ax,251ch
int 21h
lea dx,key
mov ax,2515h
int 21h
mov ax,3100h
lea dx,start
mov cl,4
shr dx,cl
add dx,11h
int 21h
ret
quit: mov ax,4c01h
int 21h
help db 0dh,0ah,09h,53h,61h,66h,65h,20h,72h,65h,73h,74h,61h,72h
db 74h,20h,74h,6fh,6fh,6ch,20h,76h,31h,2eh,30h,0dh,0ah,24h
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -