EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Assembling with GNU and ADS

Started by HG June 30, 2004
Hi,

I want to be able to build my project with both the ARM ADS and GNU
tools. This is relatively easy for the C files, however, it is proving
very difficult (actually impossible) to do this for assembly files.
Anyone know of a clever trick (pre-processor?) that allows me to
maintain a single assembly source file and assemble it with either GNU
GAS or ADS ?

TIA, HG
On 30 Jun 2004 04:32:52 -0700, armarm123@hotmail.com (HG) wrote:

>Hi, > >I want to be able to build my project with both the ARM ADS and GNU >tools. This is relatively easy for the C files, however, it is proving >very difficult (actually impossible) to do this for assembly files. >Anyone know of a clever trick (pre-processor?) that allows me to >maintain a single assembly source file and assemble it with either GNU >GAS or ADS ?
For our kernel I use a combination of C-Preprocessor and perl. I.e. I have one source that I pre-process to get ADS,IAR and GNU assembly. This works fine (I do this for various CPUs). -- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@epost.de instead !
bastian42@yahoo.com (42Bastian Schick) wrote in message news:<40e2bf41.1563945905@news.individual.de>...
> On 30 Jun 2004 04:32:52 -0700, armarm123@hotmail.com (HG) wrote: > > >Hi, > > > >I want to be able to build my project with both the ARM ADS and GNU > >tools. This is relatively easy for the C files, however, it is proving > >very difficult (actually impossible) to do this for assembly files. > >Anyone know of a clever trick (pre-processor?) that allows me to > >maintain a single assembly source file and assemble it with either GNU > >GAS or ADS ? > > For our kernel I use a combination of C-Preprocessor and perl. > I.e. I have one source that I pre-process to get ADS,IAR and GNU > assembly. > > This works fine (I do this for various CPUs).
Any chance of an example of what you mean ? TIA, HG
armarm123@hotmail.com (HG) wrote in
news:47822c89.0407010712.65d5c77@posting.google.com: 

> bastian42@yahoo.com (42Bastian Schick) wrote in message > news:<40e2bf41.1563945905@news.individual.de>... >> On 30 Jun 2004 04:32:52 -0700, armarm123@hotmail.com (HG) wrote: >> >> >Hi, >> > >> >I want to be able to build my project with both the ARM ADS and GNU >> >tools. This is relatively easy for the C files, however, it is >> >proving very difficult (actually impossible) to do this for assembly >> >files. Anyone know of a clever trick (pre-processor?) that allows me >> >to maintain a single assembly source file and assemble it with >> >either GNU GAS or ADS ? >> >> For our kernel I use a combination of C-Preprocessor and perl. >> I.e. I have one source that I pre-process to get ADS,IAR and GNU >> assembly. >> >> This works fine (I do this for various CPUs). > Any chance of an example of what you mean ? > > TIA, HG >
This is a total hack and probably most offensive to perl experts, but worked for me where I had to take a GAS file and assemble it using ADS: while (<>) { s/@/ ;@/; s/^(\w+):/$1/; s/\.section.*/ AREA |x|,code,readonly/; s/\.equ ([^\s]+),\s+([^\s]+)/$1 equ $2/; s/\.global\s+([^\s]+)/ EXPORT $1/; print ; } print "\n END\n"; Obviously you'll have to extend it to cover GAS keywords that weren't in the code I was assembling. Just pipe the GAS file through the perl to get ADS compatible code... Peter.
On 1 Jul 2004 08:12:59 -0700, armarm123@hotmail.com (HG) wrote:

>bastian42@yahoo.com (42Bastian Schick) wrote in message news:<40e2bf41.1563945905@news.individual.de>... >> On 30 Jun 2004 04:32:52 -0700, armarm123@hotmail.com (HG) wrote: >> >> >Hi, >> > >> >I want to be able to build my project with both the ARM ADS and GNU >> >tools. This is relatively easy for the C files, however, it is proving >> >very difficult (actually impossible) to do this for assembly files. >> >Anyone know of a clever trick (pre-processor?) that allows me to >> >maintain a single assembly source file and assemble it with either GNU >> >GAS or ADS ? >> >> For our kernel I use a combination of C-Preprocessor and perl. >> I.e. I have one source that I pre-process to get ADS,IAR and GNU >> assembly. >> >> This works fine (I do this for various CPUs). >Any chance of an example of what you mean ?
In my source I have: #define ARM 1 #define GNU 2 #if COMPILER == ARM MACRO SC_FUNC32 $name CODE32 EXPORT $name $name MEND #define LONG DCD #endif #if COMPILER == GNU .macro SC_FUNC32 name .code 32 .type \name,function \name: .endm #define LONG .long #endif Inside the source I only use macros for things that are specific to an assembler. Two produce the actual files I'll pre-process the original source gcc -E -DCOMPILER=1 source.S >source_ads.s or gcc -E -DCOMPILER=2 source.S >source_gnu.S Net effect: Comments are stripped if written as C comments. After the above state you might use a simple C program or perl script to remove empty lines. -- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@epost.de instead !

The 2024 Embedded Online Conference