In a big endian system, the address 0x12345678 is represented by the bytes
78 56 34 12 on a little endian system, and by 12 34 56 78 on a big endian
system. In my experience, both print out, with %p, as 0x12345678. It's not
really a matter of 'byte swapping', per se, but rather interpreting the
bytes
in the correct order for the platform. Would the above address print
0x78563412
on a big endian system with sdcc, I would likely file a bug report.

Warner

On Thu, Nov 11, 2021 at 12:59 PM Bodo Wenzel <bodowen...@web.de> wrote:

> Pragmatically, if there is something to check endianness, make a working
> chance for all targets, or at least non-breaking for little-endian
> systems. I see not much value in finding by whom or why this
> little-endian-only solution was written, because for me it is a clear
> error.
>
> The implementation-defined part of the standard targets more prefix,
> number of digits, number base, or other specialties like
> "segment:offset", in my eyes. Swapping bytes does not belong here…
>
> -Bodo
>
> Am 10.11.21 um 23:38 schrieb Basil Hussain:
> > Hi all,
> >
> > Quick question: was the SDCC standard library printf() implementation
> > for the %p conversion specifier written only with little-endian
> > platforms (e.g. 8051) in mind?
> >
> > I ask because I encounter once again today an annoyance I've encountered
> > before when working on big-endian target platforms such as the STM8.
> > Whenever you use %p, the pointer value is formatted with the bytes in
> > the wrong order. For example, a pointer with value of 0x87A1 is output
> > as "0xa187". It's annoying to have to mentally transpose the bytes when
> > looking at debugging output.
> >
> > Regards,
> > Basil Hussain
> >
> >
> > _______________________________________________
> > Sdcc-user mailing list
> > Sdcc-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to