P3.3输入一个电平,P0输出! ;实验5---P3.3口输入、P1口输出 ; KEY_P33 EQU P3.3 ORG 00H LJMP INIT ORG 30H INIT: MOV R0 , #0x00 MOV R1 , #0x0FF MAIN: MOV P3 , #0FFH JNB KEY_P33 , readKeyValue ;若有按键按下则跳转到 readKeyValue SJMP MAIN readKeyValue: CALL DELAY10MS ;调用延时函数,消抖 JNB KEY_P33 , $ ;松手检测 CALL DLY50MS JNB KEY_P33 , showNum showNum: I NC R0 MOV A , R0 MOV P0 , A LJMP MAIN ;延时50Ms的子程序 DLY50MS:MOV R7 , #200 DEL1: MOV R6 , #125 DEL2: DJNZ R6 , DEL2 DJNZ R7 , DEL1 RET ;*************; ; 延时程序 ; ;*************; DELAY10MS: MOV R6 , #015H DE1: MOV R7 , #0F8H DE2: DJNZ R7 , DE2 DJNZ R6 , DE1 RET END NC R0 MOV A , R0 MOV P0 , A LJMP MAIN ;延时50Ms的子程序 DLY50MS:MOV R7 , #200 DEL1: MOV R6 , #125 DEL2: DJNZ R6 , DEL2 DJNZ R7 , DEL1 RET ;*************; ; 延时程序 ; ;*************; DELAY10MS: MOV R6 , #015H DE1: MOV R7 , #0F8H DE2: DJNZ R7 , DE2 DJNZ R6 , DE1 RET END