Diab PPC Assy. macro question

Nov 05, 2004 2 Replies

I'm trying to swap an 8 byte quantity via a Diab macro but I am unable to figure out how to get access to the second word of the unsigned long long. Here's what I have:



asm uint64 swap8Bytes(uint64 eightBytes) { % reg eightBytes; ! "r0", "r12"



mr r12,eightBytes /* LSW */ rlwinm r0,r12, 8, 8,31 rlwimi r0,r12,24,16,23 rlwimi r0,r12,24, 0, 8 mr r4,r0



mr r12,eightBytes /* MSW? How? */ rlwinm r0,r12, 8, 8,31 rlwimi r0,r12,24,16,23 rlwimi r0,r12,24, 0, 8 mr r3,r0 }



- Mark -> --

Have you considered writing this in C, then looking at the assembly output Diab creates for a hint?

--Gene

Gene S. Berkowitz wrote in news: snipped-for-privacy@news.comcast.giganews.com:

[snip]

Uh, yes and it is atrocious code. The compiler doesn't recognized the idiom of a 64-bit integer swap. Thus, we PowerPC developers tend to use this handy sequence of rlwiXX instruction for swapping bytes in a word. What I am trying to discern is the Diab assembler mnemonic that allows the human assembler writer to specify the MS word and LS word in a 64-bit integer. The Diab manuals do not specify how to do this.

Thanks.

- Mark -> --

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required