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

📄 main.lst

📁 用keil开发的.单片机税控器程序.单片机用的是AT公司的.upsd3245
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V8.01   MAIN                                                                  03/28/2006 09:48:48 PAGE 1   


C51 COMPILER V8.01, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN Main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Main.C LARGE OPTIMIZE(9,SIZE) BROWSE DEBUG OBJECTEXTEND CODE

line level    source

   1          /*
   2          * Copyright (c) 2004,成都港顺科技发展有限公司
   3          * All rights reserved.
   4          *
   5          * 编 译 器:uVision 2;Keil:C Compiler:7.20;Assembler:7.10
   6          * 工程名称:POS-Test.UV2
   7          * 文件名称:Main.C
   8          ************************************************************************ ********************************
   9          * 摘    要:系统初始化 清除内存 数据保护 字符串转换函数定义  以及“销售”和“系统功能”函数入口
  10          * ********************************************************************************************************
  11          * 单 片 机:uPSD3254
  12          * 当前版本:0.4
  13          * 作    者:李凯
  14          * 完成日期:2004-12-7 14:45
  15          *
  16          * 存储器地址空间分配:
  17          * CSIOP  : PAGE:ALL 256bytes  0x0200-0x02FF
  18          * SRAM   : PAGE:ALL 31.25Kbytes 0x300-0x7FFF
  19          * BOOT0  : PAGE:ALL 32Kbytes 0x0000-0x1FFF  Program Space
  20          * BOOT1  : PAGE:ALL 32Kbytes 0x2000-0x3FFF  Program Space
  21          * BOOT2  : PAGE:ALL 32Kbytes 0x4000-0x5FFF  Program Space
  22          * BOOT3  : PAGE:ALL 32Kbytes 0x6000-0x7FFF  Program Space
  23          * Flash0 : PAGE:0   32Kbytes 0x8000-0xFFFF  Program Space
  24          * Flash1 : PAGE:1   32Kbytes 0x8000-0xFFFF  Program Space
  25          * Flash2 : PAGE:2   32Kbytes 0x8000-0xFFFF  Program Space
  26          * Flash3 : PAGE:3   32Kbytes 0x8000-0xFFFF  Program Space
  27          * Flash4 : PAGE:4   32Kbytes 0x8000-0xFFFF  Program Space
  28          * Flash5 : PAGE:5   32Kbytes 0x8000-0xFFFF  Program Space
  29          * Flash6 : PAGE:6   32Kbytes 0x8000-0xFFFF  Program Space
  30          * Flash7 : PAGE:7   32Kbytes 0x8000-0xFFFF  Program Space
  31          */
  32          
  33          #include "Main.h"
  34          
  35          PSD_REGS PSD_REG  _at_  PSD_REG_ADDR;
  36          
  37          /*
  38          
  39          void reset (void)
  40          {//软件自复位(中断中不能使用)
  41          ((void (code *) (void)) 0x0000) ();
  42          }
  43          
  44          
  45          */
  46          //void IntSet(uint x)
  47          //{//INT0:bit0 UART2:bit1 Timer0:bit3 I2C:bit4 INT1:bit5 DDC:bit6 Timer1:bit7 USB:bit8 UART1:bit9 Timer2+E
             -XF2:bit10
  48          //  EA=1;
  49          //  EX0=1;
  50          //  if(x & 0x02)IEA |= 0x10;
  51          //  else    IEA &= 0xEF;
  52          //  if(x & 0x04)ET0=1;
  53          //  else    ET0=0;
  54          //  if(x & 0x08)IEA |= 0x02;
