📄 typeword.asm
字号:
;this program for:sample program of key input
;-----------------------------------------------------
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 (?)
row_reg db (?) ;row*col
col_reg db (?)
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 ;return to dos
mov ax,data
mov ds,ax ;set ds
mov ax,video
mov es,ax ;set es
;
mov row_reg,3
mov col_reg,10
mov r6,0000h ;clr screen
mov r7,184fh
mov bh,4fh ;set bg color
call clr_screen
mov r6,0000h
mov r7,174fh
mov bh,0fh ;set background color
call clr_screen ;make bottom red
mov r6,030ah ;clr screen
mov r7,0f45h
mov bh,1fh ;set bg color
call clr_screen
mov r4,020ah
mov r5,0309h
call make_frame
mov r4,100ah
mov r5,0346h
call make_frame
mov al,2bh ;make corner
mov ah,1eh
mov cx,0209h
call display
mov cx,1009h
call display
mov cx,0246h
call display
mov cx,1046h
call display
;
scan_key: call read_time
call read_date
call convert_ascii
call display_time
call display_date
mov ah,1
int 16h
jz scan_key
yes_key: mov ah,0
int 16h
cmp al,08h ;test "bs=08h"
je key_process2
cmp al,1bh ;test "esc=1bh" key
jnz key_process
jmp exit ;if "esc" key go to exit
key_process: mov ah,1fh ;set symbol color
mov cl,col_reg ;set locat of symbol
mov ch,row_reg ;set locat of symbol
call display
inc col_reg
cmp col_reg,70
jne key_process1
mov col_reg,10
inc row_reg
cmp row_reg,16
jne key_process1
mov row_reg,15
mov col_reg,69
key_process2: mov ah,1fh
mov al,0
mov cl,col_reg
mov ch,row_reg
call display
dec col_reg
key_process1: mov ah,02h ;set arrow location
mov dh,row_reg
mov dl,col_reg
mov bh,0
int 10h
jmp scan_key
exit: mov r6,0000h
mov r7,184fh
mov bh,0fh ;set background color
call clr_screen
ret
main endp
;****************************************************************
;;bellow is some proc near program
;-----------------------------------------
;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 time,led1 to led8
display_time proc near
;-------
mov r0,8 ;the No. of the symbol,use r0
lea bx,led1
mov cx,1847h ;where the time is
display_time1:
mov al,[bx]
mov ah,4eh ;set symbol color
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 ;the No. of the symbol,use r0
lea bx,led10
mov cx,1801h ;;where the time is
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,r6
mov dx,r7
int 10h
mov ah,02h
mov dh,row_reg
mov dl,col_reg
mov bh,0
int 10h
ret
clr_screen endp
;-------------------------------------------
make_frame proc near
mov cx,r4
mov r0,60
mov al,2dh ;"symbol"
mov ah,1eh ;color
make_frame1:
call display
inc cx
dec r0
jnz make_frame1
mov cx,r5
mov r0,13
mov al,7ch ;"symbol"
mov ah,1eh ;color
make_frame2:
call display
add cx,100h
dec r0
jnz make_frame2
ret
make_frame 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
;-----------------------------------------------
program ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -