P1.0接按钮,P1.1接LED,高电平亮 ORG 0000HAJMP MAINORG 0030HMAIN: MOV A,#0CLR P1.1LOOP: JB P1.0,LOOPACALL DELAYJB P1.0,LOOPINC ACJNE A,#1,L_2SETB P1.1AJMP LOOPL_2: CJNE A,#2,L_3CLR P1.1MOV A,#0L_3: AJMP LOOP
DELAY:MOV R7,#50D1: MOV R6,#255DJNZ R6,$DJNZ R7,D1RET
END