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

📄 lib_str.lst

📁 stm32+ucos-ii
💻 LST
📖 第 1 页 / 共 5 页
字号:
    462          
    463              while (( pstr_copy_dest != (      CPU_CHAR *)  0 ) &&       /* Copy str until NULL ptr(s)  [see Note #3b]  ...      */
    464                     ( pstr_copy_src  != (const CPU_CHAR *)  0 ) &&
    465                     (*pstr_copy_src  != (      CPU_CHAR  )'\0') &&       /* ... or NULL char found      (see Note #3c); ...      */
    466                     ( len_copy       <  (      CPU_SIZE_T)len_max)) {    /* ... or max nbr chars copied (see Note #3d).          */
   \                     ??Str_Copy_N_3:
   \   0000001C   002C               CMP      R4,#+0
   \   0000001E   0CD0               BEQ.N    ??Str_Copy_N_4
   \   00000020   002D               CMP      R5,#+0
   \   00000022   0AD0               BEQ.N    ??Str_Copy_N_4
   \   00000024   2878               LDRB     R0,[R5, #+0]
   \   00000026   0028               CMP      R0,#+0
   \   00000028   07D0               BEQ.N    ??Str_Copy_N_4
   \   0000002A   9642               CMP      R6,R2
   \   0000002C   05D2               BCS.N    ??Str_Copy_N_4
    467                 *pstr_copy_dest = *pstr_copy_src;
   \   0000002E   2878               LDRB     R0,[R5, #+0]
   \   00000030   2070               STRB     R0,[R4, #+0]
    468                  pstr_copy_dest++;
   \   00000032   641C               ADDS     R4,R4,#+1
    469                  pstr_copy_src++;
   \   00000034   6D1C               ADDS     R5,R5,#+1
    470                  len_copy++;
   \   00000036   761C               ADDS     R6,R6,#+1
   \   00000038   F0E7               B.N      ??Str_Copy_N_3
    471              }
    472                                                                          /* Rtn NULL if NULL ptr(s) found  (see Note #3b1).      */
    473              if ((pstr_copy_dest == (      CPU_CHAR *)0) ||
    474                  (pstr_copy_src  == (const CPU_CHAR *)0)) {
   \                     ??Str_Copy_N_4:
   \   0000003A   002C               CMP      R4,#+0
   \   0000003C   01D0               BEQ.N    ??Str_Copy_N_5
   \   0000003E   002D               CMP      R5,#+0
   \   00000040   01D1               BNE.N    ??Str_Copy_N_6
    475                   return ((CPU_CHAR *)0);
   \                     ??Str_Copy_N_5:
   \   00000042   0020               MOVS     R0,#+0
   \   00000044   04E0               B.N      ??Str_Copy_N_1
    476              }
    477          
    478              if (len_copy < len_max) {                                   /* If  copy str len < max buf len (see Note #2a2A), ... */
   \                     ??Str_Copy_N_6:
   \   00000046   9642               CMP      R6,R2
   \   00000048   01D2               BCS.N    ??Str_Copy_N_7
    479                 *pstr_copy_dest = (CPU_CHAR)'\0';                        /* ... copy NULL char  (see Note #3c1).                 */
   \   0000004A   0020               MOVS     R0,#+0
   \   0000004C   2070               STRB     R0,[R4, #+0]
    480              }
    481          
    482          
    483              return (pstr_dest);                                         /* Rtn ptr to dest str (see Note #2b1).                 */
   \                     ??Str_Copy_N_7:
   \   0000004E   1800               MOVS     R0,R3
   \                     ??Str_Copy_N_1:
   \   00000050   70BC               POP      {R4-R6}
   \   00000052   7047               BX       LR               ;; return
    484          }
    485          
    486          
    487          /*$PAGE*/
    488          /*
    489          *********************************************************************************************************
    490          *                                              Str_Cat()
    491          *
    492          * Description : Append concatenation string to destination string.
    493          *
    494          * Argument(s) : pstr_dest   Pointer to destination   string to append concatenation  string (see Note #1a).
    495          *
    496          *               pstr_cat    Pointer to concatenation string to append to destination string (see Note #1b).
    497          *
    498          * Return(s)   : Pointer to destination string, if NO error(s) [see Note #2b1].
    499          *
    500          *               Pointer to NULL,               otherwise      (see Note #2b2A).
    501          *
    502          * Caller(s)   : Application.
    503          *
    504          * Note(s)     : (1) (a) Destination buffer size NOT validated; buffer overruns MUST be prevented by caller.
    505          *
    506          *                       (1) Destination buffer size MUST be large enough to accommodate the entire 
    507          *                           concatenated string size including the terminating NULL character.
    508          *
    509          *                   (b) Concatenation string buffer NOT modified.
    510          *
    511          *               (2) (a) IEEE Std 1003.1, 2004 Edition, Section 'strcat() : DESCRIPTION' states that :
    512          *
    513          *                       (1) "The strcat() function shall append a copy of the string pointed to by 's2' 
    514          *                           ('pstr_cat') ... to the end of the string pointed to by 's1' ('pstr_dest')."
    515          *
    516          *                       (2) (A) "The initial byte of 's2' ('pstr_cat') overwrites the null byte at the 
    517          *                                end of 's1' ('pstr_dest')."
    518          *                           (B)  A "terminating null byte" is appended at the end of the concatenated 
    519          *                                destination strings.
    520          *
    521          *                   (b) IEEE Std 1003.1, 2004 Edition, Section 'strcat() : RETURN VALUE' states that :
    522          *
    523          *                       (1) "The strcat() function shall return 's1' ('pstr_dest');" ...
    524          *                       (2) "no return value shall be reserved to indicate an error."
    525          *                           (A) #### This requirement is intentionally NOT implemented in order to return 
    526          *                               NULL for any error(s).
    527          *
    528          *                   (c) IEEE Std 1003.1, 2004 Edition, Section 'strcat() : DESCRIPTION' states that "if
    529          *                       copying takes place between objects that overlap, the behavior is undefined."
    530          *
    531          *               (3) String concatenation terminates when :
    532          *
    533          *                   (a) Destination/Concatenation string pointer(s) are passed NULL pointers.
    534          *                       (1) No string concatenation performed; NULL pointer returned.
    535          *
    536          *                   (b) Destination/Concatenation string pointer(s) point to NULL.
    537          *                       (1) String buffer(s) overlap with NULL address; NULL pointer returned.
    538          *
    539          *                   (c) Concatenation string's terminating NULL character found.
    540          *                       (1) Entire concatenation string appended to destination string (see Note #2a1).
    541          *********************************************************************************************************
    542          */
    543          

   \                                 In section .text, align 2, keep-with-next
    544          CPU_CHAR  *Str_Cat (       CPU_CHAR  *pstr_dest,
    545                              const  CPU_CHAR  *pstr_cat)
    546          {
   \                     Str_Cat:
   \   00000000   70B5               PUSH     {R4-R6,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   0D00               MOVS     R5,R1
    547              CPU_CHAR  *pstr_rtn;
    548          
    549              
    550              pstr_rtn = Str_Cat_N(pstr_dest,
    551                                   pstr_cat,
    552                                   DEF_INT_CPU_U_MAX_VAL);
   \   00000006   5FF0FF32           MOVS     R2,#-1
   \   0000000A   2900               MOVS     R1,R5
   \   0000000C   2000               MOVS     R0,R4
   \   0000000E   ........           BL       Str_Cat_N
   \   00000012   0600               MOVS     R6,R0
    553          
    554              return (pstr_rtn);
   \   00000014   3000               MOVS     R0,R6
   \   00000016   70BD               POP      {R4-R6,PC}       ;; return
    555          }
    556          
    557          
    558          /*$PAGE*/
    559          /*
    560          *********************************************************************************************************
    561          *                                             Str_Cat_N()
    562          *
    563          * Description : Append concatenation string to destination string, up to a maximum number of characters.
    564          *
    565          * Argument(s) : pstr_dest   Pointer to destination   string to append concatenation  string (see Note #1a).
    566          *
    567          *               pstr_cat    Pointer to concatenation string to append to destination string (see Note #1b).
    568          *
    569          *               len_max     Maximum number of characters to concatenate (see Notes #2a1B & #3d).
    570          *
    571          * Return(s)   : Pointer to destination string, if NO error(s) [see Note #2b1].
    572          *
    573          *               Pointer to NULL,               otherwise      (see Note #2b2A).
    574          *
    575          * Caller(s)   : Application.
    576          *
    577          * Note(s)     : (1) (a) Destination buffer size NOT validated; buffer overruns MUST be prevented by caller.
    578          *
    579          *                       (1) Destination buffer size MUST be large enough to accommodate the entire 
    580          *                           concatenated string size including the terminating NULL character.
    581          *
    582          *                   (b) Concatenation string buffer NOT modified.
    583          *
    584          *               (2) (a) IEEE Std 1003.1, 2004 Edition, Section 'strncat() : DESCRIPTION' states that :
    585          *
    586          *                       (1) (A) "The strncat() function shall append ... the array pointed to by 's2' 
    587          *                               ('pstr_cat') to the end of the string pointed to by 's1' ('pstr_dest')" ...
    588          *                           (B)  but "not more than 'n' ('len_max') bytes".
    589          *
    590          *                       (2) (A) "The initial byte of 's2' ('pstr_cat') overwrites the null byte at the 
    591          *                                end of 's1' ('pstr_dest')."
    592          *                           (B) "(a null byte and bytes that follow it are not appended)."
    593          *                           (C) "A terminating null byte is always appended to the result."
    594          *
    595          *                   (b) IEEE Std 1003.1, 2004 Edition, Section 'strncat() : RETURN VALUE' states that :
    596          *
    597          *                       (1) "The strncat() function shall return 's1' ('pstr_dest');" ...
    598          *                       (2) "no return value shall be reserved to indicate an error."
    599          *                           (A) #### This requirement is intentionally NOT implemented in order to return 
    600          *                               NULL for any error(s).
    601          *
    602          *                   (c) IEEE Std 1003.1, 2004 Edition, Section 'strncat() : DESCRIPTION' states that "if
    603          *                       copying takes place between objects that overlap, the behavior is undefined."
    604          *
    605          *               (3) String concatenation terminates when :
    606          *
    607          *                   (a) Destination/Concatenation string pointer(s) are passed NULL pointers.
    608          *                       (1) No string concatenation performed; NULL pointer returned.
    609          *
    610          *                   (b) Destination/Concatenation string pointer(s) point to NULL.
    611          *                       (1) String buffer(s) overlap with NULL address; NULL pointer returned.
    612          *
    613          *                   (c) Concatenation string's terminating NULL character found.
    614          *                       (1) Entire concatenation string appended to destination string (see Note #2a1A).

⌨️ 快捷键说明

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