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

📄 lib_str.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 5 页
字号:
   \   0000000E   0A78               LDRB     R2,[R1, #+0]
   \   00000010   002A               CMP      R2,#+0
   \   00000012   F8D1               BNE.N    ??Str_Len_1
    151          
    152              return (len);
   \                     ??Str_Len_2:
   \   00000014   7047               BX       LR               ;; return
    153          }
    154          
    155          
    156          /*$PAGE*/
    157          /*
    158          *********************************************************************************************************
    159          *                                             Str_Copy()
    160          *
    161          * Description : Copy source string to destination string buffer.
    162          *
    163          * Argument(s) : pdest       Pointer to destination string buffer to receive source string copy (see Note #1).
    164          *
    165          *               psrc        Pointer to source      string to copy into destination string buffer.
    166          *
    167          * Return(s)   : Pointer to destination string, if NO errors (see Note #2).
    168          *
    169          *               Pointer to NULL,               otherwise.
    170          *
    171          * Caller(s)   : Application.
    172          *
    173          * Note(s)     : (1) Destination buffer size NOT validated; buffer overruns MUST be prevented by caller.
    174          *
    175          *                   (a) Destination buffer size MUST be large enough to accommodate the entire source 
    176          *                       string size including the terminating NULL character.
    177          *
    178          *               (2) String copy terminates when :
    179          *
    180          *                   (a) Destination/Source string pointer(s) are passed NULL pointers.
    181          *                       (1) No string copy performed; NULL pointer returned.
    182          *
    183          *                   (b) Destination/Source string pointer(s) points to NULL.
    184          *                       (1) String buffer(s) overlap with NULL address.
    185          *                       (2) Source string copied into destination string buffer up to but NOT beyond or
    186          *                           including the NULL address; destination string buffer properly terminated
    187          *                           with NULL character.
    188          *
    189          *                   (c) Source string's terminating NULL character found.
    190          *                       (1) Entire source string copied into destination string buffer.
    191          *********************************************************************************************************
    192          */
    193          

   \                                 In segment CODE, align 4, keep-with-next
    194          CPU_CHAR  *Str_Copy (CPU_CHAR  *pdest,
    195                               CPU_CHAR  *psrc)
    196          {
   \                     Str_Copy:
   \   00000000   10B5               PUSH     {R4,LR}
    197              CPU_CHAR  *pstr;
    198              CPU_CHAR  *pstr_next;
    199          
    200                                                                          /* Rtn NULL if str ptr(s) NULL (see Note #2a).          */
    201              if (pdest == (CPU_CHAR *)0) {
   \   00000002   0028               CMP      R0,#+0
   \   00000004   01D1               BNE.N    ??Str_Copy_0
    202                  return  ((CPU_CHAR *)0);
   \                     ??Str_Copy_1:
   \   00000006   0020               MOVS     R0,#+0
   \   00000008   10BD               POP      {R4,PC}
    203              }
    204              if (psrc  == (CPU_CHAR *)0) {
   \                     ??Str_Copy_0:
   \   0000000A   0029               CMP      R1,#+0
   \   0000000C   FBD0               BEQ.N    ??Str_Copy_1
    205                  return  ((CPU_CHAR *)0);
    206              }
    207          
    208          
    209              pstr      = pdest;
   \   0000000E   0200               MOVS     R2,R0
    210              pstr_next = pstr;
    211              pstr_next++;
   \   00000010   1300               MOVS     R3,R2
   \   00000012   5B1C               ADDS     R3,R3,#+1
   \   00000014   03E0               B.N      ??Str_Copy_2
    212              while (( pstr_next != (CPU_CHAR *)0) &&                     /* Copy str until NULL ptr(s) (see Note #2b) ...        */
    213                     ( psrc      != (CPU_CHAR *)0) &&
    214                     (*psrc      != (CPU_CHAR  )0)) {                     /* ... or NULL char found     (see Note #2c).           */
    215                 *pstr = *psrc;
   \                     ??Str_Copy_3:
   \   00000016   1470               STRB     R4,[R2, #+0]
    216                  pstr++;
   \   00000018   521C               ADDS     R2,R2,#+1
    217                  pstr_next++;
   \   0000001A   5B1C               ADDS     R3,R3,#+1
    218                  psrc++;
   \   0000001C   491C               ADDS     R1,R1,#+1
    219              }
   \                     ??Str_Copy_2:
   \   0000001E   002B               CMP      R3,#+0
   \   00000020   04D0               BEQ.N    ??Str_Copy_4
   \   00000022   0029               CMP      R1,#+0
   \   00000024   02D0               BEQ.N    ??Str_Copy_4
   \   00000026   0C78               LDRB     R4,[R1, #+0]
   \   00000028   002C               CMP      R4,#+0
   \   0000002A   F4D1               BNE.N    ??Str_Copy_3
    220          
    221             *pstr = (CPU_CHAR)0;                                         /* Append NULL char (see Note #2b2).                    */
   \                     ??Str_Copy_4:
   \   0000002C   0021               MOVS     R1,#+0
   \   0000002E   1170               STRB     R1,[R2, #+0]
    222          
    223          
    224              return (pdest);
   \   00000030   10BD               POP      {R4,PC}          ;; return
    225          }
    226          
    227          
    228          /*$PAGE*/
    229          /*
    230          *********************************************************************************************************
    231          *                                            Str_Copy_N()
    232          *
    233          * Description : Copy source string to destination string buffer, up to a maximum number of characters.
    234          *
    235          * Argument(s) : pdest       Pointer to destination string buffer to receive source string copy (see Note #1).
    236          *
    237          *               psrc        Pointer to source      string to copy into destination string buffer.
    238          *
    239          *               len_max     Maximum number of characters to copy (see Note #2d).
    240          *
    241          * Return(s)   : Pointer to destination string, if NO errors (see Note #2).
    242          *
    243          *               Pointer to NULL,               otherwise.
    244          *
    245          * Caller(s)   : Application.
    246          *
    247          * Note(s)     : (1) Destination buffer size NOT validated; buffer overruns MUST be prevented by caller.
    248          *
    249          *                   (a) Destination buffer size MUST be large enough to accommodate the entire source 
    250          *                       string size including the terminating NULL character.
    251          *
    252          *               (2) String copy terminates when :
    253          *
    254          *                   (a) Destination/Source string pointer(s) are passed NULL pointers.
    255          *                       (1) No string copy performed; NULL pointer returned.
    256          *
    257          *                   (b) Destination/Source string pointer(s) points to NULL.
    258          *                       (1) String buffer(s) overlap with NULL address.
    259          *                       (2) Source string copied into destination string buffer up to but NOT beyond or
    260          *                           including the NULL address; destination string buffer properly terminated
    261          *                           with NULL character.
    262          *
    263          *                   (c) Source string's terminating NULL character found.
    264          *                       (1) Entire source string copied into destination string buffer.
    265          *
    266          *                   (d) 'len_max' number of characters copied.
    267          *                       (1) 'len_max' number of characters does NOT include the terminating NULL character.
    268          *
    269          *                           See also Note #1a.
    270          *********************************************************************************************************
    271          */
    272          

   \                                 In segment CODE, align 4, keep-with-next
    273          CPU_CHAR  *Str_Copy_N (CPU_CHAR    *pdest,
    274                                 CPU_CHAR    *psrc,
    275                                 CPU_SIZE_T   len_max)
    276          {
   \                     Str_Copy_N:
   \   00000000   F0B5               PUSH     {R4-R7,LR}
    277              CPU_CHAR    *pstr;
    278              CPU_CHAR    *pstr_next;
    279              CPU_SIZE_T   len_copy;
    280          
    281                                                                          /* Rtn NULL if str ptr(s) NULL      (see Note #2a).     */
    282              if (pdest == (CPU_CHAR *)0) {
   \   00000002   0028               CMP      R0,#+0
   \   00000004   01D1               BNE.N    ??Str_Copy_N_0
    283                  return  ((CPU_CHAR *)0);
   \                     ??Str_Copy_N_1:
   \   00000006   0020               MOVS     R0,#+0
   \   00000008   F0BD               POP      {R4-R7,PC}
    284              }
    285              if (psrc  == (CPU_CHAR *)0) {
   \                     ??Str_Copy_N_0:
   \   0000000A   0029               CMP      R1,#+0
   \   0000000C   FBD0               BEQ.N    ??Str_Copy_N_1
    286                  return  ((CPU_CHAR *)0);
    287              }
    288          
    289              if (len_max == (CPU_SIZE_T)0) {                             /* Rtn NULL if copy len equals zero (see Note #2d).     */
   \   0000000E   002A               CMP      R2,#+0
   \   00000010   F9D0               BEQ.N    ??Str_Copy_N_1
    290                  return  ((CPU_CHAR *)0);
    291              }
    292          
    293          
    294              pstr      = pdest;
   \   00000012   0400               MOVS     R4,R0
    295              pstr_next = pstr;
    296              pstr_next++;
   \   00000014   2500               MOVS     R5,R4
   \   00000016   6D1C               ADDS     R5,R5,#+1
    297              len_copy  = 0;
   \   00000018   0023               MOVS     R3,#+0
   \   0000001A   1E00               MOVS     R6,R3
   \   0000001C   04E0               B.N      ??Str_Copy_N_2
    298          
    299              while (( pstr_next != (CPU_CHAR *)0) &&                     /* Copy str until NULL ptr(s)  (see Note #2b)  ...      */
    300                     ( psrc      != (CPU_CHAR *)0) &&
    301                     (*psrc      != (CPU_CHAR  )0) &&                     /* ... or NULL char found      (see Note #2c); ...      */
    302                     ( len_copy  <  (CPU_SIZE_T)len_max)) {               /* ... or max nbr chars copied (see Note #2d).          */
    303                 *pstr = *psrc;
   \                     ??Str_Copy_N_3:
   \   0000001E   2770               STRB     R7,[R4, #+0]
    304                  pstr++;
   \   00000020   641C               ADDS     R4,R4,#+1
    305                  pstr_next++;
   \   00000022   6D1C               ADDS     R5,R5,#+1
    306                  psrc++;
   \   00000024   491C               ADDS     R1,R1,#+1
    307                  len_copy++;

⌨️ 快捷键说明

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