8个LED在P0口,0有效,P0.7灯在最下面,8个按钮在P3口
RESET:MOV P3,#0FFH
MOV P0,#0FFH
MLOOP:MOV A ,P3
MOV R6,#0
MOV R7,#8
TCLOP:RLC A
JC NEXT
INC R6
NEXT: DJNZ R7,TCLOP
CJNE R6,#0 ,DIP0
MOV P0,#0FFH
SJMP MLOOP
DIP0: MOV A,#0FEH
DIPN: RR A
DJNZ R6,DIPN
MOV P0,A
SJMP MLOOP
END
仿真效果如下