#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit led0=P1^0;
sbit led1=P1^1;
sbit led2=P1^2;
sbit led3=P1^3;
uint num;
uchar bai,shi,ge,xiao,count,temp,t;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7C,0x39,0x5E,0x79,0x71};
void delay(int k);
void display(uchar bai,uchar shi,uchar ge,uchar xiao);
void main()
{
temp=0xfe;
t=0;
P3=temp;
TMOD=0x11;
count=0;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR0=1;
P0=table[0];
num=5666;
count=0;
while(1)
{
display(bai,shi,ge,xiao);
}
}
void T1_time() interrupt 3
{
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
count++;
if(count==2)
{
count=0;
num--;
if(num==5555)
TR1=0;
TR0=0;
}
}
void delay(int k)
{
while(k--);
}
void T0_time() interrupt 1
{
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
t++;
if(t==10)
{
t=0;
temp=_crol_(temp,1);
P3=temp;
}
}
void display(uchar bai,uchar shi,uchar ge,uchar xiao)
{
bai=num/1000;
shi=num%1000/100;
ge=num%100/10;
xiao=num%10;
P0=table[bai];
led0=0;
delay(200);
led0=1;
P0=table[shi];
led1=0;
delay(200);
led1=1;
P0=table[ge];
led2=0;
delay(200);
led2=1;
P0=table[xiao];
led3=0;
delay(200);
led3=1;
}