编写并安装 int 7ch 中断例程,功能为以“年/月/日 时:分:秒”的格式, 在
屏幕中间显示当前的日期、时间。中断例程安装在 0:200 处。 要求提供调用 程序,测试中
断例程的调用结果及对应电脑的系统时间的截图
中断程序源代码:
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset time
mov ax,0
mov es,ax
mov di,200H
mov cx,offset timeend-offset time
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[7cH*4],200H
mov word ptr es:[7cH*4+2],0
mov ax,4c00H
int 21H
time: jmp short timestart
db '00/00/00 00:00:00',0
db 9,8,7,4,2,0
timestart:
mov ax,cs
mov ds,ax
mov si,202H;与13.2书上例题一样,程序被写到0:200处
mov cx,6;此时cs=0,第一条jmp语句占两字节,所以字符串
mov bx,18;偏移地址为202H
s: push cx;读取当前系统时间
mov ax,[bx+202H]
out 70H,al
in al,71H
mov ah,al
mov cl,4
shr al,cl;十位数
and ah,00001111b;个位数
add ah,30H;对应得ascii码
add al,30H
mov ds:[si],ax;将数字写入到字符串中,因为ah放在右边
;所以ah应该放个位数,al放十位数,不然显示结果是反的,别问,问就是踩过坑
inc bx
add si,3
pop cx
loop s
mov ax,0b800h
mov es,ax
mov di,120*12+31*2
mov si,202H
showtime:
mov cl,ds:[si];将字符串写到显存里
mov ch,0
jcxz ok
mov es:[di],cl
inc si
add di,2
jmp short showtime
ok:
mov ax,4c00H
int 21H;这一定要写,不写无法正常显示
timeend: nop
code ends
end start
测试文件:
assume cs:code
code segment
start:
int 7cH
mov ax,4c00H
int 21H
code ends
end start