汇编实现年月日时分秒的显示

来源:互联网 发布:林青霞五官数据分析 编辑:程序博客网 时间:2024/06/05 07:18
;显示时间,年/月/日 时:分:秒
assume cs:codesg, ds:datasg
datasg segment
db 9,8,7,4,2,0;年,月,日,时,分,秒
datasg ends
codesg segment
main:
mov ax, datasg
mov ds, ax
mov si, 0
;设置显示地址
mov bx, 0b800H
mov es, bx
mov di, 14*160 + 30*2;
;年月日的循环
mov cx, 6
s:
push cx;shr时用到了cl,所以要入栈保存

mov al, [si]
out 70H, al
in al, 71H
;十进制数到bcd码
mov ah, al
mov cl, 4
shr ah, cl
and al, 00001111B
;bcd码到acsii码
add ah, 30H
add al, 30H

mov byte ptr es:[di], ah
add di, 2
mov byte ptr es:[di], al
add di, 2

pop cx

cmp cx, 4
je s1;
ja s2;
jna s3;

s1:
mov byte ptr es:[di], 20H;20H-空格
add di, 2

inc si
loop s
s2:
mov byte ptr es:[di], 2FH;5cH-'/'
add di, 2

inc si
loop s
s3:

cmp cx, 1
;je exit;退出程序
je main;循环显示时间

mov byte ptr es:[di], 3AH;3AH-':'
add di, 2
inc si
loop s




exit:
mov ax, 4c00H
int 21H
codesg ends

end main

结果:



0 0
原创粉丝点击