This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS570LS3137: Clarification on memcpy_t2.asm

Part Number: TMS570LS3137

Tool/software: TI C/C++ Compiler

Hi Ti Experts,

In the below code snippet of memcpy_t2.asm provided by Ti compiler, It is pushing r4 to r6, but when it is loaded it is loading from r3 to r6.

Can you please help me in calculating how much stack is used here . I assume it should be how 16bytes.

_ovr16: PUSH {r4 - r6} ; COPYING 16 BYTES OR MORE.
SUBS r2, #16 ;
_lp16: LDMIA r1!, {r3 - r6} ;
STMIA r0!, {r3 - r6} ;
SUBS r2, #16 ;
BCS _lp16 ;
POP {r4 - r6} ; RESTORE THE SAVED REGISTERS AND
ADDS r2, #16 ; CONTINUE THE COPY IF THE REMAINDER
BEQ _ret_ ; IS NONZERO.

Regards,

Somesh

  • Someswararao malla said:
    please help me in calculating how much stack is used here

    12 bytes.

    While the register R3 is used in the 16-byte copy, it is not preserved with the PUSH/POP instructions.  That is because of the calling convention used by the ARM compiler.  According to that convention, the registers R4-R6 are preserved by the current function (memcpy) and the register R3 is preserved by the caller to memcpy.  The usual way this is implemented is that the caller to memcpy does not preserve R3, but presumes R3 is overwritten by memcpy.

    Thanks and regards,

    -George