1 ;以"年/月/日 时:分:秒"的格式, 显示当前的日期, 时间
2 assume cs:code
3 code segment
4 main:
5 mov al,9
6 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
7 in al,71h ;从该存储单元中读入数据
8
9 mov ah,al
10 mov cl,4
11 shr al,cl
12 add al,30h ;显示的年份的十位的ascii码
13 and ah,00001111b
14 add ah,30h ;显示的年份的个位的ascii码
15
16 mov bx,0b800h
17 mov es,bx
18 mov byte ptr es:[160*12+30*2],al
19 mov byte ptr es:[160*12+31*2],ah ;显示年
20
21 mov byte ptr es:[160*12+32*2],'/' ;显示'/'
22
23 mov al,8
24 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
25 in al,71h ;从该存储单元中读入数据
26
27 mov ah,al
28 mov cl,4
29 shr al,cl
30 add al,30h ;显示的年份的十位的ascii码
31 and ah,00001111b
32 add ah,30h ;显示的年份的个位的ascii码
33
34 mov byte ptr es:[160*12+33*2],al
35 mov byte ptr es:[160*12+34*2],ah ;显示月
36
37 mov byte ptr es:[160*12+35*2],'/' ;显示'/'
38
39 mov al,7
40 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
41 in al,71h ;从该存储单元中读入数据
42
43 mov ah,al
44 mov cl,4
45 shr al,cl
46 add al,30h ;显示的年份的十位的ascii码
47 and ah,00001111b
48 add ah,30h ;显示的年份的个位的ascii码
49
50 mov byte ptr es:[160*12+36*2],al
51 mov byte ptr es:[160*12+37*2],ah ;显示日
52
53 mov byte ptr es:[160*12+38*2],' ' ;显示' '
54
55 mov al,4
56 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
57 in al,71h ;从该存储单元中读入数据
58
59 mov ah,al
60 mov cl,4
61 shr al,cl
62 add al,30h ;显示的年份的十位的ascii码
63 and ah,00001111b
64 add ah,30h ;显示的年份的个位的ascii码
65
66 mov byte ptr es:[160*12+39*2],al
67 mov byte ptr es:[160*12+40*2],ah ;显示时
68
69 mov byte ptr es:[160*12+41*2],':' ;显示':'
70
71 mov al,2
72 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
73 in al,71h ;从该存储单元中读入数据
74
75 mov ah,al
76 mov cl,4
77 shr al,cl
78 add al,30h ;显示的年份的十位的ascii码
79 and ah,00001111b
80 add ah,30h ;显示的年份的个位的ascii码
81
82 mov byte ptr es:[160*12+42*2],al
83 mov byte ptr es:[160*12+43*2],ah ;显示分
84
85 mov byte ptr es:[160*12+44*2],':' ;显示':'
86
87 mov al,0
88 out 70h,al ;告诉CMOS RAM将要访问的存储单元编号
89 in al,71h ;从该存储单元中读入数据
90
91 mov ah,al
92 mov cl,4
93 shr al,cl
94 add al,30h ;显示的年份的十位的ascii码
95 and ah,00001111b
96 add ah,30h ;显示的年份的个位的ascii码
97
98 mov byte ptr es:[160*12+45*2],al
99 mov byte ptr es:[160*12+46*2],ah ;显示秒
100
101
102 mov ax,4c00h
103 int 21h
104 code ends
105 end main