This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

string definition

I have following code but find that x and y are the same value on the debugger. viewing ARM assembly review that the memcpy use same string address.

#define A "\xA0\x00\x01"
#define B "\xA0\x00\x02"
memcpy(x, A, sizeof(A)-1);
memcpy(y, B, sizeof(B)-1);

If I change
#define A "\xA0\x01\x01"
#define B "\xA0\x02\x02"
it will be OK.

Tam

Parents

  • The suggestion is that the Debugger is assuming that your data is supposed to be a null-terminated 'C' string, and so is terminating its display of the string at the first null.
    You need to inspect the memory directly to be sure of what's going on.


    I am sure that it is a compiler problem because I have checked the asm listing that the compiler only generate one constant string.

    Besides, the asm listing shows both memcmp() use pointer pointing to the same location in its second parameter.

     if( memcmp( in_buffer, A, sizeof(A))==0)
     {
     }
     else if( memcmp( in_buffer, B, sizeof(B))==0)
     {
     }
    

Reply

  • The suggestion is that the Debugger is assuming that your data is supposed to be a null-terminated 'C' string, and so is terminating its display of the string at the first null.
    You need to inspect the memory directly to be sure of what's going on.


    I am sure that it is a compiler problem because I have checked the asm listing that the compiler only generate one constant string.

    Besides, the asm listing shows both memcmp() use pointer pointing to the same location in its second parameter.

     if( memcmp( in_buffer, A, sizeof(A))==0)
     {
     }
     else if( memcmp( in_buffer, B, sizeof(B))==0)
     {
     }
    

Children