《单片机矩阵键盘汇编语言程序(共6页).doc》由会员分享,可在线阅读,更多相关《单片机矩阵键盘汇编语言程序(共6页).doc(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上51单片机4*4矩阵键盘汇编语言程序示例(原创)QQ:,欢迎咨询线反转法ORG 00HLJMP MAINMAIN:MOV R0,#00HMOV R1,#00HMOV R2,#00HMOV R3,#00HMOV A,#00HAJMP KEYSCANKEYSCAN:MOV P3,#0F0HMOV A,P3ANL A,#0F0HXRL A,#0F0HJNZ DELAYDELAY:MOV R2,#05HLOOP1:MOV R3,#0FAHLOOP2:DJNZ R3,LOOP2DJNZ R2,LOOP1MOV A,P3ANL A,#0F0HMOV R0,AXRL A,#0F0H
2、JNZ KEYSCAN1LJMP KEYSCANKEYSCAN1:MOV A,#00HMOV P3,#0FHMOV A,P3ANL A,#0FHMOV R1,AXRL A,#0FHJNZ NUMLJMP KEYSCANNUM:MOV A,R0MOV B,R1ORL A,BMOV DPTR,#TABSJMP DISP0DISP0:CJNE A,#0EEH,DISP1MOV A,#00HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP1:CJNE A,#0EDH,DISP2MOV A,#01HMOVC A,A+DPTRMOV P0,ALCALL D
3、ELAY1LJMP KEYSCANDISP2:CJNE A,#0EBH,DISP3MOV A,#02HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP3:CJNE A,#0E7H,DISP4MOV A,#03HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP4:CJNE A,#0DEH,DISP5MOV A,#04HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP5:CJNE A,#0DDH,DISP6MOV A,#05HMOVC A,A+DPT
4、RMOV P0,ALCALL DELAY1LJMP KEYSCANDISP6:CJNE A,#0DBH,DISP7MOV A,#06HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP7:CJNE A,#0D7H,DISP8MOV A,#07HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP8:CJNE A,#0BEH,DISP9MOV A,#08HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISP9:CJNE A,#0BDH,DISPAMOV A,
5、#09HMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPA:CJNE A,#0BBH,DISPBMOV A,#0AHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPB:CJNE A,#0B7H,DISPCMOV A,#0BHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPC:CJNE A,#07EH,DISPDMOV A,#0CHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPD:CJNE A,#
6、07DH,DISPEMOV A,#0DHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPE:CJNE A,#07BH,DISPFMOV A,#0EHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDISPF:CJNE A,#077H,KEYMOV A,#0FHMOVC A,A+DPTRMOV P0,ALCALL DELAY1LJMP KEYSCANDELAY1:MOV R2,#0FHLOOP10:MOV R3,#0FAHLOOP20:DJNZ R3,LOOP20DJNZ R2,LOOP10RETKEY:
7、LJMP MAINTAB:DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71HEND行扫描法ORG 00HLJMP MAINMAIN:LCALL KEYJUDGELCALL KEYSCANLCALL DISPLJMP MAINKEYJUDGE:MOV P3,#0F0HMOV A,P3XRL A,#0F0HJNZ DELAYLJMP MAINDELAY:MOV R4,#08HLOOP1:MOV R5,#0FAHLOOP2:DJNZ R5,LOOP2DJNZ R4,LOOP1MOV P3,#0F0HMOV A,P3XR
8、L A,#0F0HJZ MAIN RETKEYSCAN:MOV R0,#00HMOV R1,#00HMOV R2,#0FEHMOV R3,#04HKEY:MOV P3,R2KEY0:JB P3.4,KEY1MOV R1,#00HLJMP NUMKEY1:JB P3.5,KEY2MOV R1,#04HLJMP NUMKEY2:JB P3.6,KEY3MOV R1,#08HLJMP NUMKEY3:JB P3.7,NEXTMOV R1,#0CHLJMP NUMNEXT:INC R0MOV A,R2RL AMOV R2,ADJNZ R3,KEYLJMP NUMNUM:MOV A,R0ADD A,R1MOV DPTR,#TABMOVC A,A+DPTRMOV R6,ARETDISP:MOV P0,R6LCALL DELAY1RETDELAY1:MOV R4,#0FHLOOP10:MOV R5,#0FAHLOOP20:DJNZ R5,LOOP20DJNZ R4,LOOP10RETTAB:DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71HEND专心-专注-专业