📄 lib_str.lst
字号:
591 p2_str++;
\ 000000A4 011091E2 ADDS R1,R1,#+1
\ 000000A8 EFFFFFEA B ??Str_Cmp_4
592 }
593
594
595 if (*p1_str != *p2_str) { /* If strs NOT identical, ... */
\ ??Str_Cmp_5:
\ 000000AC 0000D2E5 LDRB R0,[R2, #+0]
\ 000000B0 0050D1E5 LDRB R5,[R1, #+0]
\ 000000B4 050050E1 CMP R0,R5
\ 000000B8 0400000A BEQ ??Str_Cmp_6
596 cmp_val = (CPU_INT16S)(*p1_str) - (CPU_INT16S)(*p2_str); /* ... calc & rtn char diff (see Note #2d1). */
\ 000000BC 0000D2E5 LDRB R0,[R2, #+0]
\ 000000C0 0050D1E5 LDRB R5,[R1, #+0]
\ 000000C4 050050E0 SUBS R0,R0,R5
\ 000000C8 0030B0E1 MOVS R3,R0
\ 000000CC 120000EA B ??Str_Cmp_7
597
598 } else if (*p1_str == (CPU_CHAR)0) { /* If NULL char(s) found, ... */
\ ??Str_Cmp_6:
\ 000000D0 0000D2E5 LDRB R0,[R2, #+0]
\ 000000D4 000050E3 CMP R0,#+0
\ 000000D8 0200001A BNE ??Str_Cmp_8
599 cmp_val = 0; /* ... strs identical; rtn 0 (see Note #2e). */
\ 000000DC 0000A0E3 MOV R0,#+0
\ 000000E0 0030B0E1 MOVS R3,R0
\ 000000E4 0C0000EA B ??Str_Cmp_7
600
601 } else {
602 if (p1_str_next == (CPU_CHAR *)0) {
\ ??Str_Cmp_8:
\ 000000E8 00005CE3 CMP R12,#+0
\ 000000EC 0800001A BNE ??Str_Cmp_9
603 if (p2_str_next == (CPU_CHAR *)0) { /* If BOTH next str ptrs NULL, ... */
\ 000000F0 000054E3 CMP R4,#+0
\ 000000F4 0200001A BNE ??Str_Cmp_10
604 cmp_val = (CPU_INT16S)0; /* ... rtn 0 (see Note #2f). */
\ 000000F8 0000A0E3 MOV R0,#+0
\ 000000FC 0030B0E1 MOVS R3,R0
\ 00000100 050000EA B ??Str_Cmp_7
605 } else { /* If p1_str_next NULL, ... */
606 cmp_val = (CPU_INT16S)0 - (CPU_INT16S)(*p2_str_next); /* ... rtn neg p2_str_next val (see Note #2g). */
\ ??Str_Cmp_10:
\ 00000104 0000D4E5 LDRB R0,[R4, #+0]
\ 00000108 000070E2 RSBS R0,R0,#+0
\ 0000010C 0030B0E1 MOVS R3,R0
\ 00000110 010000EA B ??Str_Cmp_7
607 }
608 } else { /* If p2_str_next NULL, ... */
609 cmp_val = (CPU_INT16S)(*p1_str_next); /* ... rtn pos p1_str_next val (see Note #2h). */
\ ??Str_Cmp_9:
\ 00000114 0000DCE5 LDRB R0,[R12, #+0]
\ 00000118 0030B0E1 MOVS R3,R0
610 }
611 }
612
613
614 return (cmp_val);
\ ??Str_Cmp_7:
\ 0000011C 0300B0E1 MOVS R0,R3
\ 00000120 0008A0E1 MOV R0,R0, LSL #+16
\ 00000124 4008B0E1 MOVS R0,R0, ASR #+16
\ ??Str_Cmp_2:
\ 00000128 3000BDE8 POP {R4,R5}
\ 0000012C 0EF0A0E1 MOV PC,LR ;; return
615 }
616
617
618 /*$PAGE*/
619 /*
620 *********************************************************************************************************
621 * Str_Cmp_N()
622 *
623 * Description : Determine if two strings are identical for up to a maximum number of characters.
624 *
625 * Argument(s) : p1_str Pointer to first string (see Note #1).
626 *
627 * p2_str Pointer to second string (see Note #1).
628 *
629 * len_max Maximum number of characters to compare (see Notes #2i & #2j).
630 *
631 * Return(s) : 0, if strings are identical (see Notes #2a, #2e, #2f, #2i, & #2j).
632 *
633 * Negative value, if 'p1_str' is less than 'p2_str' (see Notes #2b, #2g, & #2d).
634 *
635 * Positive value, if 'p1_str' is greater than 'p2_str' (see Notes #2c, #2h, & #2d).
636 *
637 * Caller(s) : various.
638 *
639 * Note(s) : (1) String buffers NOT modified.
640 *
641 * (2) String comparison terminates when :
642 *
643 * (a) BOTH string pointer(s) are passed NULL pointers.
644 * (1) NULL strings identical; return 0.
645 *
646 * (b) 'p1_str' passed a NULL pointer.
647 * (1) Return negative value of character pointed to by 'p2_str'.
648 *
649 * (c) 'p2_str' passed a NULL pointer.
650 * (1) Return positive value of character pointed to by 'p1_str'.
651 *
652 * (d) Non-matching characters found.
653 * (1) Return signed-integer difference of the character pointed to by 'p2_str'
654 * from the character pointed to by 'p1_str'.
655 *
656 * (e) Terminating NULL character found in both strings.
657 * (1) Strings identical; return 0.
658 * (2) Only one NULL character test required in conditional since previous condition
659 * tested character equality.
660 *
661 * (f) BOTH strings point to NULL.
662 * (1) Strings overlap with NULL address.
663 * (2) Strings identical up to but NOT beyond or including the NULL address; return 0.
664 *
665 * (g) 'p1_str_next' points to NULL.
666 * (1) 'p1_str' overlaps with NULL address.
667 * (2) Strings compared up to but NOT beyond or including the NULL address.
668 * (3) Return negative value of character pointed to by 'p2_str_next'.
669 *
670 * (h) 'p2_str_next' points to NULL.
671 * (1) 'p2_str' overlaps with NULL address.
672 * (2) Strings compared up to but NOT beyond or including the NULL address.
673 * (3) Return positive value of character pointed to by 'p1_str_next'.
674 *
675 * (i) 'len_max' passed a zero length.
676 * (1) Zero-length strings identical; return 0.
677 *
678 * (j) First 'len_max' number of characters identical.
679 * (1) Strings identical; return 0.
680 *
681 * (3) Since 16-bit signed arithmetic is performed to calculate a non-identical comparison
682 * return value, 'CPU_CHAR' native data type size MUST be 8-bit.
683 *********************************************************************************************************
684 */
685 /*$PAGE*/
\ In segment CODE, align 4, keep-with-next
686 CPU_INT16S Str_Cmp_N (CPU_CHAR *p1_str,
687 CPU_CHAR *p2_str,
688 CPU_SIZE_T len_max)
689 {
\ Str_Cmp_N:
\ 00000000 F0002DE9 PUSH {R4-R7}
\ 00000004 0030B0E1 MOVS R3,R0
690 CPU_CHAR *p1_str_next;
691 CPU_CHAR *p2_str_next;
692 CPU_INT16S cmp_val;
693 CPU_SIZE_T cmp_len;
694
695
696 if (len_max == 0) { /* If cmp len equals zero, rtn 0 (see Note #2i). */
\ 00000008 000052E3 CMP R2,#+0
\ 0000000C 0100001A BNE ??Str_Cmp_N_0
697 return ((CPU_INT16S)0);
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 500000EA B ??Str_Cmp_N_1
698 }
699
700 if (p1_str == (CPU_CHAR *)0) {
\ ??Str_Cmp_N_0:
\ 00000018 000053E3 CMP R3,#+0
\ 0000001C 0A00001A BNE ??Str_Cmp_N_2
701 if (p2_str == (CPU_CHAR *)0) {
\ 00000020 000051E3 CMP R1,#+0
\ 00000024 0100001A BNE ??Str_Cmp_N_3
702 return ((CPU_INT16S)0); /* If BOTH str ptrs NULL, rtn 0 (see Note #2a). */
\ 00000028 0000A0E3 MOV R0,#+0
\ 0000002C 4A0000EA B ??Str_Cmp_N_1
703 }
704 cmp_val = (CPU_INT16S)0 - (CPU_INT16S)(*p2_str);
\ ??Str_Cmp_N_3:
\ 00000030 0000D1E5 LDRB R0,[R1, #+0]
\ 00000034 000070E2 RSBS R0,R0,#+0
\ 00000038 0040B0E1 MOVS R4,R0
705 return (cmp_val); /* If p1_str NULL, rtn neg p2_str val (see Note #2b). */
\ 0000003C 0400B0E1 MOVS R0,R4
\ 00000040 0008A0E1 MOV R0,R0, LSL #+16
\ 00000044 4008B0E1 MOVS R0,R0, ASR #+16
\ 00000048 430000EA B ??Str_Cmp_N_1
706 }
707 if (p2_str == (CPU_CHAR *)0) {
\ ??Str_Cmp_N_2:
\ 0000004C 000051E3 CMP R1,#+0
\ 00000050 0500001A BNE ??Str_Cmp_N_4
708 cmp_val = (CPU_INT16S)(*p1_str);
\ 00000054 0000D3E5 LDRB R0,[R3, #+0]
\ 00000058 0040B0E1 MOVS R4,R0
709 return (cmp_val); /* If p2_str NULL, rtn pos p1_str val (see Note #2c). */
\ 0000005C 0400B0E1 MOVS R0,R4
\ 00000060 0008A0E1 MOV R0,R0, LSL #+16
\ 00000064 4008B0E1 MOVS R0,R0, ASR #+16
\ 00000068 3B0000EA B ??Str_Cmp_N_1
710 }
711
712
713 p1_str_next = p1_str;
\ ??Str_Cmp_N_4:
\ 0000006C 0350B0E1 MOVS R5,R3
714 p2_str_next = p2_str;
\ 00000070 0160B0E1 MOVS R6,R1
715 p1_str_next++;
\ 00000074 015095E2 ADDS R5,R5,#+1
716 p2_str_next++;
\ 00000078 016096E2 ADDS R6,R6,#+1
717 cmp_len = 0;
\ 0000007C 0000A0E3 MOV R0,#+0
\ 00000080 00C0B0E1 MOVS R12,R0
718 while ((*p1_str == *p2_str) && /* Cmp strs until non-matching char (see Note #2d) .. */
719 (*p1_str != (CPU_CHAR )0) && /* .. or NULL char(s) (see Note #2e) .. */
720 ( p1_str_next != (CPU_CHAR *)0) && /* .. or NULL ptr(s) found (see Notes #2f, #2g, & #2h); */
721 ( p2_str_next != (CPU_CHAR *)0) &&
722 ( cmp_len < (CPU_SIZE_T)len_max)) { /* .. or len nbr chars cmp'd (see Note #2j). */
\ ??Str_Cmp_N_5:
\ 00000084 0000D3E5 LDRB R0,[R3, #+0]
\ 00000088 0070D1E5 LDRB R7,[R1, #+0]
\ 0000008C 0700
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -