;汇编语言 第二版 王爽 实验14 访问CMOS RAM
;编程,以“年/月/日 时:分:秒”的格式,显示当前的日期、时间。
;存放单元:秒:0, 分:2, 时:4, 日:7, 月:8, 年:9
assume cs:code
data segment
db 9,'/',8,'/',7,' ',4,':',2,':',0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
mov ax,0b800h
mov es,ax
mov di,160*11
mov cx,11
time_dis:
mov al,ds:[si]
cmp al,9
jnbe time_next
out 70h,al
in al,71h
push cx
mov cl,4
mov ah,al
shr ah,cl
add ah,30h
mov ch,al
mov al,ah
mov ah,100b
mov es:[di],ax
mov al,ch
pop cx
and al,1111b
add al,30h
add di,2
mov ah,100b
mov es:[di],ax
jmp time_again
time_next:
mov ah,100b
mov es:[di],ax
time_again:
inc si
add di,2
loop time_dis
in al,60h
cmp al,10h ;Q键的扫描码
je quit
jmp start
quit:
mov ax,4c00h
int 21h
code ends
end start