花样流水灯的设计4(单片机-汇编)
; maker:Chen Weiwu
; date:2012-11-08
; version:1.0.0
;-------------------------------------------------------------
;Define
Ledprt equ p0
SegDisplay equ p2
Button equ p1
ButtonState equ 30h
;----------------------
;Set the initiation address which the program runing
;----------------------
org 0
ajmp main
;-----------------------
Cycle:
mov a,#low(Tables)
add a,r1
mov dpl,a
clr a
addc a,#high(Tables)
mov dph,a
;---------------------- Get Tables Address
clr a
movc a,@a+dptr
mov r1,a
mov a,#1
movc a,@a+dptr
mov dpl,a
mov dph,r1
;----------------------
clr a
movc a,@a+dptr ;Get the count of data in table
mov r0,a
inc dptr
;----------------------
mov ButtonState,button ;Save button
Loop:
mov a,button
cjne a,ButtonState,ExitCycle ;Buttion is change
clr a
movc a,@a+dptr
mov Ledprt,a
acall delay
inc dptr
djnz r0,Loop
ExitCycle:
ret
;-----------------------
;-----------------------
;delay sub
delay: mov r5,#50
delay1: mov r6,#100
DELAY2: mov r7,#10
djnz r7,$
djnz r6,delay2
djnz r5,delay1
ret
;-----------------------
ButtonTable:
;--------ONE BUTTON--------
db 11111110B
DB 11111101B
db 11111011B
DB 11110111B
;--------TWO BUTTON--------
DB 11111100B
db 11111010B
DB 11110110B
DB 11111001B
db 11110101B
DB 11110011B
;-------THREE BUTTON-------
DB 11111000B
DB 11110100B
DB 11110010B
DB 11110001B
;-------FOUR BUTTON-------
DB 11110000B
DB 0
;-----------------------
Tables: dw Table1,Table2,Table3,Table4
dw Table5,Table6,Table7,Table8,Table9,Table10
dw Table11,Table12,Table13,Table14
dw Table15
dw 0
;-----------------------
Table1: db Table2-$-1
db 11101111b
db 11011111b
db 10111111b
db 01111111b
db 11111110b
db 11111101b
db 11111011b
db 11110111b
db 11111011b
db 11111101b
db 11111110b
db 01111111b
db 10111111b
db 11011111b
Table2: db Table3-$-1
db 01111110b
db 10111101b
db 11011011b
db 11100111b
db 11011011b
db 10111101b
Table3: db Table4-$-1
db 01010101b
db 00000000b
db 10101010b
db 00000000b
Table4: db Table5-$-1
db 11111110b
db 11111100b
db 11111000b
db 11110000b
db 11100000b
db 11000000b
db 10000000b
db 00000000b
db 00000001b
db 00000011b
db 00001111b
db 00011111b
db 00111111b
db 01111111b
db 11111111b
Table5: db Table6-$-1
db 00000000b
db 11111111b
Table6: db Table7-$-1
db 00001111b
db 00011110b
db 00111100b
db 01111000b
db 11110000b
db 01111111b
db 00111111b
db 00011111b
Table7: db Table8-$-1
db 00110110b
db 01010110b
db 01100110b
db 01101010b
db 01101100b
db 01101010b
db 01100110b
db 01010110b
Table8: db Table9-$-1
db 01110111b
db 10110111b
db 11010111b
db 11100111b
db 11101011b
db 11101101b
db 11101110b
db 11101101b
db 11101011b
db 11100111b
db 11010111b
db 10110111b
Table9: db Table10-$-1
db 11100111b
花样流水灯单片机汇 相关文章:
- 花样流水灯的设计2(单片机-汇编)(11-30)
- 花样流水灯的设计1(单片机-汇编)(11-29)
- 花样流水灯的设计3(单片机-汇编)(11-29)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)