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.

C6746 / 6740 memcpy alignment

Hi!

I noticed that memcpy isn't able to copy from addresses that are not 32bit aligned.

e.g. copying from 0xCxxxxxxA would fail:

0xC0000008    0x00000000
0xC000000C    0x00007400

uint32 target = 0;

memcpy (&target, (uint32*)(0xC000000D),sizeof(uint32));

what i would have expected:

target = 0x00000074;

what the result is:

target = 0x00007400;

Note: the same code runs fine on C6713, i don't use DSP BIOS.

Since memcpy is written in ASM in memcpy64.asm, i can hardly understand why this wouldn't work.

Kind Regards

  • The Problem narrows down to LDW / LDNW:

    The compiler optimizes

    mempy (&target, (uint32*)(0x<any Address>), sizeof(uint32))

    to a LDW instruction, which obviously fails for non 32bit aligned Addresses, the solution is to cast the source address pointer to uint8:

    memcopy (&target, (uint8*)(0x<any Address>), sizeof(uint32)) optimizes to a LDNW instruction which can handle non-aligned addresses.