📄 lib_str.lst
字号:
\ 00000050 013093E2 ADDS R3,R3,#+1
304 pstr_next++;
\ 00000054 01C09CE2 ADDS R12,R12,#+1
305 psrc++;
\ 00000058 011091E2 ADDS R1,R1,#+1
306 len_copy++;
\ 0000005C 014094E2 ADDS R4,R4,#+1
307 }
\ ??Str_Copy_N_4:
\ 00000060 00005CE3 CMP R12,#+0
\ 00000064 0600000A BEQ ??Str_Copy_N_6
\ 00000068 000051E3 CMP R1,#+0
\ 0000006C 0400000A BEQ ??Str_Copy_N_6
\ 00000070 0050D1E5 LDRB R5,[R1, #+0]
\ 00000074 000055E3 CMP R5,#+0
\ 00000078 0100000A BEQ ??Str_Copy_N_6
\ 0000007C 020054E1 CMP R4,R2
\ 00000080 F0FFFF3A BCC ??Str_Copy_N_5
308
309 *pstr = (CPU_CHAR)0; /* Append NULL char (see Note #2b2). */
\ ??Str_Copy_N_6:
\ 00000084 0010A0E3 MOV R1,#+0
\ 00000088 0010C3E5 STRB R1,[R3, #+0]
310
311
312 return (pdest);
\ ??Str_Copy_N_1:
\ 0000008C 3000BDE8 POP {R4,R5}
\ 00000090 0EF0A0E1 MOV PC,LR ;; return
313 }
314
315
316 /*$PAGE*/
317 /*
318 *********************************************************************************************************
319 * Str_Cat()
320 *
321 * Description : Append concatenation string to destination string.
322 *
323 * Argument(s) : pdest Pointer to destination string to append concatenation string (see Note #1).
324 *
325 * pstr_cat Pointer to concatenation string to append to destination string.
326 *
327 * Return(s) : Pointer to destination string, if NO errors (see Note #2).
328 *
329 * Pointer to NULL, otherwise.
330 *
331 * Caller(s) : various.
332 *
333 * Note(s) : (1) Destination string buffer size NOT validated; buffer overruns MUST be prevented by caller.
334 *
335 * (a) Destination buffer size MUST be large enough to accomodate the entire concatenated
336 * string size including the terminating NULL character.
337 *
338 * (2) String concatenation terminates when :
339 *
340 * (a) Destination/Concatenation string pointer(s) are passed NULL pointers.
341 * (1) No string concatenation performed; NULL pointer returned.
342 *
343 * (b) Destination string overlaps with NULL address.
344 * (1) No string concatenation performed; NULL pointer returned.
345 *
346 * (c) Destination/Concatenation string pointer(s) points to NULL.
347 * (1) String buffer(s) overlap with NULL address.
348 * (2) Concatenation string appended into destination string buffer up to but NOT
349 * beyond or including the NULL address; destination string buffer properly
350 * terminated with NULL character.
351 *
352 * (d) Concatenation string's terminating NULL character found.
353 * (1) Entire concatenation string appended to destination string.
354 *********************************************************************************************************
355 */
356
\ In segment CODE, align 4, keep-with-next
357 CPU_CHAR *Str_Cat (CPU_CHAR *pdest,
358 CPU_CHAR *pstr_cat)
359 {
360 CPU_CHAR *pstr;
361 CPU_CHAR *pstr_next;
362
363 /* Rtn NULL if str ptr(s) NULL (see Note #2a). */
364 if (pdest == (CPU_CHAR *)0) {
\ Str_Cat:
\ 00000000 000050E3 CMP R0,#+0
\ 00000004 0100001A BNE ??Str_Cat_0
365 return ((CPU_CHAR *)0);
\ 00000008 0000A0E3 MOV R0,#+0
\ 0000000C 200000EA B ??Str_Cat_1
366 }
367 if (pstr_cat == (CPU_CHAR *)0) {
\ ??Str_Cat_0:
\ 00000010 000051E3 CMP R1,#+0
\ 00000014 0100001A BNE ??Str_Cat_2
368 return ((CPU_CHAR *)0);
\ 00000018 0000A0E3 MOV R0,#+0
\ 0000001C 1C0000EA B ??Str_Cat_1
369 }
370
371
372 pstr = pdest;
\ ??Str_Cat_2:
\ 00000020 0020B0E1 MOVS R2,R0
\ 00000024 000000EA B ??Str_Cat_3
373 while (( pstr != (CPU_CHAR *)0) && /* Adv to end of cur dest str until NULL ptr ... */
374 (*pstr != (CPU_CHAR )0)) { /* ... or NULL char found.. */
375 pstr++;
\ ??Str_Cat_4:
\ 00000028 012092E2 ADDS R2,R2,#+1
376 }
\ ??Str_Cat_3:
\ 0000002C 000052E3 CMP R2,#+0
\ 00000030 0200000A BEQ ??Str_Cat_5
\ 00000034 0030D2E5 LDRB R3,[R2, #+0]
\ 00000038 000053E3 CMP R3,#+0
\ 0000003C F9FFFF1A BNE ??Str_Cat_4
377 if (pstr == (CPU_CHAR *)0) { /* If NULL str overrun, rtn NULL (see Note #2b). */
\ ??Str_Cat_5:
\ 00000040 000052E3 CMP R2,#+0
\ 00000044 0100001A BNE ??Str_Cat_6
378 return ((CPU_CHAR *)0);
\ 00000048 0000A0E3 MOV R0,#+0
\ 0000004C 100000EA B ??Str_Cat_1
379 }
380
381 pstr_next = pstr;
\ ??Str_Cat_6:
\ 00000050 0230B0E1 MOVS R3,R2
382 pstr_next++;
\ 00000054 013093E2 ADDS R3,R3,#+1
\ 00000058 040000EA B ??Str_Cat_7
383 while (( pstr_next != (CPU_CHAR *)0) && /* Cat str until NULL ptr(s) (see Note #2c) ... */
384 ( pstr_cat != (CPU_CHAR *)0) &&
385 (*pstr_cat != (CPU_CHAR )0)) { /* ... or NULL char found (see Note #2d). */
386 *pstr = *pstr_cat;
\ ??Str_Cat_8:
\ 0000005C 00C0D1E5 LDRB R12,[R1, #+0]
\ 00000060 00C0C2E5 STRB R12,[R2, #+0]
387 pstr++;
\ 00000064 012092E2 ADDS R2,R2,#+1
388 pstr_next++;
\ 00000068 013093E2 ADDS R3,R3,#+1
389 pstr_cat++;
\ 0000006C 011091E2 ADDS R1,R1,#+1
390 }
\ ??Str_Cat_7:
\ 00000070 000053E3 CMP R3,#+0
\ 00000074 0400000A BEQ ??Str_Cat_9
\ 00000078 000051E3 CMP R1,#+0
\ 0000007C 0200000A BEQ ??Str_Cat_9
\ 00000080 00C0D1E5 LDRB R12,[R1, #+0]
\ 00000084 00005CE3 CMP R12,#+0
\ 00000088 F3FFFF1A BNE ??Str_Cat_8
391
392 *pstr = (CPU_CHAR)0; /* Append NULL char (see Note #2c2). */
\ ??Str_Cat_9:
\ 0000008C 0010A0E3 MOV R1,#+0
\ 00000090 0010C2E5 STRB R1,[R2, #+0]
393
394
395 return (pdest);
\ ??Str_Cat_1:
\ 00000094 0EF0A0E1 MOV PC,LR ;; return
396 }
397
398
399 /*$PAGE*/
400 /*
401 *********************************************************************************************************
402 * Str_Cat_N()
403 *
404 * Description : Append concatenation string to destination string, up to a maximum number of characters.
405 *
406 * Argument(s) : pdest Pointer to destination string to append concatenation string (see Note #1).
407 *
408 * pstr_cat Pointer to concatenation string to append to destination string.
409 *
410 * len_max Maximum number of characters to concatenate (see Note #2e).
411 *
412 * Return(s) : Pointer to destination string, if NO errors (see Note #2).
413 *
414 * Pointer to NULL, otherwise.
415 *
416 * Caller(s) : various.
417 *
418 * Note(s) : (1) Destination string buffer size NOT validated; buffer overruns MUST be prevented by caller.
419 *
420 * (a) Destination buffer size MUST be large enough to accomodate the entire concatenated
421 * string size including the terminating NULL character.
422 *
423 * (2) String concatenation terminates when :
424 *
425 * (a) Destination/Concatenation string pointer(s) are passed NULL pointers.
426 * (1) No string concatenation performed; NULL pointer returned.
427 *
428 * (b) Destination string overlaps with NULL address.
429 * (1) No string concatenation performed; NULL pointer returned.
430 *
431 * (c) Destination/Concatenation string pointer(s) points to NULL.
432 * (1) String buffer(s) overlap with NULL address.
433 * (2) Concatenation string appended into destination string buffer up to but NOT
434 * beyond or including the NULL address; destination string buffer properly
435 * terminated with NULL character.
436 *
437 * (d) Concatenation string's terminating NULL character found.
438 * (1) Entire concatenation string appended to destination string.
439 *
440 * (e) 'len_max' number of characters concatenated.
441 * (1) 'len_max' number of characters does NOT include the terminating NULL character.
442 *
443 * See also Note #1a.
444 *********************************************************************************************************
445 */
446 /*$PAGE*/
\ In segment CODE, align 4, keep-with-next
447 CPU_CHAR *Str_Cat_N (CPU_CHAR *pdest,
448 CPU_CHAR *pstr_cat,
449 CPU_SIZE_T len_max)
450 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -