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

📄 calculator.lst

📁 我做的畢業設計,用AT89S51 控制LCD1602作為顯示. DS1302時鐘芯片顯示時間,DS18B20測量溫度,還有4X4的鍵盤驅動.實現了一個計算功能.可以用PROTUES 仿真軟件仿真,當時
💻 LST
📖 第 1 页 / 共 3 页
字号:
 356  11                                                                        }
 357  10                                                                }
 358   9                                                                else
 359   9                                                                {
C51 COMPILER V7.50   CALCULATOR                                                            04/09/2007 18:39:43 PAGE 7   

 360  10                                      Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';
 361  10                                                                }
 362   9                                                          }
 363   8                                                        else
 364   8                                                         {
 365   9                                                           Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';Display_Ram[3]=' ';
 366   9                                                         }
 367   8                                                 }
 368   7                                 else{
 369   8                                               Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';Display_Ram[3]=' ';Display_Ram[4]='0
             -';
 370   8      
 371   8                                             }
 372   7                                     p_Display_Ram=Display_Ram;               //指向显示缓冲单元
 373   7                                 LCD_disp_string(11,1,p_Display_Ram);
 374   7                           }
 375   6                         }
 376   5                     else                                        // 如果操作数A 的数大于5位,则出错处理         
             -                     
 377   5                        {
 378   6                        //Call clear all and flag
 379   6                                        Clear_All_Flag_Init();
 380   6                                              /*       Bit_Number=0;                     // 位计数清零  
 381   6                                                       Frist=0;Second=0;                 //运算数清零
 382   6                                                       operator=operator_Emputy;         //运算符初始化
 383   6                                               Flag_operand_B_NoEmpty=0;         //操作数B 为空
 384   6                                               Flag_operand_A_NoEmpty=0;         //操作数A  为空 
 385   6                                       Flag_operator_FristTime=0;        //没有运算符按下 
 386   6                                              
 387   6                                                       //display the errot
 388   6                                       operand_A[0]=0;                   //清零  
 389   6                                                       operand_A[1]=0;
 390   6                                                       operand_A[2]=0;
 391   6                                                       operand_A[3]=0;
 392   6                                                       operand_A[4]=0;*/
 393   6                                                       
 394   6                                                       p_string_code=string_error_tomanybit; //指向字符串“出错处理”
 395   6                                       LCD_disp_string_code(0,1,p_string_code);
 396   6                              }
 397   5                  
 398   5                     }
 399   4                  else                                          //如果操作数A 已经按下
 400   4                    {
 401   5                       if(Bit_Number<5)                         //如果操作数B  的位数小于等于 5位
 402   5                       {
 403   6                         /*operand_B[Bit_Number++]=Key_temp;
 404   6                         Second=operand_B[0]+operand_B[1]*10+operand_B[2]*100;*/
 405   6                          switch(Bit_Number)                   
 406   6                            {
 407   7                              case 0: operand_B[0]=Key_temp;break;
 408   7                              case 1: operand_B[1]=operand_B[0];operand_B[0]=Key_temp;break;
 409   7                              case 2: operand_B[2]=operand_B[1];operand_B[1]=operand_B[0];operand_B[0]=Key_temp;
             -break;
 410   7                                                      case 3: operand_B[3]=operand_B[2];operand_B[2]=operand_B[1];operand_B[1]=operand_B[0];operand_B[0]=K
             -ey_temp;break;
 411   7                                                      case 4: operand_B[4]=operand_B[3];operand_B[3]=operand_B[2];operand_B[2]=operand_B[1];operand_B[1]=o
             -perand_B[0];operand_B[0]=Key_temp;break;
 412   7                              default: Bit_Number=0;     
 413   7                            }
 414   6                                         Bit_Number++;                          //位数加1
 415   6                         Second=operand_B[0]+operand_B[1]*10+operand_B[2]*100+operand_B[3]*1000+operand_B[4]*100
             -00;
C51 COMPILER V7.50   CALCULATOR                                                            04/09/2007 18:39:43 PAGE 8   

 416   6                                                                                //运算
 417   6                         Flag_operator_FristTime=0;             //有运算符按下,可以接收第二次运算符
 418   6                                         if(operand_B[4]>=6)
 419   6                                          {
 420   7                           The_Number_Too_Large();
 421   7                                              }
 422   6                                         else
 423   6                                          {
 424   7                                     if(Second>0)
 425   7                          { Display_Ram[4]=(Second%10)+0x30;
 426   8                                                   if(Second>=10)
 427   8                                                         {
 428   9                                                           Display_Ram[3]=(Second%100)/10+0x30;
 429   9                                                               if(Second>=100)
 430   9                                                                {
 431  10                                                                  Display_Ram[2]=(Second%1000)/100+0x30;
 432  10                                                                      if(Second>=1000)
 433  10                                                                        {
 434  11                                                                          Display_Ram[1]=(Second%10000)/1000+0x30;
 435  11                                                                              if(Second>=10000)
 436  11                                                                                {
 437  12                                               Display_Ram[0]=(Second/10000)+0x30;
 438  12                                                                                }
 439  11                                                                              else
 440  11                                                                                {
 441  12                                                                                 Display_Ram[0]=' ';
 442  12                                                                                }
 443  11                                                                        }
 444  10                                                                       else
 445  10                                                                        {
 446  11                                                                          Display_Ram[0]=' ';Display_Ram[1]=' ';
 447  11                                                                        }
 448  10                                                                }
 449   9                                                                else
 450   9                                                                {
 451  10                                      Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';
 452  10                                                                }
 453   9                                                          }
 454   8                                                        else
 455   8                                                         {
 456   9                                                           Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';Display_Ram[3]=' ';
 457   9                                                         }
 458   8                                                 }
 459   7                                 else{
 460   8                                               Display_Ram[0]=' ';Display_Ram[1]=' ';Display_Ram[2]=' ';Display_Ram[3]=' ';Display_Ram[4]='0
             -';
 461   8      
 462   8                                             }
 463   7                         Flag_operand_B_NoEmpty=1;
 464   7                             p_Display_Ram=Display_Ram;
 465   7                                 LCD_disp_string(11,1,p_Display_Ram);
 466   7                                        }
 467   6                       }
 468   5                     else                              //如果操作数B 的位数 大于5位
 469   5                       {
 470   6                        //Call clear all flag
 471   6                                       Frist=0;Second=0;               //运算数据清零
 472   6                                       Result=0;                       //结果清零
 473   6                                       Clear_All_Flag_Init();
 474   6                                      /* operator=operator_Emputy;       //运算符初始化
 475   6                               Flag_operand_B_NoEmpty=0;       //操作数B  为空
 476   6                               Flag_operand_A_NoEmpty=0;       //操作数A  为空
C51 COMPILER V7.50   CALCULATOR                                                            04/09/2007 18:39:43 PAGE 9   

 477   6                       Flag_operator_FristTime=0;      //无运算符按下  
 478   6                                       Flag_Number_FristTime=0;        //无操作数按下
 479   6                       //display the errot
 480   6                                       operand_B[0]=0;
 481   6                                       operand_B[1]=0;
 482   6                                       operand_B[2]=0;
 483   6                                       operand_B[3]=0;
 484   6                                       operand_B[4]=0;     */           //显示太多位出错啦!!!!!!!!!
 485   6                                       p_string_code=string_error_tomanybit;
 486   6                       LCD_disp_string_code(0,1,p_string_code);
 487   6      
 488   6                       }
 489   5                }     //end  default    
 490   4                 }//end if
 491   3           }//end switch
 492   2        }//end if  
 493   1      }//end Calculator
 494          
 495          void Clear_All_Flag_Init(void)
 496          {
 497   1      
 498   1         operator=operator_Emputy;                //运算符初始化
 499   1         Flag_operand_B_NoEmpty=0;                //操作数B 为空
 500   1         Flag_operand_A_NoEmpty=0;                //操作数A 为空
 501   1         Flag_operator_FristTime=0;               //无运算符按下
 502   1         Flag_Number_FristTime=0;                 //无操作数
 503   1         operand_A[0]=0;operand_A[1]=0;operand_A[2]=0;operand_A[3]=0;operand_A[4]=0;
 504   1         operand_B[0]=0;operand_B[1]=0;operand_B[2]=0;operand_B[3]=0;operand_B[4]=0;
 505   1         Bit_Number=0;                            //位计算清零
 506   1      
 507   1      }
 508          
 509          void The_Number_Too_Large(void)
 510          {
 511   1        Clear_All_Flag_Init();
 512   1        Frist=0;Second=0;Result=0;        //清零
 513   1        GotoXY(0,1);
 514   1        Print("Number too large");
 515   1      
 516   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1927    ----
   CONSTANT SIZE    =     83    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     18       4
   IDATA SIZE       =   ----       5
   BIT SIZE         =      5    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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