#include
#include
unsigned char tmp;
unsigned char data1 = 0;
unsigned int num1 = 0,num2 = 0,num3 = 0,fu = 0;
int q[100] = {0};
int printf_flag = 0;
int a = 0;
int c = 0;
void send_char(unsigned char txd);
void send(unsigned int u);
void main()
{
// EA = 1; //总开关
// ES = 1; //IE寄存器 通信开关
SCON = 0x50; // 设定串行口工作方式 0101 0000 工作方式1
TMOD = 0x20; // 定时器1工作于8位自动重载模式, 用于产生波特率
TH1 = 0xFD; // 波特率9600
TL1 = 0xFD;
PCON = 0x00; // 波特率不倍增
TR1 = 1; // 启动定时器1
while(1)
{
if(RI == 1) // 是否有数据到来
{
RI = 0;
data1 = SBUF;
//P1 = data1; // 数据传送到P0口
// send_char(data1); // 回传接收到的数据
if(( data1>='0') && (data1<='9'))
{
num1 = 10*num1+(data1 -'0');
}
else if(data1 == '+'||data1 =='-'||data1 == '*'|| data1 == '/')
{
fu = data1;
num2 = num1;
num1 = 0;
}
else if(data1 == '='&&fu; == '+')//
{
num3 = num1+num2;
printf_flag = 1;
}
else if(data1 == '='&&fu; == '-')// &&fu; == '-'
{
num3 = num2-num1;
printf_flag = 1;
}
else if(data1 == '='&&fu; == '*')//&&fu; == '*'
{
num3 = num1*num2;
printf_flag = 1;
}
else if(data1 == '='&&fu; == '/')// '&&fu; == '/'
{
num3 = num1/num2;
printf_flag = 1;
1