|
下面的这个程序unsigned char search_1(unsigned char num_0)这个函数有个语法错误,运行时提示错误“syntax error near 'unsigeded'”,实在看不出来了,请指教
#include
unsigned char print[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D, //'0~5'
0x7D,0x07,0x7F,0x6F,0x77,0x7C, //'-' 0x7C
0x39,0x5E,0x79,0x71,0x00,0x40} ;
unsigned char search[]={0xDE,0xED,0xDD,0xBD, //0,1,2,3
0xEB,0xDB,0xBB,0xE7, //4,5,6,7
0xD7,0xB7,0x7E,0x7D, //8,9,+,-
0x7B,0x77,0xBE,0xEE}; //*,%,=,zero
unsigned char ser[]={0xEF,0xDF,0xBF,0x7F};
bit flag;//0:功能
sbit P3_0=P3^0;
sbit P3_1=P3^1;
unsigned char n=0,m,w=0;
unsigned char p=0,q=0,k,j=0;
signed char s=0,r=0;
void output(unsigned char num);
unsigned char search_1(unsigned char num_0);
void print_num(unsigned char);
void math(unsigned char num_1);
void main()
{
output(n);
while(1)
{
w=0;
do
{P1=0x0F;
m=P1;
}while(m==0x0F);
do
{P1=ser[w++];
m=P1;
}while(m==ser[w]) ;
n=search_1(m);
if(n<10) {print_num(n); flag=0;}
else {math(n);flag=0;}
}//while
}
void math(unsigned char num_1)
{
if(j==0) {s=r;}
else
{if(k==10) s+=r;
if(k==11) s-=r;
if(k==12) s*=r;
if(k==13) s/=r;
if(k==14)
{if(s<0)
{ r=0x7C;
for(w=0;w<8;w++)
{r=r<<1;
P3_0=CY;
P3_1=0;
P3_1=1;
}//for
s&=0x7F;
}
output(s);
}
if(k==15) { s=0;output(s);j=0;flag=0;}
k=num_1;
++j;
}
unsigned char search_1(unsigned char num_0)
{
w=0;
while(num_0!=search[w])
{++w;}
return w;
}
void print_num(unsigned char t)
{
if(flag==0) {r=t;flag=1;}
else
{
r*=10;
r+=t;
}
if(r>255) output(0);
else output(r);
}
void output(unsigned char num)
{
do
{ P1=0x0F;
m=P1;
}while(m==P1);
p=num/100;
p=print[p];
num%=100;
q=num/10;
q=print[q];
r=num%10;
r=print[r];
for(w=0;w<8;w++)
{
r=r<<1;
P3_0=CY;
P3_1=0;
P3_1=1;
}//for
if(q!=0)
{ for(w=0;w<8;w++)
{q=q<<1;
P3_0=CY;
P3_1=0;
P3_1=1;}
}//if
if(p!=0)
{for(w=0;w<8;w++)
{p=p<<1;
P3_0=CY;
P3_1=0;
P3_1=1;}
}//if
}
|
|