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

📄 tstfloat.lst

📁 The code is for Auxiliary IO module which supports 16 inputs and 16 outputs and Modbus protocol
💻 LST
字号:
C51 COMPILER V6.21  TSTFLOAT                                                               07/29/2006 17:35:01 PAGE 1   


C51 COMPILER V6.21, COMPILATION OF MODULE TSTFLOAT
OBJECT MODULE PLACED IN tstfloat.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE tstfloat.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <Stdio.h>
   2          
   3          idata union test_data 
   4          {
   5          unsigned char dchar[5];
   6          unsigned int  dint[2];
   7          float  dfloat[1];
   8          };
   9          union test_data a;
  10          
  11          unsigned char decnt;
  12          volatile float test;
  13          bit zerf = 0;
  14          
  15          void Process_data();
  16          
  17          
  18          main()
  19          {
  20   1      a.dfloat[0]  =77.77;
  21   1      Process_data();
  22   1      while(1)
  23   1      {
  24   2      }
  25   1      } 
  26          
  27          // 
  28          // when test = 1500 and zerf = 0 , it is suppose to display 15.00, 
  29          // when test = 15 and zerf = 1 , it is suppose to display 0.015, 
  30          //
  31          
  32          
  33          void Process_Data()
  34          {
  35   1      unsigned int test1;
  36   1      if((a.dfloat[0] <= 9999) && (a.dfloat[0] >= 0))
  37   1      {
  38   2              test = a.dfloat[0];
  39   2              if(test == 0)
  40   2              {  
  41   3              decnt = 0;  // decnt = 0, no decimal
  42   3              test = (int)(test);
  43   3              }
  44   2              
  45   2              else if((test >= 0) && (test < 10))
  46   2              { 
  47   3              if(test < 1)
  48   3                zerf = 1;  
  49   3              decnt = 3;
  50   3              test = (int)(test * 1000);
  51   3              }
  52   2              else if((test >= 10) && (test < 100))
  53   2              {  
  54   3              decnt = 2;
  55   3              test= ((test * 100)/1);
C51 COMPILER V6.21  TSTFLOAT                                                               07/29/2006 17:35:01 PAGE 2   

  56   3              test1 = (unsigned int)test;
  57   3              }
  58   2              else if((test >= 100) && (test < 1000))
  59   2              {  
  60   3              decnt = 1;
  61   3              test= (test * 10);
  62   3              }
  63   2              else if((test >= 1000) && (test < 9999))
  64   2              {  
  65   3              decnt = 0;
  66   3              test= (test);
  67   3              }
  68   2      }
  69   1      else
  70   1      {
  71   2              //default value
  72   2              test = 0;
  73   2              decnt = 0;
  74   2      }
  75   1      
  76   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    426    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     10       2
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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