On Thu, Mar 06, 2003 at 12:33:16PM -0500, Mark Stokes wrote:
> I've been pulling my hair out about an auto increment problem. I
> finally realized the following statement wasn't acting as I expected it
> to:
>
> Unsigned char ReadByte( unsigned int *address )
> {
> unsigned char data;
>
> // Setup read from memory chip (SPI)
>
> E2DISABLE; // End Read operation
> // Auto increment address the proper number of bytes
> *address++;
> return data;
> }
>
> I expected the contents of memory that address pointed to be incremented
> one. But when I check the .lst file, I get this:
> ...
> E2DISABLE; // End Read operation
> 1b88: d2 d3 19 00 bis.b #1, &0x0019
> *address++;
> return data;
> 1b8c: 4f 4e mov.b r14, r15 ;
> ...
>
> Nothing came out at all!!! And no warnings. When I changed the line to
> read:
> // Auto increment address the proper number of bytes
> *address += 1;
> I got the desired result:
> *address += 1;
> 1b8e: 9e 53 00 00 inc 0(r14) ;
> Is this a bug?
I don't think it is a bug:
In the first case: * address ++; will do the folowing:
It will take data, that address was pointing to, and throw it out,
then it will increment address.
The second: * address += 1; will take data pointed by address,
increment and restore the result in place that address is pointing to.
> -Mark Stokes
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
> for complex code. Debugging C/C++ programs can leave you feeling lost and
> disoriented. TotalView can help you find your way. Available on major UNIX
> and Linux platforms. Try it free. www.etnus.com
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users