C51 COMPILER V8.01   MAIN                                                                  03/28/2006 09:48:48 PAGE 2   

  55          //  else    IEA &= 0xFD;
  56          //  if(x & 0x10)EX1=1;
  57          //  else    EX1=0;
  58          //  if(x & 0x20)IEA |= 0x80;
  59          //  else    IEA &= 0x7F;
  60          //  if(x & 0x40)ET1=1;
  61          //  else    ET1=0;
  62          //  if(x & 0x80)IEA |= 0x01;
  63          //  else    IEA &= 0xFE;
  64          //  if(x & 0x100)ES=1;
  65          //  else    ES=0;
  66          //  if(x & 0x200)ET2=1;
  67          //  else    ET2=0;
  68          //}
  69          
  70          
  71          
  72          //mode::bit0=0:按整数转换为字符串;bit0=1:按浮点数转换为字符串     SwitchInt SwitchFloat
  73          //mode::bit1=0:如dat值为0不转换为字符‘0’;bit1=1:如dat值为0则要转换    SwitchZero
  74          //mode::bit2=0:按浮点数转换时如果小数点后全为0,不转换;bit2=1:要转换 SwitchDot
  75          //mode::bit3=0:高位的0不转换;bit3=1:高位的0转换为字符‘ ’(空格)      SwitchSpace
  76          //mode::bit7=0:转换后的字符串加结束符'\0';bit7=1:加空格' '        SwitchEnd
  77          void NumToStr(ulong dat, uchar *str, uchar mode)
  78          {//ulong最大为:4294967295,不超过10位,加小数点和结束符,不超过12位
  79   1              uchar i=0,j=0,x;
  80   1              ulong k,e=1000000000;
  81   1      
  82   1              if(dat==0)
  83   1              {
  84   2                      if(mode & SwitchZero)
  85   2                      {
  86   3                              str[0]='0';
  87   3                              x=1;
  88   3                      }
  89   2                      else    x=0;
  90   2                      
  91   2                      if(mode & SwitchEnd)
  92   2                              str[x]=' ';
  93   2                      else
  94   2                              str[x]=0;
  95   2                      return;
  96   2              }
  97   1              k=dat;
  98   1              while(1)
  99   1              {
 100   2                      x = dat/e;
 101   2                      if(mode & SwitchSpace)
 102   2                      {
 103   3                              str[i] = x + '0';
 104   3                              i++;
 105   3                      }
 106   2                      else
 107   2                      {               
 108   3                              if(x!=0 || i!=0)//i!=0是为了保证当最高位之后有的位是0也能够被正常转换
 109   3                              {
 110   4                                      str[i] = x + '0';
 111   4                                      i++;
 112   4                              }       
 113   3                      }       
 114   2                      if(e==1)break;
 115   2                      dat = dat%e;
 116   2                      e /= 10;
C51 COMPILER V8.01   MAIN                                                                  03/28/2006 09:48:48 PAGE 3   

 117   2              }
 118   1      
 119   1              if(mode & SwitchFloat)
 120   1              {//按浮点数转换
 121   2                      if(k>=100)
 122   2                      {
 123   3                              if((k%100)!=0 || (mode & SwitchDot))
 124   3                              {
 125   4                                      str[i]=str[i-1];
 126   4                                      str[i-1]=str[i-2];
 127   4                                      str[i-2]='.';
 128   4                                      if(mode & SwitchEnd)
 129   4                                              str[i+1]=' ';
 130   4                                      else
 131   4                                              str[i+1]=0;
 132   4                              }
 133   3                              else
 134   3                              {
 135   4                                      if((mode & SwitchDot)==0)
 136   4                                      {
 137   5                                              if(mode & SwitchEnd)
 138   5                                              {
 139   6                                                      str[i]=str[i-1]=0;
 140   6                                                      str[i-2]=' ';
 141   6                                              }
 142   5                                              else
 143   5                                                      str[i]=str[i-1]=str[i-2]=0;
 144   5                                      }
 145   4                              }
 146   3                      }
 147   2                      else
 148   2                      {
 149   3                              if(k>9)
 150   3                              {
 151   4                                      str[2]=str[0];
 152   4                              str[3]=str[1];
 153   4                              str[0]='0';
 154   4                              str[1]='.';
 155   4                      }
 156   3                      else
 157   3                      {
 158   4                              str[3]=str[0];
 159   4                              str[0]='0';
 160   4                              str[1]='.';
 161   4                              str[2]='0';
 162   4                      }
 163   3                      if(mode & SwitchEnd)
 164   3                                      str[4]=' ';
 165   3                              else
 166   3                                      str[4]=0;
 167   3              }
 168   2              }
 169   1              else
 170   1              {
 171   2                      if(mode & SwitchEnd)
 172   2                              str[i]=' ';
 173   2                      else
 174   2                              str[i]=0;
 175   2              }
 176   1      }
 177          
 178          
C51 COMPILER V8.01   MAIN                                                                  03/28/2006 09:48:48 PAGE 4   

 179          
 180          //mode::bit0=0:BCD数组全部为0不转换;bit0=1:要转换为字符'0'
 181          //mode::bit1=0:
 182          //mode::bit2=0:
 183          //mode::bit3=0:
 184          //mode::bit7=0:高位的零不转换;bit7=1:要转换为字符'0'
 185          void BcdToStr(uchar len,uchar *bcd,uchar *str,uchar mode)
 186          //void BcdToStr(uchar len,uchar *bcd,uchar *str)
 187          {//是否考虑将0转换为空格
 188   1              uchar i=0,j=0,k=0,f=0,x,first=0;//mode=0;
 189   1              
 190   1              for(i=0;i<len;i++)
 191   1                      if(bcd[i]!=0)f=1;
 192   1              if((mode&0x01)==0 && f==0)
 193   1              {
 194   2                      str[0]=0;
 195   2                      return;
 196   2              }
 197   1      //      if(bcd[i]==0 && (mode&0x01)==0)
 198   1      //      {
 199   1      //              if(mode & 0x80)str[0]=' ';
 200   1      //              else    str[0]=0;
 201   1      //              return;
 202   1      //      }
 203   1              x=mode&0x80;
 204   1              for(i=0;i<len;i++)
 205   1              {               
 206   2                      k=bcd[i]>>4;
 207   2                      if(k!=0)first=1;
 208   2                      if(k!=0 || first==1 || x)
 209   2                      {
 210   3                              if(k > 9)
 211   3                                      str[j]=k-10+'A';
 212   3                              else                                    
 213   3                                      str[j]=k+'0';           
 214   3                              j++;                    
 215   3                      }
 216   2                      k=bcd[i]&0xf;
 217   2                      if(k!=0)first=1;
 218   2                      if(k!=0 || first==1 || x)
 219   2                      {
 220   3                              if(k > 9)
 221   3                                      str[j]=k-10+'A';
 222   3                              else                                    
 223   3                                      str[j]=k+'0';
 224   3                              j++;
 225   3                      }
 226   2              }
 227   1      //      if(mode & 0x80)str[j]=' ';
 228   1      //      else    
 229   1                      str[j]=0;
 230   1      }
 231          
 232          
 233          
 234          void BcdToHex(uchar len,uchar *bcd,uchar *hex)
 235          {//可以用
 236   1              uchar i=0,j=0;
 237   1              for(i=0;i<len;i++)
 238   1              {
 239   2                      hex[j]=bcd[i]>>4;
 240   2                      j++;
C51 COMPILER V8.01   MAIN                                                                  03/28/2006 09:48:48 PAGE 5   

 241   2                      hex[j]=bcd[i]&0xf;
 242   2                      j++;
 243   2              }
 244   1              return;
 245   1      }
 246          
 247          uchar Verdict(uchar *bcdtime)
 248          {
 249   1              uchar flag;
 250   1              uchar i=0,Intime[8],day=0,month=0;
 251   1              uint  x=0,year=0;
 252   1              
 253   1              BcdToHex(4,bcdtime,Intime);
 254   1      
 255   1              year=Intime[0]*1000+Intime[1]*100+Intime[2]*10+Intime[3];//年
 256   1              month=Intime[4]*10+Intime[5];//月
 257   1              day=Intime[6]*10+Intime[7];//日
 258   1              if(((year%4==0) && (year%100!=0)) || year%400==0) flag=1;//是润年

⌨️ 快捷键说明

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