📄 display.asm
字号:
;*****************************************************
;
; This programme is for study Ver2.0.0 beta
;This programme must be run in 12MHz standard settings
; Display programmer
; Designer: Mr.Koii
; Copyright 2002-2003 koiistudio
; 2003.03.31 at Changsha. H.N. P.R.China
;
;*****************************************************
;*****************************************************
;数码管显示
;*****************************************************
digital: mov a,digital_bit ;根据显示位置读取不同的显示内容
jb acc.0,digital_check0
jb acc.1,digital_check1
jb acc.2,digital_check2
jb acc.3,digital_check3
jb acc.4,digital_check4
jb acc.5,digital_check5
jb acc.6,digital_check6
jb acc.7,digital_check7
call beep2
ret
digital_check0: mov r0,#digital_byte
mov a,@r0 ;秒
jmp digital_display
digital_check1: mov r0,#digital_byte
inc r0
mov a,@r0
jmp digital_display
digital_check2: mov r0,#digital_byte ;分
inc r0
inc r0
mov a,@r0
setb acc.4 ;加小数点
jmp digital_display
digital_check3: mov a,#digital_byte
add a,#3
mov r0,a
mov a,@r0
jmp digital_display
digital_check4: mov a,#digital_byte ;时
add a,#4
mov r0,a
mov a,@r0
setb acc.4 ;加小数点
jmp digital_display
digital_check5: mov a,#digital_byte
add a,#5
mov r0,a
mov a,@r0
anl a,#83h ;屏蔽无效位
jmp digital_display
digital_check6: mov a,#digital_byte
add a,#6
mov r0,a
mov a,#20h
jmp digital_display
digital_check7: mov a,#digital_byte
add a,#7
mov r0,a
mov a,#20h
digital_display: push a
mov a,digital_flash_time
anl a,#7fh ;最高位表示显示状态:1为显示;0为不显示;其余位为记数值
cjne a,#80,digital_display_00
mov a,digital_flash_time
cpl acc.7
anl a,#80h
mov digital_flash_time,a
jmp digital_display_01
digital_display_00: inc digital_flash_time
digital_display_01: pop a
jb acc.7,digital_display_1 ;最高位表示现在是否选择了该位,若是则闪烁
digital_display_0: mov dptr,#data_tab_digital
movc a,@a+dptr
cpl a ;数据是共阴数码管的,用在共阳数码管上就需要取反
mov p2,#0
mov p0,a
mov a,digital_bit
mov p2,a
rl a
mov digital_bit,a
call time2_5ms
ret
digital_display_1: push a
mov a,digital_flash_time
jb acc.7,digital_display_2
pop a ;若最高位为零则消隐
mov a,#20h
jmp digital_display_0
digital_display_2: pop a ;否则正常显示
clr acc.7
jmp digital_display_0
;*****************************************************
;共阴数码管显示数据
;排列为:0-F, 0.-F.
;端口排列:p07 p06 p05 p04 p03 p02 p01 p00
;段排列为: d dp e c g b f a
;*****************************************************
data_tab_digital: db 0b7h,014h,0adh,09dh,01eh,09bh,0bbh,015h
db 0bfh,09fh,03fh,0bah,0a8h,0bch,0abh,02bh
db 0f7h,054h,0edh,0ddh,05eh,0dbh,0fbh,055h
db 0ffh,0dfh,07fh,0fah,0e8h,0fch,0ebh,06bh
db 000h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -