C51源代码:
/*闪烁灯程序*/
#include<reg51.h>
void delay()
{
unsigned char i,j,k;
for(i=0;i<=20;i++)
for(j=0;j<=100;j++)
for(k=0;k<=248;k++);
}
int main()
{
unsigned char led;
led="0xff";
do
{
P0=led;
delay();
P0=~led;
delay();
}
while(1);
}
汇编源代码:
;闪烁灯程序
ORG 0000H
AJMP START
ORG 30H
START: MOV A,#0FFH
MOV P0,A
ACALL DELAY
CPL A
MOV P0,A
ACALL DELAY
AJMP START
DELAY:MOV R7,#20
DEL1: MOV R6,#100
DEL2: MOV R5,#248
DJNZ R5,$
DJNZ R6,DEL2
DJNZ R7,DEL1
RET
END
文章评论(0条评论)
登录后参与讨论