Searching \ for '[PIC] : 18F, Macros and reusing labels inside' 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=18F
Search entire site for: ': 18F, Macros and reusing labels inside'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] : 18F, Macros and reusing labels inside'
2005\05\09@091447 by alan smith

picon face
I thought I read somewhere...here or elsewhere, that
with the 18F series you can reuse labels inside a
macro?

I built and tested some macros then went to implement
them in a few places and came up with duplicate labels
upon building the file.

So, can you do this, and if so, whats the trick?

example as follows...on a 18F4680

min_value        macro        cMSB,compMSB,cLSB,compLSB

 movf         cMSB,w        
 cpfsgt compMSB
 bra         _minTstLsb
 movff        cMSB,compMSB        
 movff        cLSB,compLSB
 bra        _minDone
_minTstLsb
movf        cLSB,w
cpfsgt        compLSB
bra        _minDone                                        
movff        cMSB,compMSB                
movff        cLSB,compLSB        
_minDone
       endm



               
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

2005\05\09@092548 by Michael Rigby-Jones

picon face

{Quote hidden}

You have to use the LOCAL keyword.  From the MPASM help file:

len   equ 10           ; global version
size  equ 20           ; note that a local variable
                      ; may now be created and modified
test  macro size
     local len, label ; local len and label
len   set size         ; modify local len
label res len          ; reserve buffer
len   set len-20
endm                   ; end macro

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2005\05\09@093111 by olin_piclist

face picon face
alan smith wrote:
> I thought I read somewhere...here or elsewhere, that
> with the 18F series you can reuse labels inside a
> macro?
>
> So, can you do this, and if so, whats the trick?

Use the LOCAL directive.

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\05\09@121009 by John Sanderson

flavicon
face
Hello Alan & PIC.ers,

----- Original Message -----
From: "alan smith" <micro_eng2spamKILLspamyahoo.com>
To: "Microcontroller discussion list - Public." <.....piclistKILLspamspam.....mit.edu>
Sent: Monday, May 09, 2005 3:14 PM
Subject: [PIC] : 18F, Macros and reusing labels inside


{Quote hidden}

This is quite easy, by declaring the labels as `local' within each macro
they don't fight each other.
e.g.:-

start_i2c         MACRO      ;[S]
local               humf_01, humf_02
       bcf          PIR1,SSPIF
       bsf          SSPCON2,SEN     ;send i2c START [S] bit
       clrf          isr_scratch_B1        ;`stuck-loop' error trap freg
humf_02
        btfsC     SSPCON2,SEN     ;Wait for the Start condition to end,
        bra         humf_01                 ;ie endm
        decfsz     isr_scratch_B1
        bra         humf_02                 ;ie test again
        bsf         i2c_corrupt_S_flag  ;causes i2c reset
humf_01
      endm


stop_i2c         MACRO      ;[P]
local                 humf_01, humf_02
        bcf         PIR1,SSPIF
        bsf         SSPCON2,PEN     ;send i2c STOP [P] bit
        clrf         isr_scratch_B0
humf_02
        btfsC     PIR1,SSPIF     ;stop bit cycle completed
       bra         humf_01          ;ie endm
       decfsz     isr_scratch_B0
        bra         humf_02          ;ie test again
        bsf         i2c_corrupt_P_flag
humf_01
    endm




   bestos,   John

email from the desk of John Sanderson.
web: http://www.jscontrols.co.za
email: EraseMEjohnspam_OUTspamTakeThisOuTjscontrols.co.za
Tel: (027) 11 893 4154
Cell: 082 741 6275
Manufacturer and purveyor of force testing machines
and apparatus.



2005\05\09@150120 by alan smith
picon face
Thanks John...solved the problem.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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