LED1 BIT P2.4 LED2 BIT P2.5 LED3 BIT P2.6 LED4 BIT P2.7 KEY1 BIT P3.2 KEY2 BIT P3.4 BEEP BIT P1.0 DelayTimes_100MS EQU 6FH ; 将地址6FH用伪指令命名为DelayTimes_100MS KEY1_State DATA 69H ; 将地址69H用伪指令命名为KEY1_State CLR BEEP SETB LED1 SETB LED2 SETB LED3 SETB LED4 LOOP: JB KEY1,KEY_OFF MOV DelayTimes_100MS,#4 ;按键去抖 LCALL Delay100MS KEY_ON: MOV A,KEY1_State RL A ADD A,KEY1_State MOV DPTR, #KEY1_Flash JMP @A+DPTR KEY1_Flash: LJMP KEY1_Flash0 ;0 LJMP KEY1_Flash1 ;3 LJMP KEY1_Flash2 ;6 LJMP KEY1_Flash3 ;9 LJMP KEY1_Flash4 ;12 KEY1_Flash0: CLR LED1 SETB LED2 SETB LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash1: CLR LED1 CLR LED2 SETB LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash2: CLR LED1 CLR LED2 CLR LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash3: CLR LED1 CLR LED2 CLR LED3 CLR LED4 INC KEY1_State AJMP LOOP KEY1_Flash4: SETB LED1 SETB LED2 SETB LED3 SETB LED4 MOV KEY1_State,#0 AJMP LOOP KEY_OFF: AJMP LOOP Delay100MS: MOV R7,DelayTimes_100MS Delay100MS_1: MOV R6,#10 Delay100MS_2: MOV R5,#150 Delay100MS_3: MOV R4,#200 Delay100MS_4: DJNZ R4, Delay100MS_4 DJNZ R5, Delay100MS_3 DJNZ R6, Delay100MS_2 DJNZ R7, Delay100MS_1 RET ;子程序返回 END
LED1 BIT P2.4 LED2 BIT P2.5 LED3 BIT P2.6 LED4 BIT P2.7 KEY1 BIT P3.2 KEY2 BIT P3.4 BEEP BIT P1.0 DelayTimes_100MS EQU 6FH ; 将地址6FH用伪指令命名为DelayTimes_100MS KEY1_State DATA 69H ; 将地址69H用伪指令命名为KEY1_State CLR BEEP SETB LED1 SETB LED2 SETB LED3 SETB LED4 LOOP: JB KEY1,KEY_OFF MOV DelayTimes_100MS,#4 ;按键去抖 LCALL Delay100MS KEY_ON: MOV A,KEY1_State RL A ADD A,KEY1_State MOV DPTR, #KEY1_Flash JMP @A+DPTR KEY1_Flash: LJMP KEY1_Flash0 ;0 LJMP KEY1_Flash1 ;3 LJMP KEY1_Flash2 ;6 LJMP KEY1_Flash3 ;9 LJMP KEY1_Flash4 ;12 KEY1_Flash0: CLR LED1 SETB LED2 SETB LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash1: CLR LED1 CLR LED2 SETB LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash2: CLR LED1 CLR LED2 CLR LED3 SETB LED4 INC KEY1_State AJMP LOOP KEY1_Flash3: CLR LED1 CLR LED2 CLR LED3 CLR LED4 INC KEY1_State AJMP LOOP KEY1_Flash4: SETB LED1 SETB LED2 SETB LED3 SETB LED4 MOV KEY1_State,#0 AJMP LOOP KEY_OFF: AJMP LOOP Delay100MS: MOV R7,DelayTimes_100MS Delay100MS_1: MOV R6,#10 Delay100MS_2: MOV R5,#150 Delay100MS_3: MOV R4,#200 Delay100MS_4: DJNZ R4, Delay100MS_4 DJNZ R5, Delay100MS_3 DJNZ R6, Delay100MS_2 DJNZ R7, Delay100MS_1 RET ;子程序返回 END
举报