1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Diab PPC Assy. macro question

Discussion in 'Embedded' started by Mark A. Odell, Nov 5, 2004.

  1. 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 A. Odell, Nov 5, 2004
    #1
    1. Advertisements

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

    --Gene
     
    Gene S. Berkowitz, Nov 6, 2004
    #2
    1. Advertisements

  3. 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 A. Odell, Nov 8, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.