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

📄 dps2spc3.lst

📁 pROFIBUS 从站源程序 SPC3 pROFIBUS 从站源程序 SPC3
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 1   


C51 COMPILER V7.02b, COMPILATION OF MODULE DPS2SPC3
OBJECT MODULE PLACED IN DPS2SPC3.OBJ
COMPILER INVOKED BY: D:\KEIL\C51\BIN\C51.EXE DPS2SPC3.C LARGE ROM(COMPACT) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*
   2          +------------------------------------------------------------------------+
   3          | Project: D P S 2   w i t h   S P C 3                                   |
   4          |                                                                        |
   5          | File:   DPS2SPC3.C                                                     |
   6          | Date:   24-Mar-1997                                                    |
   7          | Version: V 1.30                                                        |
   8          | Initial Editor:   Thomas Lang                                          |
   9          +------------------------------------------------------------------------+
  10          | Description:                                                           |
  11          |  This File contains the functions for DPS2 with SPC3.                  |
  12          |                                                                        |
  13          |                                                                        |
  14          +------------------------------------------------------------------------+
  15          | following environments are supported                                   |
  16          |  Processor: SAB C165                                                   |
  17          |   Compiler: BSO Tasking 80166 C Cross-Compiler, V 4.0                  |
  18          |  Processor: iNTEL 8032                                                 |
  19          |   Compiler: Keil                                                       |
  20          +------------------------------------------------------------------------+
  21          |                    Copyright (C) SIEMENS AG, 1994                      |
  22          |                         All Rights reserved                            |
  23          +------------------------------------------------------------------------+
  24          | History:                                                                                                                        |
  25          | V1.0,LT, first official version                                                                  |
  26          | V1.1,LT, error in calculation of the FDL-SAP-List-Pointer fixed             |
  27          |                        (dps2_buf_len was not divided by)                                     |
  28          | V1.3,MM,12-Feb-1997, I/O-len calculation corrected                      |
  29          | V1.3,MM,24-Mar-1997, translation                                                             |
  30          |                                                                        |
  31          +------------------------------------------------------------------------+
  32          | Technical support:       Siemens Schnittstellencenter                  |
  33          |                          AUT7 WKF B1 TDL2                              |
  34          |                                                                        |
  35          |   Schmidt Xaver                   Mittelberger Martin                  |
  36          |   Tel.: 0911/750-2079             Tel.: 0911/750-2072                  |
  37          |                                                                        |
  38          |                   Fax.:         -2100                                  |
  39          |                   Mailbox: 0911/737972                                 |
  40          |                                                                        |
  41          +------------------------------------------------------------------------+
  42          */
  43          
  44          /*~
  45          includes and declarations
  46          ~*/
  47             /* formal declaratios for spc3dps2.h */
  48          #define SPC3_DPS2             1
  49          /*#define SPC3_INTEL_MODE       1*/
  50          #define SPC3_DATA_XDATA
  51          #define SPC3_FAR
  52          
  53          #include "spc3dps2.h"
  54          
  55          /*~
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 2   

  56          literals and macros
  57          ~*/
  58             /*
  59             +------------------------------------------------------------------------+
  60             |                           L i t e r a l s                              |
  61             +------------------------------------------------------------------------+
  62             */
  63             /*-- cout of buffers assigned to AUX-buffer --*/
  64          #define ASS_AUX_BUF                             3
  65             /*-- masks for config-data --*/
  66          #define DPS_CFG_IS_BYTE_FORMAT          (UBYTE)0x30
  67          #define DPS_CFG_BF_LENGTH               (UBYTE)0x0f
  68          #define DPS_CFG_LENGTH_IS_WORD_FORMAT   (UBYTE)0x40
  69          #define DPS_CFG_BF_INP_EXIST            (UBYTE)0x10
  70          #define DPS_CFG_BF_OUTP_EXIST           (UBYTE)0x20
  71          #define DPS_CFG_SF_OUTP_EXIST           (UBYTE)0x80
  72          #define DPS_CFG_SF_INP_EXIST            (UBYTE)0x40
  73          #define DPS_CFG_SF_LENGTH               (UBYTE)0x3f
  74          
  75             /*
  76             +------------------------------------------------------------------------+
  77             |                             M a c r o s                                |
  78             +------------------------------------------------------------------------+
  79             */
  80             /*-- start address of user-area in the SPC3 in SPC3-format(8字节一段)-*/
  81          #define SPC3_BUF_START ((UBYTE)(((UWORD)(dps2_base_ptr -\
  82                                   (UBYTE SPC3_PTR_ATTR*)&spc3)) >> 3))
  83          
  84          /*~
  85          Variables
  86          ~*/
  87             /*
  88             +------------------------------------------------------------------------+
  89             |                g l o b a l     V a r i a b l e s                       |
  90             +------------------------------------------------------------------------+
  91             */
  92          #ifdef _C166
                       #pragma global
              #endif
  95          
  96             UBYTE _dps2_x;              /* dummy-byte */
  97          
  98          #ifdef _C166
                       #pragma public
              #endif
 101          
 102             /*
 103             +------------------------------------------------------------------------+
 104             |          "M o d u l" - g l o b a l   V a r i a b l e s                 |
 105             +------------------------------------------------------------------------+
 106             */
 107             static DPS2_BUFINIT dps2_binit;       /* storeage for initialization data */
 108             static WORD dps2_buf_len = 0;         /* used bufferspace */
 109             static UBYTE SPC3_PTR_ATTR *dps2_base_ptr =\
 110                                          (UBYTE SPC3_PTR_ATTR*)0; /* buffer base address */
 111             static DPS2_IO_DATA_LEN io_data_len;  /* Struct. f. IO-lens */
 112          
 113             /*
 114             +------------------------------------------------------------------------+
 115             |               e x t e r n a l   D e c l a r a t i o n s                |
 116             +------------------------------------------------------------------------+
 117             */
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 3   

 118          #ifndef _IM182
 119             extern SPC3 SPC3_PTR_ATTR spc3;
 120          #endif
 121          
 122          /*~
 123          assign_aux_buf()
 124          ~主调dps_buf_init .Cp9*/
 125             /*
 126             +------------------------------------------------------------------------+
 127             | Function:   a s s i g n _ a u x _ b u f ( )                            |
 128          +------------------------------------------------------------------------------+
 129          | Description:                                                                 |
 130          |  Based on a list of bufferlens the best len of the aux-buffers is calculated.|
 131          | The list's lens will be adjusted, the assignment-list will be calculated.    |
 132          | (基于各设定buf长度计算出aux-buf的最佳长度,表的LENS将做调整,并得出新的安排表) |
 133          +------------------------------------------------------------------------------+
 134             | Parameters:                                                               |
 135             | -lens:    Pointer to a list of buffer-lens ( real_buf_len数组的指针)      |
 136             |           The calculated lens are inserted in this list.                  |
 137             | -count:   length of list (2 to ASS_AUX_BUF大小2或3)                       |
 138             | -assign:  pointer to an assignment-b yte(用于assignment的字节)             |
 139             |           For each len there is a corresponding bit for the               |
 140             |           assignment to AUX-buffer 1 or 2. 0 means AUX-buffer 1,          |
 141             |           1 means AUX-Buffer 2. Bit 0 ist for the first, Bit 7            |
 142             |         for the 8th length.(已定义UBYTE aux_ass,用于AUX-buffer-assignment)|                          
             -           
 143             | -aux_len: pointer to a 2-byte-array for AUX-buffer-lens                   |
 144             |           The calculated lens of AUX-buffer 1 and 2 are stored here.      |
 145             |    (储存AUX-buffer-lens的二字节数组的指针,数组分别存计算出的AUX-buf的长度)|
 146             | Returnvalue: UWORD: total amount of used bytes (0 = error)                |
 147             +---------------------------------------------------------------------------+
 148             */
 149          
 150             UWORD assign_aux_buf(UBYTE SPC3_DATA_ATTR *lens, UBYTE count, UBYTE
 151             SPC3_DATA_ATTR *assign, WORD SPC3_DATA_ATTR *aux_len) /*$G*/
 152             {  
 153   1                UBYTE pos[ASS_AUX_BUF];     /* storage for former position of lens    */
 154   1                UBYTE lensx[ASS_AUX_BUF];   /* working-array for calculated lens      */
 155   1                UBYTE step;                 /* counter for done step                  */
 156   1                UBYTE lx;                   /* temp-var for lenarray-sorting(整理)    */
 157   1                UBYTE px;                   /* temp-var dor position-sorting          */
 158   1                UWORD min_len = 0xffff;     /* calculated min-len                     */
 159   1                UBYTE min_step = 0;         /* step at reached min-len                */
 160   1                BYTE i,j;
 161   1      
 162   1                if((count < 2) || (count > ASS_AUX_BUF))
 163   1                {
 164   2                       return 0;/* 返回0即出错*/
 165   2                }
 166   1                /* init position-array ;初始化position-array */
 167   1                for(i = 0; i < count; i++)
 168   1                {
 169   2                       pos[i] = i;
 170   2                }
 171   1                /* init working-array ;初始化working-array */
 172   1                for(i = 0; i < count; i++)
 173   1                {
 174   2                       lensx[i] = lens[i];/*lens是real_buf_len数组的指针*/
 175   2                }
 176   1                /* round up(聚拢) lens to SPC3-lens (8-byte-granularity) */
 177   1                for(i = 0; i < count; i++)
 178   1                {
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 4   

 179   2                       lensx[i] = (lensx[i] + 7) & 0xf8;/*相当于四舍五入?lens长度取8的倍数*/
 180   2                }
 181   1                /* sorting of lens: gratest len to index 0;整理lens:最大len标0*/
 182   1      for(i = 0; i < count-1; i++)/*此循环用于lensx数组按从大到小排序,相应POS序号数组也排序*/
 183   1                {
 184   2                       for(j = i+1; j < count; j++)
 185   2                       {
 186   3                              if(lensx[i] < lensx[j])
 187   3                              {
 188   4                                 /* greater len found */
 189   4                                 lx = lensx[i];          /* xchg lens;交换lensx[i]和lensx[j] */
 190   4                                 lensx[i] = lensx[j];    
 191   4                                 lensx[j] = lx;
 192   4                                 px = pos[i];            /* xchg position;交换位置*/
 193   4                                 pos[i] = pos[j];
 194   4                                 pos[j] = px;
 195   4                              }
 196   3                       }
 197   2                }
 198   1                /* remove NULL-lens of list;去除lensx数组为0的元素, */
 199   1                for(i = count-1; i >= 0; i--)
 200   1                {
 201   2                       if(lensx[i] == 0)
 202   2                       {
 203   3                              count--;
 204   3                       }
 205   2                }
 206   1                if(count == 0)
 207   1                {
 208   2                       min_len = 0;     /* error: no lens specified */
 209   2                }
 210   1                /* stepwise assignment to the AUX-buffers;用试探法计算出min_step和min_len */
 211   1                for(step = 0; step < count; step++)
 212   1                {
 213   2                       /* determine total len for AUX-buffer 1 */
 214   2                       aux_len[0] = 0;

⌨️ 快捷键说明

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