?? lib_str.lst
字號:
615 *
616 * (d) 'len_max' number of characters concatenated.
617 *
618 * (1) 'len_max' number of characters does NOT include the terminating NULL character
619 * (see Note #2a2).
620 *
621 * (2) Null concatenations allowed (i.e. zero-length concatenations).
622 * (A) No string concatenation performed; destination string returned
623 * (see Note #2b1).
624 *********************************************************************************************************
625 */
626 /*$PAGE*/
\ In section .text, align 2, keep-with-next
627 CPU_CHAR *Str_Cat_N ( CPU_CHAR *pstr_dest,
628 const CPU_CHAR *pstr_cat,
629 CPU_SIZE_T len_max)
630 {
\ Str_Cat_N:
\ 00000000 70B4 PUSH {R4-R6}
\ 00000002 0300 MOVS R3,R0
631 CPU_CHAR *pstr_cat_dest;
632 const CPU_CHAR *pstr_cat_src;
633 CPU_SIZE_T len_cat;
634
635 /* Rtn NULL if str ptr(s) NULL (see Note #3a1). */
636 if (pstr_dest == (CPU_CHAR *)0) {
\ 00000004 002B CMP R3,#+0
\ 00000006 01D1 BNE.N ??Str_Cat_N_0
637 return ((CPU_CHAR *)0);
\ 00000008 0020 MOVS R0,#+0
\ 0000000A 2EE0 B.N ??Str_Cat_N_1
638 }
639 if (pstr_cat == (const CPU_CHAR *)0) {
\ ??Str_Cat_N_0:
\ 0000000C 0029 CMP R1,#+0
\ 0000000E 01D1 BNE.N ??Str_Cat_N_2
640 return ((CPU_CHAR *)0);
\ 00000010 0020 MOVS R0,#+0
\ 00000012 2AE0 B.N ??Str_Cat_N_1
641 }
642
643 if (len_max == 0) { /* Rtn dest str if cat len = 0 (see Note #3d2A). */
\ ??Str_Cat_N_2:
\ 00000014 002A CMP R2,#+0
\ 00000016 01D1 BNE.N ??Str_Cat_N_3
644 return ((CPU_CHAR *)pstr_dest);
\ 00000018 1800 MOVS R0,R3
\ 0000001A 26E0 B.N ??Str_Cat_N_1
645 }
646
647
648 pstr_cat_dest = pstr_dest;
\ ??Str_Cat_N_3:
\ 0000001C 1C00 MOVS R4,R3
649 while (( pstr_cat_dest != (CPU_CHAR *) 0 ) && /* Adv to end of cur dest str until NULL ptr ... */
650 (*pstr_cat_dest != (CPU_CHAR )'\0')) { /* ... or NULL char found.. */
\ ??Str_Cat_N_4:
\ 0000001E 002C CMP R4,#+0
\ 00000020 04D0 BEQ.N ??Str_Cat_N_5
\ 00000022 2078 LDRB R0,[R4, #+0]
\ 00000024 0028 CMP R0,#+0
\ 00000026 01D0 BEQ.N ??Str_Cat_N_5
651 pstr_cat_dest++;
\ 00000028 641C ADDS R4,R4,#+1
\ 0000002A F8E7 B.N ??Str_Cat_N_4
652 }
653 if (pstr_cat_dest == (CPU_CHAR *)0) { /* Rtn NULL if NULL ptr found (see Note #3b1). */
\ ??Str_Cat_N_5:
\ 0000002C 002C CMP R4,#+0
\ 0000002E 01D1 BNE.N ??Str_Cat_N_6
654 return ((CPU_CHAR *)0);
\ 00000030 0020 MOVS R0,#+0
\ 00000032 1AE0 B.N ??Str_Cat_N_1
655 }
656
657 pstr_cat_src = pstr_cat;
\ ??Str_Cat_N_6:
\ 00000034 0D00 MOVS R5,R1
658 len_cat = 0u;
\ 00000036 0020 MOVS R0,#+0
\ 00000038 0600 MOVS R6,R0
659
660 while (( pstr_cat_dest != ( CPU_CHAR *) 0 ) && /* Cat str until NULL ptr(s) [see Note #3b] ... */
661 ( pstr_cat_src != (const CPU_CHAR *) 0 ) &&
662 (*pstr_cat_src != ( CPU_CHAR )'\0') && /* ... or NULL char found (see Note #3c); ... */
663 ( len_cat < ( CPU_SIZE_T)len_max)) { /* ... or max nbr chars cat'd (see Note #3d). */
\ ??Str_Cat_N_7:
\ 0000003A 002C CMP R4,#+0
\ 0000003C 0CD0 BEQ.N ??Str_Cat_N_8
\ 0000003E 002D CMP R5,#+0
\ 00000040 0AD0 BEQ.N ??Str_Cat_N_8
\ 00000042 2878 LDRB R0,[R5, #+0]
\ 00000044 0028 CMP R0,#+0
\ 00000046 07D0 BEQ.N ??Str_Cat_N_8
\ 00000048 9642 CMP R6,R2
\ 0000004A 05D2 BCS.N ??Str_Cat_N_8
664 *pstr_cat_dest = *pstr_cat_src;
\ 0000004C 2878 LDRB R0,[R5, #+0]
\ 0000004E 2070 STRB R0,[R4, #+0]
665 pstr_cat_dest++;
\ 00000050 641C ADDS R4,R4,#+1
666 pstr_cat_src++;
\ 00000052 6D1C ADDS R5,R5,#+1
667 len_cat++;
\ 00000054 761C ADDS R6,R6,#+1
\ 00000056 F0E7 B.N ??Str_Cat_N_7
668 }
669 /* Rtn NULL if NULL ptr(s) found (see Note #3b1). */
670 if ((pstr_cat_dest == ( CPU_CHAR *)0) ||
671 (pstr_cat_src == (const CPU_CHAR *)0)) {
\ ??Str_Cat_N_8:
\ 00000058 002C CMP R4,#+0
\ 0000005A 01D0 BEQ.N ??Str_Cat_N_9
\ 0000005C 002D CMP R5,#+0
\ 0000005E 01D1 BNE.N ??Str_Cat_N_10
672 return ((CPU_CHAR *)0);
\ ??Str_Cat_N_9:
\ 00000060 0020 MOVS R0,#+0
\ 00000062 02E0 B.N ??Str_Cat_N_1
673 }
674
675 *pstr_cat_dest = (CPU_CHAR)'\0'; /* Append NULL char (see Note #2a2C). */
\ ??Str_Cat_N_10:
\ 00000064 0020 MOVS R0,#+0
\ 00000066 2070 STRB R0,[R4, #+0]
676
677
678 return (pstr_dest); /* Rtn ptr to dest str (see Note #2b1). */
\ 00000068 1800 MOVS R0,R3
\ ??Str_Cat_N_1:
\ 0000006A 70BC POP {R4-R6}
\ 0000006C 7047 BX LR ;; return
679 }
680
681
682 /*$PAGE*/
683 /*
684 *********************************************************************************************************
685 * Str_Cmp()
686 *
687 * Description : Determine if two strings are identical.
688 *
689 * Argument(s) : p1_str Pointer to first string (see Note #1).
690 *
691 * p2_str Pointer to second string (see Note #1).
692 *
693 * Return(s) : 0, if strings are identical (see Notes #3a1A, #3a2A, & #3b).
694 *
695 * Negative value, if 'p1_str' is less than 'p2_str' (see Notes #3a1B1, #3a2B1, & #3c).
696 *
697 * Positive value, if 'p1_str' is greater than 'p2_str' (see Notes #3a1B2, #3a2B2, & #3c).
698 *
699 * See also Note #2b.
700 *
701 * Caller(s) : Application.
702 *
703 * Note(s) : (1) String buffers NOT modified.
704 *
705 * (2) (a) IEEE Std 1003.1, 2004 Edition, Section 'strcmp() : DESCRIPTION' states that "the
706 * strcmp() function shall compare the string pointed to by 's1' ('p1_str') to the
707 * string pointed to by 's2' ('p2_str)".
708 *
709 * (b) (1) IEEE Std 1003.1, 2004 Edition, Section 'strcmp() : RETURN VALUE' states that
710 * "upon successful completion, strcmp() shall return an integer greater than,
711 * equal to, or less than 0".
712 *
713 * (2) IEEE Std 1003.1, 2004 Edition, Section 'strcmp() : DESCRIPTION' adds that "the
714 * sign of a non-zero return value shall be determined by the sign of the difference
715 * between the values of the first pair of bytes ... that differ in the strings
716 * being compared".
717 *
718 * (3) String comparison terminates when :
719 *
720 * (a) (1) (A) BOTH string pointer(s) are passed NULL pointers.
721 * (1) NULL strings identical; 0 returned.
722 *
723 * (B) (1) 'p1_str' passed a NULL pointer.
724 * (a) Return negative value of character pointed to by 'p2_str'.
725 *
726 * (2) 'p2_str' passed a NULL pointer.
727 * (a) Return positive value of character pointed to by 'p1_str'.
728 *
729 * (2) (A) BOTH strings point to NULL.
730 * (1) Strings overlap with NULL address.
731 * (2) Strings identical up to but NOT beyond or including the NULL address;
732 * 0 returned.
733 *
734 * (B) (1) 'p1_str_cmp_next' points to NULL.
735 * (a) 'p1_str' overlaps with NULL address.
736 * (b) Strings compared up to but NOT beyond or including the NULL address.
737 * (c) Return negative value of character pointed to by 'p2_str_cmp_next'.
738 *
739 * (2) 'p2_str_cmp_next' points to NULL.
740 * (a) 'p2_str' overlaps with NULL address.
741 * (b) Strings compared up to but NOT beyond or including the NULL address.
742 * (c) Return positive value of character pointed to by 'p1_str_cmp_next'.
743 *
744 * (b) Terminating NULL character found in both strings.
7
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -