Quantcast

Is memmove() working correctly?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is memmove() working correctly?

Jongsoo Jeong
Hi all,

I'm testing MSP430 GCC 3_04_05_00 that was released recently, and I found
memmove() function is not working correctly.

Here is my sample code:

    uint8_t i;
    uint8_t buf[100];

    for (i = 0; i < 100; i++)
      buf[i] = i;

    printf("buf:");
    for (i = 0; i < 100; i++)
      printf("%02X ", buf[i]);
    printf("\n");

    memmove(&buf[10], &buf[0], 90);

    printf("after memmove buf:");
    for (i = 0; i < 100; i++)
      printf("%02X ", buf[i]);
    printf("\n");

    while(1);

When msp430-elf-gcc is used,
buf:00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17
18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49
4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62
63
after memmove buf:00 01 02 03 04 05 06 07 08 09 FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF

And when IAR EW430 is used,
buf:00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17
18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49
4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62
63
after memmove buf:00 01 02 03 04 05 06 07 08 09 00 01 02 03 04 05 06 07 08
09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21
22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A
3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53
54 55 56 57 58 59

I don't know why 0xFFs are padded from the destination pointer of memmove().
Please, help me. :)

Thank you.
Jongsoo

------------------------------------------------------------------------------

_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Loading...