Searching \ for '[PIC]: Local labels (not in MACRO)?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Local labels (not in MACRO)?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Local labels (not in MACRO)?'
2008\07\12@091629 by Electron

flavicon
face

Hi,
I've a strong background in assembly but not on the dsPIC via MPLAB. What I
would like to know is how to make/use local labels. Example:


Routine1:
       RCALL   Hello1
.loop:  RCALL   BlaBla1
       BTSS    PORTF,#6
       BRA     .loop
       RETURN

Routine2:
       RCALL   Hello2
.loop:  RCALL   BlaBla2
       BTSC    PORTG,#6
       BRA     .loop
       RETURN

the assembler gives me an error at the definition of the 2nd ".loop" label,
while each .loop should be local to its own main label (Routine1 and Routine2)!

How do I define local labels then? In most assemblers one uses ".", but in MPLAB?

Thank you very much, after one long hour Googling didn't help, or am I dumb.

With kind regards,
Mario

2008\07\12@093821 by Jan-Erik Soderholm

face picon face
Electron wrote:
{Quote hidden}

I'm not sure about dsPIC-assembler, but for PIC16/PIC18, I think
that you have to have each routine in separate "modules". That
is, in separate .ASM files. Then all symbols become local to it's
own module and you have to use GLOBAL to actualy make them visible
in other modules (if you want/need that).

In your example, if Routine1 and Routine2 are in the same
ASM file, the assembler will give you an error.

Note that this *might* work different in dsPIC-assembler...

In a *macro* definiton, you can use LOCAL to declare local
symbols, but this wasn't any macro, right ?

Jan-Erik.

2008\07\12@095735 by olin piclist

face picon face
Electron wrote:
{Quote hidden}

No, it shouldn't.  There is absolutely nothing in the ASM30 documentation
that would even remotely suggest these two symbols would have any special
scope.  You might was well wave a dead fish over your code and wish really
hard.  That works about as well as guessing syntax without reading the
manual.

> How do I define local labels then? In most assemblers one uses ".",
> but in MPLAB?

Use the digits 0-9, then refer to them with a B and F following them.  See
the manual for details.

> after one long hour Googling didn't help

Not surprising.  The obvious place to look up ASM30 syntax is the ASM30
manual.  It took me well under a minute to find Section 5.5 "Local Symbols".


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2008\07\12@132014 by John Coppens

flavicon
face
On Sat, 12 Jul 2008 15:14:50 +0100
Electron <spam_OUTelectron2k4TakeThisOuTspaminfinito.it> wrote:
>
> How do I define local labels then? In most assemblers one uses ".", but
> in MPLAB?
>

If you insist on having local labels, there is a trick to do it:

0000 3012      00002 route1  movlw   12
 00000001     00003 rlocal  set     $
0001 3E01      00004         addlw   1
0002 2801      00005         goto    rlocal
0003 0008      00006         return
              00007
0004 3023      00008 route2  movlw   23
 00000005     00009 rlocal  set     $
0005 3E02      00010         addlw   2
0006 2805      00011         goto    rlocal
0007 0008      00012         return

Note that this only works with backward references (the goto must point
back)

John

2008\07\12@154630 by olin piclist

face picon face
John Coppens wrote:
> If you insist on having local labels, there is a trick to do it:
>
> 0000 3012      00002 route1  movlw   12
>   00000001     00003 rlocal  set     $
> 0001 3E01      00004         addlw   1
> 0002 2801      00005         goto    rlocal

Seems rather awkward.  Why not use the feature built into the assembler just
for this purpose.  That works both forwards and backwards.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...