📄 disdatm.asm
字号:
;This program for: display date and time
;******************************************
stack segment stack 'stack'
db 1024 dup (0)
stack ends
;
data segment
bword equ this byte
r0 dw (?)
r1 dw (?)
r2 dw (?)
r3 dw (?)
r4 dw (?)
r5 dw (?)
r6 dw (?)
r7 dw (?)
;------------------------------------------
temp1 dw (?)
temp2 dw (?)
temp3 dw (?)
temp4 dw (?)
;------------------------------------------
led1 db (?)
led2 db (?)
led3 db (?)
led4 db (?)
led5 db (?)
led6 db (?)
led7 db (?)
led8 db (?)
led9 db (?)
led10 db (?)
led11 db (?)
led12 db (?)
led13 db (?)
led14 db (?)
led15 db (?)
led16 db (?)
led17 db (?)
led18 db (?)
led19 db (?)
;------------------------------------------
year_reg db (?)
moth_reg db (?)
date_reg db (?)
s_reg db (?)
m_reg db (?)
H_reg db (?)
;------------------------------------------
data ends
;;;;;;;;;;;;;;;;;;;;;;;;;;
video segment at 0b800h
wd_buffer label word
v_buff db 25*80*2 dup (?)
video ends
program segment
;;;;;;;;;;;;;;;;;;;;;;;;;
main proc far
assume cs:program,ds:data,ss:stack,es:video
;
start: push ds
mov ax,0
push ax
;;
mov ax,data
mov ds,ax
mov ax,video
mov es,ax
;;
mov temp1,0000h ;clr screen
mov temp2,184fh
mov bh,4fh ;set background color
call clr_screen
mov temp1,0000h ;clr screen
mov temp2,154fh
mov bh,0fh ;set background color
call clr_screen ;make buttom blank red
;;;;;;;;
do_wait: mov ah,1
int 16h ;test key
jz no_key
yes_key: mov ah,0
int 16h ;read key
cmp al,1bh ;esc=1bh
jnz no_key
jmp exit ;if "esc"
no_key: call read_time ;display time
call read_date
call convert_ascii
call display_time
call display_date
call make_frame
jmp do_wait
;;;
exit: mov temp1,0000h
mov temp2,184fh
mov bh,0fh ;set background color
call clr_screen
ret
main endp
;*******************************************************
;read time
;input no
;output h_reg,s_reg,m_reg,all data is BCD code
;;
read_time proc near
;-----------------------------
mov ah,02h
int 1ah ;read time
mov h_reg,ch
mov m_reg,cl
mov s_reg,dh
ret
;---------------------------
read_time endp
;******************************************
;read date
;input no
;output year_reg,moth_reg,data_reg,all date is BCD
read_date proc near
;-----------------------------------
mov ah,04h
int 1ah ;read date
mov year_reg,cl
mov moth_reg,dh
mov date_reg,dl
ret
;------------------------------------
read_date endp
;*******************************************
;convert time and date into ASCII and store to display buffer
convert_ascii proc near
;---------------------------------
mov al,h_reg ;process time
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led1,al
mov al,h_reg
and al,0fh
add al,30h
mov led2,al
mov al,m_reg
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led4,al
mov al,m_reg
and al,0fh
add al,30h
mov led5,al
mov al,s_reg
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led7,al
mov al,s_reg
and al,0fh
add al,30h
mov led8,al
mov led3,3ah ;set ":"
mov led6,3ah ;set ":"
;-----------------------------------
mov al,year_reg
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led12,al
mov al,year_reg
and al,0fh
add al,30h
mov led13,al
mov al,moth_reg
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led15,al
mov al,moth_reg
and al,0fh
add al,30h
mov led16,al
mov al,date_reg
and al,0f0h
mov cl,4
ror al,cl
add al,30h ;convert ASCII
mov led18,al
mov al,date_reg
and al,0fh
add al,30h
mov led19,al
mov led10,32h ;"2"
mov led11,30h
mov led14,2dh ;"-"
mov led17,2dh ;"-"
ret
convert_ascii endp
;*************************************************
;display a symbol
;input symbol=al
;color=ah
;row=ch
;col=cl
display proc near
;-------
push bx
push cx
push ax
mov al,160
mul ch ;row*80*2=ax
mov bl,cl
rol bl,1 ;bl*2
mov bh,0
add bx,ax
pop ax
mov es:[wd_buffer+bx],ax
pop cx
pop bx
ret
display endp
;******************************
;display time,led1 to led8
display_time proc near
;-------
mov r0,8
lea bx,led1
mov cx,1747h
display_time1:
mov al,[bx]
mov ah,4eh ;set symbol color,00001110b
call display
inc cx
inc bx
dec r0
jnz display_time1
ret
display_time endp
;*********************************
;display date,led10 to led19
display_date proc near
mov r0,10
lea bx,led10
mov cx,1701h
display_date1:
mov al,[bx]
mov ah,4eh ;set symbol color,00001110b
call display
inc cx
inc bx
dec r0
jnz display_date1
ret
display_date endp
;********************************
clr_screen proc near
mov ah,06h
mov cx,temp1
mov dx,temp2
int 10h
ret
clr_screen endp
;*********************************
make_frame proc near
mov cx,1600h
mov r0,80
mov al,2bh ;"+"
mov ah,4fh
make_frame1:
call display
inc cx
inc cx
dec r0
dec r0
jnz make_frame1
mov cx,1800h
mov r0,80
make_frame2:
call display
inc cx
inc cx
dec r0
dec r0
jnz make_frame2
mov cx,1700h
call display
mov cx,174fh
call display
ret
make_frame endp
;**********************************
program ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -