8 years, 6 months ago.  This question has been closed. Reason: Unclear question

Serial::puts changes it's parameter address

Hi

Let's add a class

SerialwBuffer::SerialwBuffer (size_t bufferSize, PinName tx, PinName rx) : Serial (tx,  rx)

With following function :

int SerialwBuffer::PutString(const char *s)
{
	Serial::puts(s);
}

When I call it PutString(Buffer);

's' is no more equal to Buffer.....

Looking at the assembler code :

0x0800144A B570      PUSH     {r4-r6,lr}
0x0800144C 4604      MOV      r4,r0
0x0800144E 460D      MOV      r5,r1
    66:         Serial::puts(s); 
0x08001450 4629      MOV      r1,r5
0x08001452 4620      MOV      r0,r4
0x08001454 3054      ADDS     r0,r0,#0x54
0x08001456 F002FCB1  BL.W     _ZN4mbed6Stream4putsEPKc (0x08003DBC)

Why does the R0 register is increased

ADDS     r0,r0,#0x54

Before that instruction it was correcly pointing to Buffer....

Do you have any idea ?