⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text1.lst

📁 用51单片机实现一个简单计算器的功能
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   TEXT1                                                                 11/21/2008 20:45:17 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: D:\c51\C51\BIN\C51.EXE Text1.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <regx52.h>
   2          #define uchar unsigned char
   3          #define uint unsigned int
   4          
   5          unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 
   6          0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
   7            
   8          unsigned char code dispbitcode[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff}; 
   9          
  10          
  11           //unsigned char dispbuf[9]={1,1,1,1,1,16,16,16,16};
  12          unsigned char dispbuf[9]={16,16,16,16,16,16,16,16,16};
  13          
  14          unsigned char dispbufaa[9]={16,16,16,16,16,16,16,16,16};
  15          //unsigned char dispbufaa[9]={1,2,3,16,16,16,16,16,16};
  16          
  17          unsigned char dispbufbb[9]={16,16,16,16,16,16,16,16,16}; 
  18          //unsigned char dispbufbb[9]={1,2,3,16,16,16,16,16,16};
  19          
  20          unsigned char dispbufccc[9]={16,16,16,16,16,16,16,16,16};
  21          
  22          uint aa=0,bb=0,ccc=0;
  23          
  24          uchar fuhao,T=1;
  25          
  26          unsigned char key=16;
  27          
  28          unsigned char dispbitcount,keypos,cc; 
  29          
  30          //*******************************************************************
  31          
  32           void delay02ss(unsigned char m)
  33          {
  34   1        unsigned char k;
  35   1        for(;m>0;m--)
  36   1        for(k=16;k>0;k--);
  37   1      }
  38          
  39          
  40          
  41          
  42          char keyscan1()
  43          {
  44   1        unsigned char temp,ridx=0xef,cidx=0xf7,aa,bb,cc,key=16;
  45   1        unsigned int i,j,i1,j1;
  46   1        for(i=0;i<4;i++)
  47   1         { 
  48   2              P3=0xff;
  49   2              P3=(ridx<<i)|0x0f;
  50   2              temp=P3&0x0f;
  51   2              if(temp!=0x0f)
  52   2              {
  53   3                    for(i1=50;i1>0;i1--)                                                                                                         
             -                                                 
  54   3                for(j1=200;j1>0;j1--);
C51 COMPILER V8.02   TEXT1                                                                 11/21/2008 20:45:17 PAGE 2   

  55   3                    temp=P3&0x0f;
  56   3                        for(j=0;j<4;j++)
  57   3                        {
  58   4                        aa=temp|0xf0;
  59   4                        bb=cidx>>j;
  60   4                        cc=bb|0xf0;
  61   4                                if(aa==cc)
  62   4                                {
  63   5                                  key=i*4+j;
  64   5                                  break;
  65   5                                }      
  66   4        
  67   4                        }
  68   3              
  69   3       
  70   3           }
  71   2              temp=P3;
  72   2              temp=temp & 0x0f;           
  73   2          while(temp!=0x0f)
  74   2          {
  75   3            temp=P3;
  76   3            temp=temp & 0x0f;              
  77   3          }
  78   2                      
  79   2      
  80   2        }
  81   1        return key;
  82   1          
  83   1      }
  84          
  85          
  86          char keyscan2()
  87          {
  88   1        unsigned char temp,ridx=0xef,cidx=0xf7,aa,bb,cc,key=16;
  89   1        unsigned int i,j,i1,j1;
  90   1        for(i=0;i<4;i++)
  91   1         { 
  92   2              P3=0xff;
  93   2              P3=(ridx<<i)|0x0f;
  94   2              temp=P3&0x0f;
  95   2              if(temp!=0x0f)
  96   2              {
  97   3                    for(i1=50;i1>0;i1--)                                                                                                         
             -                                                 
  98   3                for(j1=200;j1>0;j1--);
  99   3                    temp=P3&0x0f;
 100   3                        for(j=0;j<4;j++)
 101   3                        {
 102   4                        aa=temp|0xf0;
 103   4                        bb=cidx>>j;
 104   4                        cc=bb|0xf0;
 105   4                                if(aa==cc)
 106   4                                {
 107   5                                  key=i*4+j;
 108   5                                  break;
 109   5                                }      
 110   4        
 111   4                        }
 112   3              
 113   3       
 114   3           }
 115   2              temp=P3;
C51 COMPILER V8.02   TEXT1                                                                 11/21/2008 20:45:17 PAGE 3   

 116   2              temp=temp & 0x0f;           
 117   2          while(temp!=0x0f)
 118   2          {
 119   3            temp=P3;
 120   3            temp=temp & 0x0f;              
 121   3          }
 122   2                      
 123   2      
 124   2        }
 125   1        return key;
 126   1          
 127   1      }
 128          void change(unsigned char *p,unsigned char count) 
 129          { 
 130   1        while(count>0) 
 131   1          { 
 132   2            *(p+count)=*(p+count-1); 
 133   2            count--; 
 134   2          } 
 135   1      }
 136          void delete()
 137          {
 138   1          uchar dispbuf1[9]={16,16,16,16,16,16,16,16,16};
 139   1              dispbuf1[0]=dispbuf[1];
 140   1              dispbuf1[1]=dispbuf[2];
 141   1              dispbuf1[2]=dispbuf[3];
 142   1              dispbuf1[3]=dispbuf[4];
 143   1              dispbuf1[4]=dispbuf[5];
 144   1              dispbuf1[5]=dispbuf[6];
 145   1              dispbuf1[6]=dispbuf[7]; 
 146   1              dispbuf1[7]=dispbuf[8];
 147   1              dispbuf[0]=dispbuf1[0];
 148   1              dispbuf[1]=dispbuf1[1];
 149   1              dispbuf[2]=dispbuf1[2];
 150   1              dispbuf[3]=dispbuf1[3];
 151   1              dispbuf[4]=dispbuf1[4];
 152   1              dispbuf[5]=dispbuf1[5];
 153   1              dispbuf[6]=dispbuf1[6];
 154   1              dispbuf[7]=dispbuf1[7];
 155   1              dispbuf[8]=16;
 156   1              keypos--;
 157   1      }
 158          void clear()
 159          {
 160   1               dispbuf[0]=16;
 161   1               dispbuf[1]=16;
 162   1               dispbuf[2]=16;
 163   1               dispbuf[3]=16;
 164   1               dispbuf[4]=16;
 165   1               dispbuf[5]=16;
 166   1               dispbuf[6]=16;
 167   1               dispbuf[7]=16;
 168   1               dispbuf[8]=16;
 169   1               keypos=0;
 170   1      }
 171          
 172          void valueaa()
 173          {
 174   1          uint a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
 175   1              TR1=0;
 176   1          //if(dispbuf[7]!=16)a=dispbuf[7]*10000000;
 177   1              //if(dispbuf[6]!=16)b=dispbuf[6]*1000000;
C51 COMPILER V8.02   TEXT1                                                                 11/21/2008 20:45:17 PAGE 4   

 178   1              //if(dispbuf[5]!=16)c=dispbuf[5]*100000;
 179   1              if(dispbuf[4]!=16)d=dispbuf[4]*10000;
 180   1              if(dispbuf[3]!=16)e=dispbuf[3]*1000;
 181   1              if(dispbuf[2]!=16)f=dispbuf[2]*100;
 182   1              if(dispbuf[1]!=16)g=dispbuf[1]*10;
 183   1              if(dispbuf[0]!=16)h=dispbuf[0]; 
 184   1          aa=a+b+c+d+e+f+g+h;
 185   1          dispbufaa[0]=dispbuf[0];
 186   1              dispbufaa[1]=dispbuf[1];
 187   1              dispbufaa[2]=dispbuf[2];
 188   1              dispbufaa[3]=dispbuf[3];
 189   1              dispbufaa[4]=dispbuf[4];
 190   1              dispbufaa[5]=dispbuf[5];
 191   1              dispbufaa[6]=dispbuf[6];
 192   1              dispbufaa[7]=dispbuf[7];
 193   1              dispbufaa[8]=dispbuf[8];
 194   1      }
 195          
 196          void valuebb()
 197          {
 198   1          uint a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
 199   1              TR1=0;
 200   1          //if(dispbuf[7]!=16)a=dispbuf[7]*10000000;
 201   1              //if(dispbuf[6]!=16)b=dispbuf[6]*1000000;
 202   1              //if(dispbuf[5]!=16)c=dispbuf[5]*100000;
 203   1              if(dispbuf[4]!=16)d=dispbuf[4]*10000;
 204   1              if(dispbuf[3]!=16)e=dispbuf[3]*1000;
 205   1              if(dispbuf[2]!=16)f=dispbuf[2]*100;
 206   1              if(dispbuf[1]!=16)g=dispbuf[1]*10;
 207   1              if(dispbuf[0]!=16)h=dispbuf[0];
 208   1          bb=a+b+c+d+e+f+g+h;
 209   1              dispbufbb[0]=dispbuf[0];
 210   1              dispbufbb[1]=dispbuf[1];
 211   1              dispbufbb[2]=dispbuf[2];
 212   1              dispbufbb[3]=dispbuf[3];
 213   1              dispbufbb[4]=dispbuf[4];
 214   1              dispbufbb[5]=dispbuf[5];
 215   1              dispbufbb[6]=dispbuf[6];
 216   1              dispbufbb[7]=dispbuf[7];
 217   1              dispbufbb[8]=dispbuf[8];
 218   1      } 
 219          
 220          void fengaa()
 221          {
 222   1              uchar a,b,c,d,e,f,g,h,i;
 223   1              i=16;
 224   1              h=16;
 225   1              g=16;
 226   1              f=16;
 227   1              e=aa/10000;
 228   1              d=aa%10000/1000;
 229   1              c=aa%10000%1000/100;
 230   1              b=aa%10000%1000%100/10;
 231   1              a=aa%10000%1000%100%10;
 232   1              dispbufaa[8]=i;
 233   1              dispbufaa[7]=h;
 234   1              dispbufaa[6]=g;
 235   1              dispbufaa[5]=f;
 236   1              dispbufaa[4]=e;
 237   1              dispbufaa[3]=d;
 238   1              dispbufaa[2]=c;
 239   1              dispbufaa[1]=b;
C51 COMPILER V8.02   TEXT1                                                                 11/21/2008 20:45:17 PAGE 5   

 240   1              dispbufaa[0]=a;
 241   1      }
 242          
 243          void fengbb()
 244          {
 245   1              uchar a,b,c,d,e,f,g,h,i;
 246   1              i=16;
 247   1              h=16;
 248   1              g=16;
 249   1              f=16;
 250   1              e=bb/10000;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -