bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inline assembler register allocation for H8S/2357


From: Carlos Manhaeghe
Subject: inline assembler register allocation for H8S/2357
Date: Fri, 8 Dec 2000 13:01:06 +0100

Hello,

my program needs to convert 32-bit values from little-endian to big-endian.
This conversion is done by the following routine:

static __inline__ unsigned long DDT32P(unsigned long *pulData)
{       register unsigned long ulResult asm("er3");
        asm("mov.b\t@(3,%1),r3h"
        "\n\tmov.b\t@(2,%1),r3l"
        "\n\tmov.w\tr3,e3"
        "\n\tmov.b\t@(1,%1),r3h"
        "address@hidden,r3l"
                : "=&r" (ulResult)
                : "r" (pulData));
        return ulResult;
}

The converted value is put into er3, which should correspond to the ulResult
local variable. However, one of the expansions of this routine leads to the
following code:

; #APP
        mov.b   @(3,er3),r3h
        mov.b   @(2,er3),r3l
        mov.w   r3,e3
        mov.b   @(1,er3),r3h
        mov.b   @er3,r3l
; #NO_APP
        mov.l   er2,er3

Here, the compiler puts pulData into er3 and uses er2 for ulResult! This is
unexpected, as the inline assembler instruction explicitly states it uses
ulResult and ulResult should be in "er3".

I agree the code would be much cleaner if the inline assembler used %0 for
ulResult. However, %0 expands as text to "er2" and I can not derive the H8S
subregisters "e2", "r2", "r2h" and "r2l" from this text string.

The problem occurred with gcc version 2.9-gnupro-99r1p1 and command line
"h8300-hms-gcc -S -ms -O2 -g". I did not include any code yet, as it is a
rather large project and perhaps this is a known bug. In case you need more
information, don't hesitate to contact me.

Kind regards,

Carlos Manhaeghe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]