#include<stdio.h>
#include<reg51.h>
sbit P20=P2^0;
sbit P21=P2^1;
sbit P32=P3^2;
sbit P00=P0^0;
sbit P01=P0^1;
sbit P02=P0^2;
sbit P03=P0^3;
sbit P04=P0^4;
sbit P05=P0^5;
sbit P06=P0^6;
sbit P07=P0^7;
sbit P17=P1^7;
unsigned int xx=9;
unsigned int yy=0;
unsigned char tab[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80};
void main()
{
#ifndef MONIOTR51
TMOD=0x01;
TH0=0x3C;
TL0=0xB0;
EA=1;
ET0=1;
EX0=1;
TR0=1;
#endif
while(xx)
{
P1=tab[yy];
}
TR0=0;
yy=0;
P20=1;
while(1)
{
P1=tab[yy];
P20=(P00&P01&P02&P03&P04&P05&P06&P07);
}
}
void timer0() interrupt 1
{
static unsigned int count=0;
TH0=0x3C;
TL0=0xB0;
count++;
if(count==10) {xx--;count=0;yy++;}
}
void int0() interrupt 0
{
int k;
if(!P00) yy=1;
if(!P01) yy=2;
if(!P02) yy=3;
if(!P03) yy=4;
if(!P04) yy=5;
if(!P05) yy=6;
if(!P06) yy=7;
if(!P07) yy=8;
P21=0;
for(k=0;k<1000;k++) ;
P21=1;
while(P17) {P1=tab[yy];}
yy=0;
}