您的位置:首页 > 其它

[汇编] 屏幕中间显示数字时钟

2014-06-05 17:43 337 查看


;显示系统时间程序

data segment
; add your data here!
hour db '?'
minute db '?'
second db '?'
time db   "00:00:00$"
temp db '?'
now  db '?'
want db '?'
pkey db "press any key...$"
ends

stack segment
dw   128  dup(0)
ends

code segment
;---------------------------------------------
main proc far
call init_register  ;初始化
SiXunHuan:
mov want,1D         ;延时3S
call delay
call setshow
call show_time      ;显示
loop SiXunHuan

call last_show      ;结果
ret
main endp;
;---------------------------------------------
init_register proc near;set segment registers:
mov ax, data
mov ds, ax
mov es, ax
ret
init_register endp
;---------------------------------------------
show_time proc near ;时间子程序
mov ah,2Ch
int 21h         ;获取时间
mov hour,ch
mov minute,cl
mov second,dh

mov ax,0        ;计算到字符串时间
mov al,hour
mov temp,10D
div temp
add al,30H
mov time[0],al
add ah,30H
mov time[1],ah

mov ax,0
mov al,minute
mov temp,10D
div temp
add al,30H
mov time[3],al
add ah,30H
mov time[4],ah

mov ax,0
mov al,second
mov temp,10D
div temp
add al,30H
mov time[6],al
add ah,30H
mov time[7],ah

lea dx,time     ;10中断显示时间
mov ah,09H
int 21H

ret
show_time endp
;---------------------------------------------
last_show proc near ;最后显示东西
lea dx, pkey   ; output string at ds:dx
mov ah, 9
int 21h

; wait for any key....and end
mov ah, 1
int 21h

mov ax, 4c00h ; exit to operating system.
int 21h
ret
last_show endp
;---------------------------------------------
delay proc near     ;延时函数,放在want为想要延时的秒数
mov ah,2Ch
int 21h         ;获取时间
mov now,dh

mov ax,0
mov al,now
add al,want
mov temp,60D
div temp
mov want,ah
del:
mov ah,2Ch
int 21h
cmp dh,want
jz  next
loop del
next:
ret
delay endp
;---------------------------------------------
setshow proc near   ;设置光标位置位置
mov dh,12      ;row-1
mov dl,34      ;columun-1
mov bh,0
mov ah,2
int 10h
setshow endp
;---------------------------------------------
clear proc near
ret
clear endp
;---------------------------------------------
end code
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: