"C--"
Robert Lipe
robertlipe@usa.net
Fri Dec 31 23:54:00 GMT 1999
Rick Hohensee wrote:
> How portable are GNU "as" assembly directives?
Depends on how you define "portable", I'm sure. Are you willing to
constrain your language to run only on those targets that support this
exact assembler syntax?
For example, UnixWare (an IA32/ELF target) can sensibly be used with
either GNU as or the native AS. Your code will work only for those
users in the former category. OpenServer (an IA32/ELF/COFF target)
cannot be realistically used with GNU as ever. Your code fails on
both the ELF and COFF assemblers and is therefore inaccessable to that
audience.
If portable to you means code that runs on both RedHat AND Caldera on
IA32, go with what you have. But if portable means a diverse collection
of architectures and development tools, you should probably find another
approach. Perhaps you have a tool that reads tables and writes a C
program containing structs that are then compiled. Perhaps everything
you need are available as GNU C extensions.
> This is my m4 macro for the header of a fundamental word...
>
> asm ("
> `ALTLABEL'
> .byte `len($2)'
> .byte 0
> .byte 0x80
> .byte 0
> .ascii \"`$2'\"
> .align 4, 0
> .int `ALTREF'
> .equ `$1'CFA, .
> ");
> `$1':
> )
>
> The macros for address-threads of derived words use the same directives.
>
> My main question:
> How portable is that?
> I only have x86 machines.
For example, the SVR[45] assemblers will complain about the maximum fill
size on your .align being bogus and they understand neither .int nor
.equ. The COFF assemblers for IA32 spell ".ascii" as ".string". ".int"
is spelled ".long". There is no fill size to .align. ".equ $blah, ." is
spelled "blah:". This is just at a glance. :-)
All of this may or may not matter to you, but it's the first step on a
slippery slope.
OTOH, I've seen code advertised as portable becuase it ran under two
different versions of Windows on IA32, so perhaps my standards are
skewed from the industry...
RJL
More information about the Gcc
mailing list