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 -> --

Diab PPC Assy. macro question
Started by ●November 5, 2004
Reply by ●November 6, 20042004-11-06
In article <Xns9598A478555FACopyrightMarkOdell@130.133.1.4>, odellmark@hotmail.com says...> 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 > }Have you considered writing this in C, then looking at the assembly output Diab creates for a hint? --Gene
Reply by ●November 8, 20042004-11-08
Gene S. Berkowitz <first.last@comcast.net> wrote in news:MPG.1bf61d6da1631fc4989755@news.comcast.giganews.com:>> 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:[snip]> Have you considered writing this in C, then looking at the assembly > output Diab creates for a hint?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 -> --
