MAIN:
NOP
NOP
ADI F_TIMER,0001B
BA0 HALTMODE ;未到5ms, 跳转
ANDIM F_TIMER,1110B ;清"5ms 到"标志
NOP
LDA PORTD,00H
STA TEMP,00H
SBI TEMP,0FH;=0,没有按键动作跳走
BAZ YS_4
ADIM TEMP5,01H
SBI TEMP5,01H;是否是第一次按键按下是的话存起来初次按键值
BAZ YS_5
LDA KEY_OLD,00H
SUB TEMP,00H
BNZ YS_4
SBI TEMP5,03H;扫描8次按键未完成继续扫描
BNZ MAIN
ANDIM TEMP5,00H
LDA T0M_1,00H;判断开机标志位
BA0 YS_8
LDA TEMP,00H
BA0 YS_4
AS_1:
ORIM T0M_1,01H;设置开机标志
JMP MAIN
YS_8:
LDA KEY_OLD,00H
BA1 YS_4
JMP YS_7
HALTMODE:
NOP
HALT
NOP
NOP
JMP MAIN
YS_4:
ANDIM F_TIMER,1110B
ANDIM TEMP5,00H
JMP MAIN
YS_5:
LDA TEMP,00H
STA KEY_OLD,00H
RTNI
YS_7:
LDI PORTC,0FH
ADI F_TIMER,0010B
BA1 YS_7
ANDIM F_TIMER,1101B
LDI PORTC,00H
JMP
MAIN
END |