This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gas usage query


On 08.03.18 15:29, John Darrington wrote:
> I want to define an alias for an immediate value.  So I'm looking for something
> similar to the c pre-processor's #define  - but I can't find a suitable directive
> in the gas manual.
>
> .set, .equiv and friends don't do the job because they actually define symbols.
> .macro doesn't do the job either since it actually emits code.

I'm not entirely sure what harm it does for the "alias" to appear in the
symbol table, but the desire to handle it entirely in the preprocessor
can be accommodated.

> What I want is something like
> 
> 	.define foo #24
> 	
>          ;; Load the D6 register with 24
> 	ld d6, foo
> 
> 
> Is there a way to to this?

While I just use the gnu idiom:

   foo = 24

and let it populate the symbol table as above, you can use #define with
gas. Just make the source files xxx.S rather than xxx.s, and feed 'em
through cpp first. Here's a snippet from my current makefile, as it's a
while since I set it up:

%.o: %.s 
%  $(AS) -I$(INC_DIR) $(ASFLAGS) -o $(OBJDIR)/$@ $<

%.o: %.S 
%  $(CC) -c -I$(INC_DIR) -x assembler-with-cpp $(CFLAGS)
-Wa,-alms=$(OBJDIR)/$@.lst -o $(OBJDIR)/$@ $<

(The last two lines are one.)

That's more to use existing C headers like avr/io.h than for keeping
symbols out of the symbol table. (Anything to avoid the horror of "magic
numbers".)

Erik


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]