;This program will show you cycle glitter between 8 led lamps; maker:Chen Weiwu; date:2012-11-08; version:1.0.0;-------------------------------------------------------------;DefineLedprt equ p0SegDisplay equ p2Button equ p1;----------------------;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 clr a movc a,@a+dptr mov dpl,a ;---------------------- clr a movc a,@a+dptr ;Get the count of data in table mov r0,a inc dptr ;----------------------Loop: mov a,button ;buttion is unable cpl a jz ExitCycle clr a movc a,@a+dptr mov Ledprt,a acall delay inc dptr djnz r0,LoopExitCycle: ret;-----------------------;-----------------------;delay subdelay: mov r5,#50delay1: mov r6,#100DELAY2: mov r7,#10 djnz r7,$ djnz r6,delay2 djnz r5,delay1 ret ;-----------------------Tables: dw Table1,Table2,Table3,Table4,0;-----------------------Table1: db Table2-$-1 db 11111110b db 11111101b db 11111011b db 11110111b db 11101111b db 11011111b db 10111111b db 01111111b 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 TableEnd-$-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 TableEnd:;-----------------------main: mov Ledprt,#11111111B mov r2,#0 mov r3,#01111111b mov SegDisplay,#00H ;Initiate the SegDisplayToNext: cjne r2,#5,ToNext1 ajmp MainToNext1: inc r2 ;Button Number mov a,r3 rl a mov r3,a cjne a,button,ToNext ;Check whether the button is enable or not mov SegDisplay,r2 ;button is enable,Show on the SegDisplay mov a,r2 rl a clr c subb a,#1 ;Location in the Tables mov r1,a mov a,r3 cjne a,button,main acall Cycle ajmp Main;----------------------- end;-------------------------------------------------------------
-电子元器件采购网(www.ruidan.com)是本土元器件目录分销商,采用“小批量、现货、样品”销售模式,致力于满足客户多型号、高质量、快速交付的采购需求。 自建高效智能仓储,拥有自营库存超过50,000种,提供一站式正品现货采购、个性化解决方案、选型替代等多元化服务。