assume cs:code
data segment
time db 'yy/mm/dd hh:mm:ss$';int 21h 显示字符串,要求以$结束
table db 9,8,7,4,2,0 ;各时间量的存放单元
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,offset table
mov di,offset time
mov cx,6
s:
push cx
mov al,ds:[si];读端口内单元号
out 70h,al;单元号送入70h端口
in al,71h;从71端口读取单元号对应地址的数据
mov ah,al
mov cl,4
shr ah,cl;将压缩BCD码分为两个BCD码
and al,00001111b
add ah,30h
add al,30h
mov ds:[di],ah
mov ds:[di+1],al;写进time
inc si
add di,3
pop cx
loop s
mov dx,offset time
mov ah,9
int 21h
code ends
end start
功能是显示当前系统的时间,主要是cmos RAM端口知识应用,时间依照年,月,日,时,分,秒顺序存在单元9、8、7、4、2、0单元。
详见王爽汇编第十四章端口
注:非原创!