完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
求帮助啊 哪位大神帮忙看看 这两个程序哪个命令可以控制灯亮啊 感谢啊
程序一: LEDDUAN EQU 8004H LEDWEI EQU 8002H KVALUE EQU 52H NUM EQU 50H ORG 0000H LJMP MAIN ORG 000BH LJMP COUNT ORG 0100H MAIN: CLR A CLR B MOV R0,#00H MOV R1,#00H MOV R2,#00H MOV R3,#00H MOV R4,#00H MOV R5,#00H MOV NUM,#10 MOV SP,#70H MOV DPTR,#LEDDUAN MOV A,#00H MOVX @DPTR,A MOV DPTR,#LEDWEI MOV A,#00H MOVX @DPTR,A J1S: MOV TMOD,#01H MOV TH0,#3CH MOV TL0,#0B0H SETB EA SETB ET0 SETB TR0 START: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,tiME LCALL CHANGE TIME: CJNE R0,#60,NEXT2 ;SECOND MOV R0,#00H INC R1 CJNE R1,#60,NEXT2 ;MINUTE MOV R1,#00H INC R2 CJNE R2,#24,NEXT2 ;HOUR MOV R2,#00H NEXT2: SJMP START ;***********CHANGE TIME**************** CHANGE: CLR TR0 CHOUR: MOV R5,#01H CHOUR2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY1 LJMP CMIN KEY1: CJNE A,#10H,KEY2 LJMP ADHOUR KEY2: LJMP CHOUR2 ADHOUR:INC R2 CJNE R2,#24,JHOUR MOV R2,#00H JHOUR: LJMP CHOUR2 CMIN: MOV R5,#02H CMIN2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY3 LJMP CSEC KEY3: CJNE A,#10H,KEY4 LJMP ADMIN KEY4: LJMP CMIN2 ADMIN: INC R1 CJNE R1,#60,JMIN MOV R1,#00H JMIN: LJMP CMIN2 CSEC: MOV R5,#03H CSEC2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY5 LJMP EXCH KEY5: CJNE A,#10H,KEY6 LJMP ADSEC KEY6: LJMP CSEC2 ADSEC: INC R0 CJNE R0,#60,JSEC MOV R0,#00H JSEC: LJMP CSEC2 EXCH: MOV TH0,#3CH MOV TL0,#0B0H MOV R5,#00H SETB TR0 RET ;*************END*************** ;***********DISPLAY************* DISPLAY:MOV DPTR,#LEDWEI ;HOUR MOV A,#20H MOVX @DPTR,A MOV A,R2 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#01H,CMOD0 ORL A,#80H ;POINT CMOD0: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#10H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU1 SJMP POI1 JU1: CJNE R5,#01H,CMOD1 POI1: ORL A,#80H ;POINT CMOD1: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI ;MINUTE MOV A,#08H MOVX @DPTR,A MOV A,R1 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#02H,CMOD2 ORL A,#80H ;POINT CMOD2: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#04H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU2 SJMP POI2 JU2: CJNE R5,#02H,CMOD3 POI2: ORL A,#80H ;POINT CMOD3: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI ;SECOND MOV A,#02H MOVX @DPTR,A MOV A,R0 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#03H,CMOD4 ORL A,#80H ;POINT CMOD4: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#01H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU3 SJMP POI3 JU3: CJNE R5,#03H,CMOD5 POI3: ORL A,#80H ;POINT CMOD5: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS RET ;**********END************** D2MS: MOV R4,#0AH DL2: MOV R3,#32H DL1: NOP NOP DJNZ R3,DL1 DJNZ R4,DL2 RET D10MS: MOV R4,#64H DL4: MOV R3,#14H DL3: NOP NOP NOP DJNZ R3,DL3 DJNZ R4,DL4 RET COUNT: DJNZ NUM,NEXT INC R0 MOV NUM,#10 NEXT: MOV TH0,#3CH MOV TL0,#0B0H RETI ;*******KEYBOARD************* KEYBOARD:MOV P1,#0FFH MOV KVALUE,#16H ;************************* WAIT: MOV A,P1 ANL A,#03H XRL A,#03H JZ NOKEY1 LCALL D10MS MOV A,P1 ANL A,#03H XRL A,#03H JZ NOKEY1 MOV A,P1 ANL A,#03H CJNE A,#02H,NK1 MOV KVALUE,#0FFH LJMP DK1A NK1: CJNE A,#01H,DK1A MOV KVALUE,#10H DK1A: MOV A,P1 ANL A,#03H XRL A,#03H JNZ DK1A ;*********LIE-2*************** NOKEY1: RET ;********END************ LEDTAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH 程序二: LEDDUAN EQU 8004H LEDWEI EQU 8002H KEYBUF EQU 51H KEYC EQU 8001H KEYA EQU 8002H KVALUE EQU 52H NUM EQU 50H ORG 0000H LJMP MAIN ORG 000BH LJMP COUNT ORG 0100H MAIN: CLR A CLR B MOV R0,#00H MOV R1,#00H MOV R2,#00H MOV R3,#00H MOV R4,#00H MOV R5,#00H MOV NUM,#10 MOV SP,#70H MOV DPTR,#LEDDUAN MOV A,#00H MOVX @DPTR,A MOV DPTR,#LEDWEI MOV A,#00H MOVX @DPTR,A J1S: MOV TMOD,#01H MOV TH0,#3CH MOV TL0,#0B0H SETB EA SETB ET0 SETB TR0 START: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,TIME LCALL CHANGE TIME: CJNE R0,#60,NEXT2 ;SECOND MOV R0,#00H INC R1 CJNE R1,#60,NEXT2 ;MINUTE MOV R1,#00H INC R2 CJNE R2,#24,NEXT2 ;HOUR MOV R2,#00H NEXT2: SJMP START ;***********CHANGE TIME**************** CHANGE: CLR TR0 CHOUR: MOV R5,#01H CHOUR2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY1 LJMP CMIN KEY1: CJNE A,#10H,KEY2 LJMP ADHOUR KEY2: LJMP CHOUR2 ADHOUR:INC R2 CJNE R2,#24,JHOUR MOV R2,#00H JHOUR: LJMP CHOUR2 CMIN: MOV R5,#02H CMIN2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY3 LJMP CSEC KEY3: CJNE A,#10H,KEY4 LJMP ADMIN KEY4: LJMP CMIN2 ADMIN: INC R1 CJNE R1,#60,JMIN MOV R1,#00H JMIN: LJMP CMIN2 CSEC: MOV R5,#03H CSEC2: LCALL DISPLAY LCALL KEYBOARD MOV A,KVALUE CJNE A,#0FFH,KEY5 LJMP EXCH KEY5: CJNE A,#10H,KEY6 LJMP ADSEC KEY6: LJMP CSEC2 ADSEC: INC R0 CJNE R0,#60,JSEC MOV R0,#00H JSEC: LJMP CSEC2 EXCH: MOV TH0,#3CH MOV TL0,#0B0H MOV R5,#00H SETB TR0 RET ;*************END*************** ;***********DISPLAY************* DISPLAY:MOV DPTR,#LEDWEI ;HOUR MOV A,#20H MOVX @DPTR,A MOV A,R2 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#01H,CMOD0 ORL A,#80H ;POINT CMOD0: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#10H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU1 SJMP POI1 JU1: CJNE R5,#01H,CMOD1 POI1: ORL A,#80H ;POINT CMOD1: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI ;MINUTE MOV A,#08H MOVX @DPTR,A MOV A,R1 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#02H,CMOD2 ORL A,#80H ;POINT CMOD2: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#04H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU2 SJMP POI2 JU2: CJNE R5,#02H,CMOD3 POI2: ORL A,#80H ;POINT CMOD3: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI ;SECOND MOV A,#02H MOVX @DPTR,A MOV A,R0 MOV B,#10 DIV AB MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#03H,CMOD4 ORL A,#80H ;POINT CMOD4: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS MOV DPTR,#LEDWEI MOV A,#01H MOVX @DPTR,A MOV A,B MOV DPTR,#LEDTAB MOVC A,@A+DPTR CJNE R5,#00H,JU3 SJMP POI3 JU3: CJNE R5,#03H,CMOD5 POI3: ORL A,#80H ;POINT CMOD5: MOV DPTR,#LEDDUAN MOVX @DPTR,A LCALL D2MS RET ;**********END************** D2MS: MOV R4,#0AH DL2: MOV R3,#32H DL1: NOP NOP DJNZ R3,DL1 DJNZ R4,DL2 RET D10MS: MOV R4,#64H DL4: MOV R3,#14H DL3: NOP NOP NOP DJNZ R3,DL3 DJNZ R4,DL4 RET COUNT: DJNZ NUM,NEXT INC R0 MOV NUM,#10 NEXT: MOV TH0,#3CH MOV TL0,#0B0H RETI ;*******KEYBOARD************* KEYBOARD:MOV DPTR,#KEYC MOV A,#0FFH MOVX @DPTR,A MOV DPTR,#KEYA MOVX @DPTR,A MOV KVALUE,#16H ;*********LIE-1**************** WAIT: MOV DPTR,#KEYA MOV A,#01FH MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY1 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY1 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK1 MOV KEYBUF,#0 LJMP DK1 NK1: CJNE A,#0BH,NK2 MOV KEYBUF,#1 LJMP DK1 NK2: CJNE A,#0DH,NK3 MOV KEYBUF,#2 LJMP DK1 NK3: CJNE A,#0EH,NK4 MOV KEYBUF,#3 LJMP DK1 NK4: NOP DK1: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK1A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK1A ;*********LIE-2*************** NOKEY1:MOV DPTR,#KEYA MOV A,#02FH MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY2 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY2 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK5 MOV KEYBUF,#4 LJMP DK2 NK5: CJNE A,#0BH,NK6 MOV KEYBUF,#5 LJMP DK2 NK6: CJNE A,#0DH,NK7 MOV KEYBUF,#6 LJMP DK2 NK7: CJNE A,#0EH,NK8 MOV KEYBUF,#7 LJMP DK2 NK8: NOP DK2: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK2A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK2A ;*********LIE-3************** NOKEY2:MOV DPTR,#KEYA MOV A,#037H MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY3 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY3 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK9 MOV KEYBUF,#8 LJMP DK3 NK9: CJNE A,#0BH,NK10 MOV KEYBUF,#9 LJMP DK3 NK10: CJNE A,#0DH,NK11 MOV KEYBUF,#10 LJMP DK3 NK11: CJNE A,#0EH,NK12 MOV KEYBUF,#11 LJMP DK3 NK12: NOP DK3: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK3A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK3A ;********LIE-4*********** NOKEY3:MOV DPTR,#KEYA MOV A,#03BH MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY4 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY4 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK13 MOV KEYBUF,#12 LJMP DK4 NK13: CJNE A,#0BH,NK14 MOV KEYBUF,#13 LJMP DK4 NK14: CJNE A,#0DH,NK15 MOV KEYBUF,#14 LJMP DK4 NK15: CJNE A,#0EH,NK16 MOV KEYBUF,#15 LJMP DK4 NK16: NOP DK4: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK4A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK4A ;*******LIE-5******** NOKEY4:MOV DPTR,#KEYA MOV A,#03DH MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY5 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY5 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK17 MOV KEYBUF,#16 LJMP DK5 NK17: CJNE A,#0BH,NK18 MOV KEYBUF,#17 LJMP DK5 NK18: CJNE A,#0DH,NK19 MOV KEYBUF,#18 LJMP DK5 NK19: CJNE A,#0EH,NK20 MOV KEYBUF,#19 LJMP DK5 NK20: NOP DK5: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK5A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK5A ;*********LIE-6************ NOKEY5:MOV DPTR,#KEYA MOV A,#03EH MOVX @DPTR,A MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY6 LCALL D10MS MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JZ NOKEY6 MOVX A,@DPTR ANL A,#0FH CJNE A,#07H,NK21 MOV KEYBUF,#20 LJMP DK6 NK21: CJNE A,#0BH,NK22 MOV KEYBUF,#21 LJMP DK6 NK22: CJNE A,#0DH,NK23 MOV KEYBUF,#22 LJMP DK6 NK23: CJNE A,#0EH,NK24 MOV KEYBUF,#23 LJMP DK6 NK24: NOP DK6: MOV A,KEYBUF MOV DPTR,#KEYTAB MOVC A,@A+DPTR MOV KVALUE,A DK6A: MOV DPTR,#KEYC MOVX A,@DPTR ANL A,#0FH XRL A,#0FH JNZ DK6A ;**************************** NOKEY6: RET ;********END************ KEYTAB: DB 16H,15H,14H,0FFH DB 13H,12H,11H,10H DB 0DH,0CH,0BH,0AH DB 0EH,03H,06H,09H DB 0FH,02H,05H,08H DB 00H,01H,04H,07H LEDTAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
|
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
417 浏览 0 评论
430 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
393 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-LCD显示图片编程示例之介绍mmap
974 浏览 0 评论
《DNESP32S3使用指南-IDF版_V1.6》第二章 常用的C语言知识点
1055 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11779 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 00:16 , Processed in 0.623801 second(s), Total 70, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号