OUTBIT equ 08002h ; 位控制口
OUTSEG equ 08004h ; 段控制口
IN equ 08001h ; 键盘读入口
LEDBuf equ 60h ; 显示缓冲
Hour equ 40h
Minute equ 41h
Second equ 42h
C100us equ 43h
Tick equ 10000
T100us equ 256-50
ljmp Start
org 000bh
T0Int:
push PSW
push ACC
mov a, C100us+1
jnz Goon
dec C100us
Goon:
dec C100us+1
mov a, C100us
orl a, C100us+1
jnz Exit
mov C100us, #high(Tick)
mov C100us+1, #low(Tick)
inc Second
mov a, Second
cjne a, #60, Exit
mov Second, #0
inc Minute
mov a, Minute
cjne a, #60, Exit
mov Minute, #0
inc Hour
mov a, Hour
cjne a, #24, Exit
mov Hour, #0
Exit:
pop ACC
pop PSW
reti
Delay: ; 延时子程序
mov r7, #0
DelayLoop:
djnz r7, DelayLoop
djnz r6, DelayLoop
ret
LEDMAP: ; 八段管显示码
db 3fh, 06h, 5bh, 4fh, 66h, 6dh, 7dh, 07h
db 7fh, 6fh, 77h, 7ch, 39h, 5eh, 79h, 71h
DisplayLED:
mov r0, #LEDBuf
mov r1, #6 ; 共6个八段管
mov r2, #00100000b ; 从左边开始显示
Loop:
mov dptr, #OUTBIT
mov a, #0
movx @dptr, a ; 关所有八段管
mov a, @r0
mov dptr, #OUTSEG
movx @dptr,a
mov dptr, #OUTBIT
mov a, r2
movx @dptr, a ; 显示一位八段管
mov r6, #1
call Delay
mov a, r2 ; 显示下一位
rr a
mov r2, a
inc r0
djnz r1, Loop
ret
; ===============================================
还有一半的程序,因为一个太长发不了,在下一个.