for(j=0;j<1000;j++);
}
main()
{
unsigned LED,i;
LED = 0xfe;
EA = 0;
while(1)
{
for(i=0;i<7;i++){delay(100);LED = (LED<<1)|0x01;P3 = LED;}
for(i=0;i<7;i++){delay(100);LED = (LED>>1)|0x80;P3 = LED;}
}
}
汇编语言
LED EQU 30H
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CLR EA
MOV SP,#5FH
MOV LED,#0FEH
MOV R0,#7
LOOP:
MOV R7,#50
LCALL DELAY
MOV A,LED
RL A
MOV LED,A
MOV P3,A
DJNZ R0,LOOP
MOV R0,#7
LOOP1:
MOV R7,#50
LCALL DELAY
MOV A,LED
RR A
MOV LED,A
MOV P3,A
DJNZ R0,LOOP1
MOV R0,#7
SJMP LOOP
;----------------------------
DELAY:
MOV R2,#8
DLY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DLY1
DJNZ R7,DELAY
RET
;-----------------------------
END