assume cs:code,DS:data,SS:stack
stack segment
DW 8 dup(0)
stack ends
data segment
DB 9,8,7,4,2,0 ;代表 年 月 日 时 分 秒
data ends
code segment
start:
MOV AX,stack
MOV SS,AX
MOV sp,16
MOV AX,data
MOV DS,AX
MOV AX,0b800h
MOV ES,AX
MOV DI,12*160
MOV CX,3
MOV SI,0
;输出年月日
s:
PUSH CX
MOV AL,[si]
OUT 70h,AL
IN AL ,71h
MOV AH,AL
MOV CL,4
SHR AH,CL
AND AL,00001111b
ADD AH,30h
ADD AL,30h
MOV ES:[di],AH
ADD DI,2
MOV ES:[di],AL
ADD DI,2
MOV BYTE ptr ES:[di],'/'
ADD DI,2
INC SI
POP CX
LOOP s
MOV BYTE ptr ES:[di-2],' '
MOV CX,3
;输出时分秒
s2:
PUSH CX
MOV AL,[si]
OUT 70h,AL
IN AL ,71h
MOV AH,AL
MOV CL,4
SHR AH,CL
AND AL,00001111b
ADD AH,30h
ADD AL,30h
MOV ES:[di],AH
ADD DI,2
MOV ES:[di],AL
ADD DI,2
MOV BYTE ptr ES:[di],':'
ADD DI,2
INC SI
POP CX
LOOP s2
MOV BYTE ptr ES:[di-2],' '
mov ax,4c00h
int 21h
code ends
end start