User: Password:
|
|
Subscribe / Log in / New account

Little-endian PowerPC

Little-endian PowerPC

Posted Oct 7, 2010 14:47 UTC (Thu) by jengelh (subscriber, #33263)
In reply to: Little-endian PowerPC by etienne
Parent article: Little-endian PowerPC

>Last time I looked gcc was not able to generate (did not know about) the bswap instruction.

Perhaps you need to update from that ancient gcc version ;-)

int main(int argc, char **argv) { printf("%d\n", htonl(argc)); return 0; } compiled with gcc-4.5 -O3 -static on x86_64 gives me a bswap in objdump. bswap has been there since 80486.

>some assembly instuctions to cast the value 3 in a 16 bits word to the value 3 in a byte,

Well, wouldn't that be just AND r0, 0xFF.


(Log in to post comments)

Little-endian PowerPC

Posted Oct 7, 2010 15:38 UTC (Thu) by etienne (guest, #25256) [Link]

> Perhaps you need to update from that ancient gcc version ;-)

Still no GCC-4.5 here and on ia32, if your example no more calls the function "htonl" (which for GCC-4.4.5 is a library function written manually in assembler - I just checked the whole calling sequence by objdump), that is a very welcome improvement!

> Well, wouldn't that be just AND r0, 0xFF.

Unfortunately a register do not have an address to pass to a function, so you need to allocate some temporary space on the stack and copy your register there...


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds