四位數(shù)碼管顯示2012的匯編語(yǔ)言與C語(yǔ)言
其對(duì)應(yīng)的C應(yīng)用如下:
#include
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
sbit p23=P2^3;
void delay(unsigned int z)
{
while(z--);
}
void main()
{
P2=0x00;
while(1)
{
p20=1;
P0=0XA4;
delay(500);
p20=0;
p21=1;
P0=0XC0;
delay(500);
p21=0;
p22=1;
P0=0XF9;
delay(500);
p22=0;
p23=1;
P0=0XA4;
delay(500);
p23=0;
}
}
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
sbit p23=P2^3;
void delay(unsigned int z)
{
while(z--);
}
void main()
{
P2=0x00;
while(1)
{
p20=1;
P0=0XA4;
delay(500);
p20=0;
p21=1;
P0=0XC0;
delay(500);
p21=0;
p22=1;
P0=0XF9;
delay(500);
p22=0;
p23=1;
P0=0XA4;
delay(500);
p23=0;
}
}
其對(duì)應(yīng)的匯編語(yǔ)言如下:
ORG 0000H
MOV P2,#00H
LOOP:SETB P2.0
MOV P0,#0XA4
ACALL DELAY
CLR P2.0
SETB P2.1
MOV P0,#0XC0
ACALL DELAY
CLR P2.1
SETB P2.2
MOV P0,#0XF9
ACALL DELAY
CLR P2.2
SETB P2.3
MOV P0,#0XA4
ACALL DELAY
CLR P2.3
AJMP LOOP
DELAY:MOV R7,#255
DJNZ R7,$
RET
END
MOV P2,#00H
LOOP:SETB P2.0
MOV P0,#0XA4
ACALL DELAY
CLR P2.0
SETB P2.1
MOV P0,#0XC0
ACALL DELAY
CLR P2.1
SETB P2.2
MOV P0,#0XF9
ACALL DELAY
CLR P2.2
SETB P2.3
MOV P0,#0XA4
ACALL DELAY
CLR P2.3
AJMP LOOP
DELAY:MOV R7,#255
DJNZ R7,$
RET
END
評(píng)論