📄 lib_mem.lst
字号:
\ 00000074 03D0 BEQ.N ??Mem_Set_10
310 *pmem_08++ = data_val;
\ 00000076 3170 STRB R1,[R6, #+0]
\ 00000078 761C ADDS R6,R6,#+1
311 size_rem -= sizeof(CPU_INT08U);
\ 0000007A 5B1E SUBS R3,R3,#+1
\ 0000007C F9E7 B.N ??Mem_Set_9
312 }
313 }
\ ??Mem_Set_10:
\ ??Mem_Set_0:
\ 0000007E BDE8F081 POP {R4-R8,PC} ;; return
314
315
316 /*$PAGE*/
317 /*
318 *********************************************************************************************************
319 * Mem_Copy()
320 *
321 * Description : Copy data octets from one memory buffer to another memory buffer.
322 *
323 * Argument(s) : pdest Pointer to destination memory buffer.
324 *
325 * psrc Pointer to source memory buffer.
326 *
327 * size Number of data buffer octets to copy (see Note #1).
328 *
329 * Return(s) : none.
330 *
331 * Caller(s) : Application.
332 *
333 * Note(s) : (1) Null copies allowed (i.e. zero-length copies).
334 *
335 * (2) Memory buffers NOT checked for overlapping.
336 *
337 * (3) For best CPU performance, optimized to copy data buffer using 'CPU_ALIGN'-sized data
338 * words.
339 *
340 * (a) Since many word-aligned processors REQUIRE that multi-octet words be accessed on
341 * word-aligned addresses, 'CPU_ALIGN'-sized words MUST be accessed on 'CPU_ALIGN'd
342 * addresses.
343 *
344 * (4) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
345 * address boundary.
346 *
347 * Modulo arithmetic in ANSI-C REQUIREs operations performed on integer values. Thus,
348 * address values MUST be cast to an appropriately-sized integer value PRIOR to any
349 * mem_align_modulo arithmetic operation.
350 *********************************************************************************************************
351 */
352 /*$PAGE*/
353 #if (LIB_MEM_CFG_OPTIMIZE_ASM_EN != DEF_ENABLED)
354 void Mem_Copy ( void *pdest,
355 const void *psrc,
356 CPU_SIZE_T size)
357 {
358 CPU_SIZE_T size_rem;
359 CPU_ALIGN *pmem_align_dest;
360 const CPU_ALIGN *pmem_align_src;
361 CPU_INT08U *pmem_08_dest;
362 const CPU_INT08U *pmem_08_src;
363 CPU_INT08U i;
364 CPU_INT08U mem_align_modulo_dest;
365 CPU_INT08U mem_align_modulo_src;
366 CPU_BOOLEAN mem_aligned;
367
368
369 if (size < 1) { /* See Note #1. */
370 return;
371 }
372 if (pdest == (void *)0) {
373 return;
374 }
375 if (psrc == (void *)0) {
376 return;
377 }
378
379
380 size_rem = size;
381
382 pmem_08_dest = ( CPU_INT08U *)pdest;
383 pmem_08_src = (const CPU_INT08U *)psrc;
384 /* See Note #4. */
385 mem_align_modulo_dest = (CPU_INT08U)((CPU_ADDR)pmem_08_dest % sizeof(CPU_ALIGN));
386 mem_align_modulo_src = (CPU_INT08U)((CPU_ADDR)pmem_08_src % sizeof(CPU_ALIGN));
387
388 mem_aligned = (mem_align_modulo_dest == mem_align_modulo_src) ? DEF_YES : DEF_NO;
389
390 if (mem_aligned == DEF_YES) { /* If mem bufs' alignment offset equal, ... */
391 /* ... optimize copy for mem buf alignment. */
392 if (mem_align_modulo_dest != 0u) { /* If leading octets avail, ... */
393 i = mem_align_modulo_dest;
394 while ((size_rem > 0) && /* ... start mem buf copy with leading octets ... */
395 (i < sizeof(CPU_ALIGN ))) { /* ... until next CPU_ALIGN word boundary. */
396 *pmem_08_dest++ = *pmem_08_src++;
397 size_rem -= sizeof(CPU_INT08U);
398 i++;
399 }
400 }
401
402 pmem_align_dest = ( CPU_ALIGN *)pmem_08_dest; /* See Note #3a. */
403 pmem_align_src = (const CPU_ALIGN *)pmem_08_src;
404 while (size_rem >= sizeof(CPU_ALIGN)) { /* While mem bufs aligned on CPU_ALIGN word boundaries, */
405 *pmem_align_dest++ = *pmem_align_src++; /* ... copy psrc to pdest with CPU_ALIGN-sized words. */
406 size_rem -= sizeof(CPU_ALIGN);
407 }
408
409 pmem_08_dest = ( CPU_INT08U *)pmem_align_dest;
410 pmem_08_src = (const CPU_INT08U *)pmem_align_src;
411 }
412
413 while (size_rem > 0) { /* For unaligned mem bufs or trailing octets, ... */
414 *pmem_08_dest++ = *pmem_08_src++; /* ... copy psrc to pdest by octets. */
415 size_rem -= sizeof(CPU_INT08U);
416 }
417 }
418 #endif
419
420
421 /*$PAGE*/
422 /*
423 *********************************************************************************************************
424 * Mem_Cmp()
425 *
426 * Description : Verify that ALL data octets in two memory buffers are identical in sequence.
427 *
428 * Argument(s) : p1_mem Pointer to first memory buffer.
429 *
430 * p2_mem Pointer to second memory buffer.
431 *
432 * size Number of data buffer octets to compare (see Note #1).
433 *
434 * Return(s) : DEF_YES, if 'size' number of data octets are identical in both memory buffers.
435 *
436 * DEF_NO, otherwise.
437 *
438 * Caller(s) : Application.
439 *
440 * Note(s) : (1) Null compares allowed (i.e. zero-length compares); 'DEF_YES' returned to indicate
441 * identical null compare.
442 *
443 * (2) Many memory buffer comparisons vary ONLY in the least significant octets -- e.g.
444 * network address buffers. Consequently, memory buffer comparison is more efficient
445 * if the comparison starts from the end of the memory buffers which will abort sooner
446 * on dissimilar memory buffers that vary only in the least significant octets.
447 *
448 * (3) For best CPU performance, optimized to compare data buffers using 'CPU_ALIGN'-sized
449 * data words.
450 *
451 * (a) Since many word-aligned processors REQUIRE that multi-octet words be accessed on
452 * word-aligned addresses, 'CPU_ALIGN'-sized words MUST be accessed on 'CPU_ALIGN'd
453 * addresses.
454 *
455 * (4) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
456 * address boundary.
457 *
458 * Modulo arithmetic in ANSI-C REQUIREs operations performed on integer values. Thus,
459 * address values MUST be cast to an appropriately-sized integer value PRIOR to any
460 * mem_align_modulo arithmetic operation.
461 ********************************************************************************************************
462 */
463 /*$PAGE*/
\ In section .text, align 2, keep-with-next
464 CPU_BOOLEAN Mem_Cmp (const void *p1_mem,
465 const void *p2_mem,
466 CPU_SIZE_T size)
467 {
\ Mem_Cmp:
\ 00000000 2DE9F84F PUSH {R3-R11,LR}
\ 00000004 0300 MOVS R3,R0
468 CPU_SIZE_T size_rem;
469 CPU_ALIGN *p1_mem_align;
470 CPU_ALIGN *p2_mem_align;
471 const CPU_INT08U *p1_mem_08;
472 const CPU_INT08U *p2_mem_08;
473 CPU_INT08U i;
474 CPU_INT08U mem_align_modulo_1;
475 CPU_INT08U mem_align_modulo_2;
476 CPU_BOOLEAN mem_aligned;
477 CPU_BOOLEAN mem_cmp;
478
479
480 if (size < 1) { /* See Note #1. */
\ 00000006 002A CMP R2,#+0
\ 00000008 01D1 BNE.N ??Mem_Cmp_0
481 return (DEF_YES);
\ 0000000A 0120 MOVS R0,#+1
\ 0000000C 7CE0 B.N ??Mem_Cmp_1
482 }
483 if (p1_mem == (void *)0) {
\ ??Mem_Cmp_0:
\ 0000000E 002B CMP R3,#+0
\ 00000010 01D1 BNE.N ??Mem_Cmp_2
484 return (DEF_NO);
\ 00000012 0020 MOVS R0,#+0
\ 00000014 78E0 B.N ??Mem_Cmp_1
485 }
486 if (p2_mem == (void *)0) {
\ ??Mem_Cmp_2:
\ 00000016 0029 CMP R1,#+0
\ 00000018 01D1 BNE.N ??Mem_Cmp_3
487 return (DEF_NO);
\ 0000001A 0020 MOVS R0,#+0
\ 0000001C 74E0 B.N ??Mem_Cmp_1
488 }
489
490
491 mem_cmp = DEF_YES; /* Assume mem bufs are identical until cmp fails. */
\ ??Mem_Cmp_3:
\ 0000001E 0120 MOVS R0,#+1
\ 00000020 8346 MOV R11,R0
492 size_rem = size;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -