#include //头文件
#define uint unsigned int //
#define uchar unsigned char
sbit e=P2^3; //定义引脚
sbit rs=P2^4;
sbit rw=P2^0;
sbit busy=P0^7;
char i,j,temp,num,num_1;
long a,b,c; //a,第一个数 b,第二个数 c,得数
float a_c,b_c;
uchar flag,fuhao;//flag表示是否有符号键按下,fuhao表征按下的是哪个符号
uchar code table[]={
7,8,9,0,
4,5,6,0,
1,2,3,0,
0,0,0,0};
uchar code table1[]={
7,8,9,0x2f-0x30,
4,5,6,0x2a-0x30,
1,2,3,0x2d-0x30,
0x01-0x30,0,0x3d-0x30,0x2b-0x30};
void delay(uchar z) // 延迟函数
{
uchar y;
for(z;z>0;z--)
for(y=0;y<110;y++);
}
void check() // 判断忙或空闲
{
do{
P0=0xFF;
rs=0; //指令
rw=1; //读
e=0; //禁止读写
delay(1); //等待,液晶显示器处理数据
e=1; //允许读写
}while(busy==1); //判断是否为空闲,1为忙,0为空闲
}
void write_com(uchar com) // 写指令函数
{
P0=com; //com指令付给P0口
rs=0;
rw=0;
e=0;
check();
e=1;
}
void write_date(uchar date) // 写数据函数
{
P0=date;
rs=1;
rw=0;
e=0;
check();
e=1;
}
void init() //初始化
{
num=-1;
e=1