Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

assembler macros

assembler macros

2012-01-23 by Steven Hodge

Is there some restriction about using a macro parameter in a label?

The following code will not work.  It gives an "undefined symbol:
usart0_Init" error:

.MACRO _USART_INIT
usart@0_Init:
.... code using @0 parameter ............
.ENDMACRO
.....
call	usart0_Init
.....
_USART_INIT 0
.....

But by simply excluding the entry point label from the macro definition it
does work:

usart0_Init:
.MACRO _USART_INIT
.... code using @0 parameter ............
.ENDMACRO
.....
call	usart0_Init
.....
_USART_INIT 0
.....

It gives the same result in either AVR Studio 4 or 5.

Thanks, Steve

Re: [AVR-Chat] assembler macros

2012-01-23 by John Samperi

At 05:27 AM 24/01/2012, you wrote:
>usart0_Init" error:
>
>.MACRO _USART_INIT
>usart@0_Init:

It would be an error if you have the extra @ in the name of the routine.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] assembler macros

2012-01-23 by Steven Hodge

I don't understand.  In the code snippet that doesn't work, "@0" is inside
the macro definition.  Why then does it not get expanded to just "0" when
the macro gets expanded with "@0" set to "0", so there ends up being no "@"
in the name of the routine?   Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of John Samperi
Sent: Monday, January 23, 2012 11:53 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] assembler macros

 

  

At 05:27 AM 24/01/2012, you wrote:
>usart0_Init" error:
>
>.MACRO _USART_INIT
>usart@0_Init:

It would be an error if you have the extra @ in the name of the routine.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************





[Non-text portions of this message have been removed]

RE: [AVR-Chat] assembler macros

2012-01-23 by John Samperi

At 07:00 AM 24/01/2012, you wrote:
>I don't understand.

Neither do I :-) , you are calling the routine
usart@0_Init: and NOT usart0_Init: see the extra @?







Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] assembler macros

2012-01-23 by Steven Hodge

I want the routine to end up being named "usart0_Init" and that is what the
call instruction uses.   The name inside the macro definition has "@0" in it
so that I'm hoping the "@0" will get replaced with the value "0" when the
macro is invoked, to end up with just "usart0_Init" as the name.  Yes, it
does appear that the "@" does not get purged, ending up with "usart@0_Init"
as the name, but I don't understand why.  Why does the parameter
substitution not work?  Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of John Samperi
Sent: Monday, January 23, 2012 12:10 PM
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] assembler macros

 

  

At 07:00 AM 24/01/2012, you wrote:
>I don't understand.

Neither do I :-) , you are calling the routine
usart@0_Init: and NOT usart0_Init: see the extra @?

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************





[Non-text portions of this message have been removed]

RE: [AVR-Chat] assembler macros

2012-01-23 by John Samperi

At 07:21 AM 24/01/2012, you wrote:
>Why does the parameter substitution not work?  Steve

OK I now see what you are trying to do but have no idea how
to fix it, sorry. :-)


Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] assembler macros

2012-01-23 by Steven Hodge

Thanks for looking at it, John.  I think it must be some sort of assembler
bug.   Steve
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of John Samperi
Sent: Monday, January 23, 2012 12:34 PM
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] assembler macros

 

  

At 07:21 AM 24/01/2012, you wrote:
>Why does the parameter substitution not work? Steve

OK I now see what you are trying to do but have no idea how
to fix it, sorry. :-)

Regards

John Samperi






[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.