AnsweredAssumed Answered

Relocatable label expressions not usable in standalone assembler of powerpc-eabivle-gcc 4.9.4 when configured for automatic Book E to VLE instruction translation

Question asked by qwertyu on Oct 9, 2019
Latest reply on Oct 16, 2019 by qwertyu

I am trying to reuse multiple assembler source files that have been written originally for the CodeWarrior toolchain. By passing the command line options "-vle" and "-ppc_asm_to_vle" it is possible to let the CodeWarrior toolchain automatically convert code written in Book E to VLE mode. Additionally, the same assembler source can be used unmodified to translate the assembly in Book E mode directly by not specifying the above command line options. This behaviour makes it possible to reuse the assembler source files in multiple projects even when they have different requirements regarding Book E or VLE mode usage.


I am looking for a way to achieve the same flexibility of translation either for Book E or VLE mode with the GCC toolchain provided in S32 Design Studio. The command line options "-mvle" and "-Wa,-ppc_asm_to_vle" seem to be the equivalent for the features provided by CodeWarrior. However, the automatic translation from Book E to VLE seems to just not work on some instructions (even for some that have been specified in the latest release notes document of S32 Design Studio).


The non-working translation is especially problematic for all instructions that might be used together with something called "relocatable label expressions" (naming according to the CodeWarrior documentation) because I need them very often. Typically such instructions end on "@ha", "@h" or "@l" which allows to get either the upper or lower 16-bits of an address/label or a value that has been specified before. But this does not work with the standalone assembler of the GCC toolchain even when "-mvle" and "-Wa,-ppc_asm_to_vle" are given.


Here is an example code that is never working:


        lis         r10, object@ha
        addi      r10, r10, object@l
        lis         r10, value@h
        ori        r10, r10, value@l
        lis         r4, object@ha
        lwz       r5, object@l (r4)
        lis         r4, object@ha
        stw       r5, object@l (r4)


Typical errors that I receive for the above code are:

"Error: syntax error; found `@', expected `,'"

"Error: junk at end of line: `@ha'"

"Error: junk at end of line: `@h'"

"Error: junk at end of line: `@l'"


It is possible to fix this by writing everything of the above code sample in VLE mode only.

Here is an example code that is always working (because it has been manually written in VLE mode):


        e_lis         r10, object@ha
        e_add16i  r10, r10, object@l
        e_lis         r10, value@h
        e_or2i      r10, value@l
        e_lis         r4, object@ha
        e_lwz       r5, object@l (r4)
        e_lis         r4, object@ha
        e_stw       r5, object@l (r4)


However, this defeats the whole purpose of the automatic conversion from Book E to VLE instructions because the assembler code is not reusable for Book E and VLE mode projects anymore.


I am using the latest release of the GCC toolchain according to the version output:

powerpc-eabivle-gcc.exe (BLD = 1607) 4.9.4 20160726 ( rev=gceb1328 s=F494 -i /opt/freescale ELe200 -V release_gceb1328_build_Fed_ELe200_ML3)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO


Is there any possibility in the current GCC toolchain version to make the relocatable label expressions usable together with automatic Book E to VLE mode translation? Or is this something that is not supported right now? Thanks in advance.