📄 systemtime.asm
字号:
code segment
assume cs:code,ds:code
org 100h
start: jmp install
msg db 'Current time is: '
time0 db ?,?
db ':'
time1 db ?,?
db ':'
time2 db ?,?,0,0
oldint1c dd ?
newint1c: push ax
push bx
push cx
push dx
push si
push di
push es
mov ax,0200h ;获取系统时间,ch→hours cl→minutes DH→seconds,均为BCD码格式
int 1ah
mov al,ch
lea si,time0
call bcd
mov al,cl
lea si,time1
call bcd
mov al,dh
lea si,time2
call bcd
mov ax,0b800h ;显存地址 采用直接写显存的方法输出字符
mov es,ax ;es:di 指向显存地址
mov di,54*2d
lea si,msg
disp: mov al,cs:[si]
inc si
or al,al
jz disp0 ;cs=ds
cld
stosb
inc di ;将cs:si指向的一个字节传送到es:di
jmp disp
disp0: pop es
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp cs:oldint1c ;新1CH中断的事情做完后调用原来的1CH中断
bcd: mov ah,al
shr ah,1
shr ah,1
shr ah,1
shr ah,1
and al,0fh
add ax,'00'
xchg ah,al
mov cs:[si],ax
ret
install: push cs
pop ds
mov ax,351ch ;获取中断向量ES:BX指向中断向量
int 21h
mov word ptr oldint1c,bx
mov word ptr oldint1c+2,es
lea dx,newint1c
mov ax,251ch ;设置中断向量 DS:DX指向中断向量
int 21h
mov dx,offset install+120h
mov cl,04h
shr dx,cl
mov ah,31h ;结束并驻留 DX:保留的长度(内存大小单位为节)
int 21h
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -