MPASM: Any "local" labels like with Gnu as?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I can't find any references to local labels in the MPASM User's Guide. Am
I missing them or don't they exists? In Gnu as I can do this:

func_one:
        lwz        r4,(r3)
1:    addi        r4,r4,1
      cmpi        r4,1000
      bne         1b
      mr          r3,r4
      blr

func_two:
        lwz        r4,(r3)
1:    addi        r4,r4,-1
      cmpi        r4,0
      bne         1b
      mr          r3,r4
      blr

In this example, '1' is the local label and the branch to 1b means jump
backwards to the first '1' label encountered. This is quite convenient
since I don't need to keep coming up with unique label names for simple
loop points.

Thanks.

--
- Mark ->
--

Re: MPASM: Any "local" labels like with Gnu as?
Quoted text here. Click to load it

The LOCAL pseudo-op does this for macros for the PIC MPASM.  The MPASM
manual can be downloaded from

www.microchip.com/Download/tools/ picmicro/code/mpasm/33014g.pdf

Thad

Re: MPASM: Any "local" labels like with Gnu as?

Quoted text here. Click to load it

I saw that, but I'm writing functions (non-repeated code), not macros.

Quoted text here. Click to load it

I've read that already. I guess the answer is "no".

Thanks,

--
- Mark ->
--

Re: MPASM: Any "local" labels like with Gnu as?

Quoted text here. Click to load it

Simply write your functions as macro and invoke them only once.

myfunc_m macro
    local bla,blub

bla:
blub:
    endm

my_func:
    myfunc_m
    rts

---
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: MPASM: Any "local" labels like with Gnu as?

Quoted text here. Click to load it

I think this link should help you:
http://groups.google.at/groups?hl=de&lr=&ie=UTF-8&frame=right&th=d80e512b414fe273&seekm=3daad715.18342655%40news.chello.at#s

While these are no "local" labels, they are compound delimiters with
anonymous label names behind them. You can write

 _begin_
  btfsc __C
  goto _end
  _begin_
    ;some simple loop here
    btfsc __C
    goto _begin
  _end_
  movlw 0ffh
  addf some_mem
  goto _else
  nop
  goto _end
 _else_
    _begin_
        ; etc
    _else_
       ; etc
    _end_
 _end_

You can also nest them (I think) 4 levels deep. I found the
quick-typing-without-figuring-out-another-pesky-label-name actually
made my coding less buggy and more productive. The source was more
readable also, although someone may think that the absence of the
information that was once in the label names would make it harder to
understand. It was quite the contrary because without the pressure to
find an original and talking name you had time to write a senseful
comment above the loops.
BTW, in this posting you will find a semi-intelligent "switch-case"
construct  also.

HTH
Mark

--
Mark Piffer
MCU and DSP programming & software design

Site Timeline