unsigned int a,b,c;
SCON = 0x50; //串口方式1,允许接收
TMOD = 0x20; //定时器1定时方式2
TCON = 0x40; //设定时器1开始计数
TH1 = 0xE8; //11.0592MHz 1200波特率
TL1 = 0xE8;
TI = 1;
TR1 = 1; //启动定时器
while(1)
{
scanf("%d%d",&a,&b);
if(a>b)
{
c=a-b;
}
c=b-a;
printf("a=%d,b=%d,c=%d\n",a,b,c);
}
}
|