📄 lib_str.lst
字号:
\ Str_Cat_N:
\ 00000000 30002DE9 PUSH {R4,R5}
451 CPU_CHAR *pstr;
452 CPU_CHAR *pstr_next;
453 CPU_SIZE_T len_cat;
454
455 /* Rtn NULL if str ptr(s) NULL (see Note #2a). */
456 if (pdest == (CPU_CHAR *)0) {
\ 00000004 000050E3 CMP R0,#+0
\ 00000008 0100001A BNE ??Str_Cat_N_0
457 return ((CPU_CHAR *)0);
\ 0000000C 0000A0E3 MOV R0,#+0
\ 00000010 280000EA B ??Str_Cat_N_1
458 }
459 if (pstr_cat == (CPU_CHAR *)0) {
\ ??Str_Cat_N_0:
\ 00000014 000051E3 CMP R1,#+0
\ 00000018 0100001A BNE ??Str_Cat_N_2
460 return ((CPU_CHAR *)0);
\ 0000001C 0000A0E3 MOV R0,#+0
\ 00000020 240000EA B ??Str_Cat_N_1
461 }
462
463 if (len_max == (CPU_SIZE_T)0) { /* Rtn NULL if cat len equals zero (see Note #2e). */
\ ??Str_Cat_N_2:
\ 00000024 000052E3 CMP R2,#+0
\ 00000028 0100001A BNE ??Str_Cat_N_3
464 return ((CPU_CHAR *)0);
\ 0000002C 0000A0E3 MOV R0,#+0
\ 00000030 200000EA B ??Str_Cat_N_1
465 }
466
467
468 pstr = pdest;
\ ??Str_Cat_N_3:
\ 00000034 0030B0E1 MOVS R3,R0
\ 00000038 000000EA B ??Str_Cat_N_4
469 while (( pstr != (CPU_CHAR *)0) && /* Adv to end of cur dest str until NULL ptr ... */
470 (*pstr != (CPU_CHAR )0)) { /* ... or NULL char found.. */
471 pstr++;
\ ??Str_Cat_N_5:
\ 0000003C 013093E2 ADDS R3,R3,#+1
472 }
\ ??Str_Cat_N_4:
\ 00000040 000053E3 CMP R3,#+0
\ 00000044 0200000A BEQ ??Str_Cat_N_6
\ 00000048 0040D3E5 LDRB R4,[R3, #+0]
\ 0000004C 000054E3 CMP R4,#+0
\ 00000050 F9FFFF1A BNE ??Str_Cat_N_5
473 if (pstr == (CPU_CHAR *)0) { /* If NULL str overrun, rtn NULL (see Note #2b). */
\ ??Str_Cat_N_6:
\ 00000054 000053E3 CMP R3,#+0
\ 00000058 0100001A BNE ??Str_Cat_N_7
474 return ((CPU_CHAR *)0);
\ 0000005C 0000A0E3 MOV R0,#+0
\ 00000060 140000EA B ??Str_Cat_N_1
475 }
476
477 pstr_next = pstr;
\ ??Str_Cat_N_7:
\ 00000064 03C0B0E1 MOVS R12,R3
478 pstr_next++;
\ 00000068 01C09CE2 ADDS R12,R12,#+1
479 len_cat = 0;
\ 0000006C 0040A0E3 MOV R4,#+0
\ 00000070 050000EA B ??Str_Cat_N_8
480
481 while (( pstr_next != (CPU_CHAR *)0) && /* Cat str until NULL ptr(s) (see Note #2c) ... */
482 ( pstr_cat != (CPU_CHAR *)0) &&
483 (*pstr_cat != (CPU_CHAR )0) && /* ... or NULL char found (see Note #2d); ... */
484 ( len_cat < (CPU_SIZE_T)len_max)) { /* ... or max nbr chars cat'd (see Note #2d). */
485 *pstr = *pstr_cat;
\ ??Str_Cat_N_9:
\ 00000074 0050D1E5 LDRB R5,[R1, #+0]
\ 00000078 0050C3E5 STRB R5,[R3, #+0]
486 pstr++;
\ 0000007C 013093E2 ADDS R3,R3,#+1
487 pstr_next++;
\ 00000080 01C09CE2 ADDS R12,R12,#+1
488 pstr_cat++;
\ 00000084 011091E2 ADDS R1,R1,#+1
489 len_cat++;
\ 00000088 014094E2 ADDS R4,R4,#+1
490 }
\ ??Str_Cat_N_8:
\ 0000008C 00005CE3 CMP R12,#+0
\ 00000090 0600000A BEQ ??Str_Cat_N_10
\ 00000094 000051E3 CMP R1,#+0
\ 00000098 0400000A BEQ ??Str_Cat_N_10
\ 0000009C 0050D1E5 LDRB R5,[R1, #+0]
\ 000000A0 000055E3 CMP R5,#+0
\ 000000A4 0100000A BEQ ??Str_Cat_N_10
\ 000000A8 020054E1 CMP R4,R2
\ 000000AC F0FFFF3A BCC ??Str_Cat_N_9
491
492 *pstr = (CPU_CHAR)0; /* Append NULL char (see Note #2c2). */
\ ??Str_Cat_N_10:
\ 000000B0 0010A0E3 MOV R1,#+0
\ 000000B4 0010C3E5 STRB R1,[R3, #+0]
493
494
495 return (pdest);
\ ??Str_Cat_N_1:
\ 000000B8 3000BDE8 POP {R4,R5}
\ 000000BC 0EF0A0E1 MOV PC,LR ;; return
496 }
497
498
499 /*$PAGE*/
500 /*
501 *********************************************************************************************************
502 * Str_Cmp()
503 *
504 * Description : Determine if two strings are identical.
505 *
506 * Argument(s) : p1_str Pointer to first string (see Note #1).
507 *
508 * p2_str Pointer to second string (see Note #1).
509 *
510 * Return(s) : 0, if strings are identical (see Notes #2a, #2e, & #2f).
511 *
512 * Negative value, if 'p1_str' is less than 'p2_str' (see Notes #2b, #2g, & #2d).
513 *
514 * Positive value, if 'p1_str' is greater than 'p2_str' (see Notes #2c, #2h, & #2d).
515 *
516 * Caller(s) : various.
517 *
518 * Note(s) : (1) String buffers NOT modified.
519 *
520 * (2) String comparison terminates when :
521 *
522 * (a) BOTH string pointer(s) are passed NULL pointers.
523 * (1) NULL strings identical; return 0.
524 *
525 * (b) 'p1_str' passed a NULL pointer.
526 * (1) Return negative value of character pointed to by 'p2_str'.
527 *
528 * (c) 'p2_str' passed a NULL pointer.
529 * (1) Return positive value of character pointed to by 'p1_str'.
530 *
531 * (d) Non-matching characters found.
532 * (1) Return signed-integer difference of the character pointed to by 'p2_str'
533 * from the character pointed to by 'p1_str'.
534 *
535 * (e) Terminating NULL character found in both strings.
536 * (1) Strings identical; return 0.
537 * (2) Only one NULL character test required in conditional since previous condition
538 * tested character equality.
539 *
540 * (f) BOTH strings point to NULL.
541 * (1) Strings overlap with NULL address.
542 * (2) Strings identical up to but NOT beyond or including the NULL address; return 0.
543 *
544 * (g) 'p1_str_next' points to NULL.
545 * (1) 'p1_str' overlaps with NULL address.
546 * (2) Strings compared up to but NOT beyond or including the NULL address.
547 * (3) Return negative value of character pointed to by 'p2_str_next'.
548 *
549 * (h) 'p2_str_next' points to NULL.
550 * (1) 'p2_str' overlaps with NULL address.
551 * (2) Strings compared up to but NOT beyond or including the NULL address.
552 * (3) Return positive value of character pointed to by 'p1_str_next'.
553 *
554 * (3) Since 16-bit signed arithmetic is performed to calculate a non-identical comparison
555 * return value, 'CPU_CHAR' native data type size MUST be 8-bit.
556 *********************************************************************************************************
557 */
558 /*$PAGE*/
\ In segment CODE, align 4, keep-with-next
559 CPU_INT16S Str_Cmp (CPU_CHAR *p1_str,
560 CPU_CHAR *p2_str)
561 {
\ Str_Cmp:
\ 00000000 10002DE9 PUSH {R4}
562 CPU_CHAR *p1_str_next;
563 CPU_CHAR *p2_str_next;
564 CPU_INT16S cmp_val;
565
566
567 if (p1_str == (CPU_CHAR *)0) {
\ 00000004 000050E3 CMP R0,#+0
\ 00000008 0800001A BNE ??Str_Cmp_0
568 if (p2_str == (CPU_CHAR *)0) {
\ 0000000C 000051E3 CMP R1,#+0
\ 00000010 0100001A BNE ??Str_Cmp_1
569 return ((CPU_INT16S)0); /* If BOTH str ptrs NULL, rtn 0 (see Note #2a). */
\ 00000014 0000A0E3 MOV R0,#+0
\ 00000018 370000EA B ??Str_Cmp_2
570 }
571 cmp_val = (CPU_INT16S)0 - (CPU_INT16S)(*p2_str);
\ ??Str_Cmp_1:
\ 0000001C 0000D1E5 LDRB R0,[R1, #+0]
\ 00000020 000070E2 RSBS R0,R0,#+0
572 return (cmp_val); /* If p1_str NULL, rtn neg p2_str val (see Note #2b). */
\ 00000024 0008A0E1 MOV R0,R0, LSL #+16
\ 00000028 4008B0E1 MOVS R0,R0, ASR #+16
\ 0000002C 320000EA B ??Str_Cmp_2
573 }
574 if (p2_str == (CPU_CHAR *)0) {
\ ??Str_Cmp_0:
\ 00000030 000051E3 CMP R1,#+0
\ 00000034 0300001A BNE ??Str_Cmp_3
575 cmp_val = (CPU_INT16S)(*p1_str);
\ 00000038 0000D0E5 LDRB R0,[R0, #+0]
576 return (cmp_val); /* If p2_str NULL, rtn pos p1_str val (see Note #2c). */
\ 0000003C 0008A0E1 MOV R0,R0, LSL #+16
\ 00000040 4008B0E1 MOVS R0,R0, ASR #+16
\ 00000044 2C0000EA B ??Str_Cmp_2
577 }
578
579
580 p1_str_next = p1_str;
\ ??Str_Cmp_3:
\ 00000048 0020B0E1 MOVS R2,R0
581 p2_str_next = p2_str;
\ 0000004C 0130B0E1 MOVS R3,R1
582 p1_str_next++;
\ 00000050 012092E2 ADDS R2,R2,#+1
583 p2_str_next++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -