avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Using __tmp_reg__ etc in assembly file


From: Colin Wall
Subject: Re: [avr-gcc-list] Using __tmp_reg__ etc in assembly file
Date: Fri, 23 Jan 2009 08:32:32 +1300

> ----- Message from Georg-Johann Lay <address@hidden> on Thu, 22 Jan 
> 2009 00:06:15 +0100 -----
> 
> To:
> 
> Colin Wall <address@hidden>
> 
> cc:
> 
> address@hidden
> 
> Subject:
> 
> Re: [avr-gcc-list] Using __tmp_reg__ etc in assembly file
> 
> Colin Wall schrieb:
> > Hi List,
> > 
> > I must be missing something.
> > 
> > I can use symbols like __SREG__,  __tmp_reg__ and __zero_reg__ in 
in-line 
> > asm (e.g. "push __tmp_reg__") but if I do the same in a pure assembly 
> > file, the compiler complains with "constant value required". How does 
one 
> > access these symbols in the assembly file and keep gas happy?
> 
> gcc gererates a header in easch assembly output that looks like
> 
>    .file   "fifo.c"
>    .arch atmega168
> __SREG__ = 0x3f
> __SP_H__ = 0x3e
> __SP_L__ = 0x3d
> __tmp_reg__ = 0
> __zero_reg__ = 1
>    .global __do_copy_data
>    .global __do_clear_bss
>   ;  GNU C version 3.4.6 (avr)
> 
> Newer versions ov gcc even define more. So the __tmp_reg__ is not a 
> symbol it's just a definiton. So
> 
> push __tmp_reg__
> 
> is equivalent to
> 
> push 0
> 
> and yes, there is no (redundant) register prefix "R" in this case.
> 
> 
> > I know I can always do my own #define, but it feels wrong to re-define 

> > something that already exists...
> 
> No, it does not exist in any header. It exists in gcc ;-)
> 
> Georg-Johann
> 

So, from what I can see, the compiler makes these defines available to
C source, but not to asm (.S) source, and I need to repeat them myself
in the asm file to use them there.

Thanks for your help Georg-Johann.

Colin.
> 
> 
> 
> 
> ----- Message from Ruud Vlaming <address@hidden> on Thu, 22 
> Jan 2009 00:28:57 +0100 -----
> 
> To:
> 
> address@hidden
> 
> Subject:
> 
> Re: [avr-gcc-list] Using __tmp_reg__ etc in assembly file
> 
> On Wednesday 21 January 2009 23:09, Colin Wall wrote:
> 
> > I know I can always do my own #define, but it feels wrong to re-define 

> > something that already exists...
> 
> You can make use of the constructions (examples):
>     out  (_SFR_IO_ADDR(SREG)), r25
>     out  (_SFR_IO_ADDR(SPL)), r26
>     out  (_SFR_IO_ADDR(SPH)), r27
> etc, if i remember correctly.
> 
> Ruud.
> 
> 

These work in the asm file because SREG etc are defined when io.h is 
included. I can't see a way to use __tmp_reg__ et al without re-defining
them myself.

Colin.

###########################################################################
This e-mail is confidential and may contain information subject to legal 
privilege.  If you are not the intended recipient please advise us of our
error by return e-mail then delete this e-mail and any attached files.  
You may not copy, disclose or use the contents in any way.  

The views expressed in this e-mail may not be those of Gallagher Group 
Ltd or subsidiary companies thereof.
###########################################################################




reply via email to

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