Searching \ for '[PIC]: Macro Location' 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: 'Macro Location'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Macro Location'
2002\07\24@113034 by Richard Mellina

picon face
       I am new to pics and am confused about where macros can go in the program.
I read that they are placed in a .inc file and then included in the program.
Can they be placed in a .asm file? Thanks

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\07\24@120816 by 8859-9?B?1m1lciBZYWxo/Q==?=

Yes you can, PUSH, PULL, Bank0 and Bank1, movlf, movff are all macros:

       list    p=16f628
       #include  P16F628.INC

       __CONFIG   _BODEN_ON & _CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF
& _MCLRE_OFF & _INTRC_OSC_NOCLKOUT

       errorlevel -302
;***********************************************************************
***************************
; defines start here
;***********************************************************************
***************************
#define MyCode                  0x92
#define RedPin                  portb, 4
#define GreenPin                portb, 5

;***********************************************************************
***************************
; macros start here
;***********************************************************************
***************************
; first thing to do when entering the interrupt
;***********************************************************************
***************************
push    macro
       movwf   w_temp          ; save w reg
       swapf   status, w       ; the swapf instruction, unlike the
movf, affects no status bits, which is why it is used here.
       clrf    status          ; sets to bank0
       movwf   status_temp     ; save status reg
       movf    pclath, w
       movwf   pclath_temp     ; save pclath
       clrf    pclath
       movf    fsr, w
       movwf   fsr_temp        ; save fsr reg
       endm
;***********************************************************************
***************************
; last thing to do when exiting the interrupt
;***********************************************************************
***************************
pull    macro
       movf    fsr_temp, w     ; get saved fsr reg
       movwf   fsr             ; restore        
       movf    pclath_temp, w  ; get saved pclath
       movwf   pclath          ; restore
       swapf   status_temp, w  ; get saved status in w         movwf   status          ; restore status ( and bank )
       swapf   w_temp, f       ; reload into self to set status bits
       swapf   w_temp, w       ; and restore
       endm

; switch to bank 0
bank0   macro
       bcf     status, rp0
       endm

; switch to bank 1
bank1   macro
       bsf     status, rp0
       endm

; mov l to f
movlf   macro   lvalue, faddress
       movlw   lvalue
       movwf   faddress
       endm

movff   macro   f1addr, f2addr
       movf    f1addr, w
       movwf   f2addr
       endm
;**********************************************************
; end of macro definitions
;**********************************************************

; define variables starting at address 0x20
       cblock  0x20

       count1
       count2
       count3
       temp1

       endc
; end defining variables

; starts here when reset
       org     0x000
       goto    Initialize

; interrupt starts here
       org     0x004
       push

       nop

       pull
       retfie
;***********************************************************************
***************************
Initialize
       movlw   0x07
       movwf   cmcon                                           ;
(bank1:) PortA digital i/o (VERY IMPORTANT!!!)
       .
       .
       .

       end

Ömer YALHI
.....oyalhiKILLspamspam@spam@teksan.com.tr
http://www.teksan.com.tr
Tel : +90 212 613 22 00
Fax: +90 212 544 70 35


{Original Message removed}

2002\07\24@123103 by Harold M Hallikainen

picon face
Yes. I typically place them at the top of my ASM file. I THINK (but I
haven't looked it up) macros must be defined before they are used
(earlier in the file, or in an include file that is included before the
macro is used).

Harold

On Wed, 24 Jul 2002 10:25:40 -0500 Richard Mellina <rsillemspamKILLspamFLASH.NET>
writes:
>         I am new to pics and am confused about where macros can go in
> the program.
> I read that they are placed in a .inc file and then included in the
> program.
> Can they be placed in a .asm file? Thanks
>


FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

Reach broadcasters, engineers, manufacturers, compliance labs, and
attorneys.
Advertise at http://www.hallikainen.com/FccRules/ .


________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/web/.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\07\24@142219 by Bob Barr

flavicon
face
On Wed, 24 Jul 2002 10:25:40 -0500, Richard Mellina  wrote:

>        I am new to pics and am confused about where macros can go in the program.
>I read that they are placed in a .inc file and then included in the program.
>Can they be placed in a .asm file? Thanks

They sure can. Anything in an include file is treated by the assembler
just as if it were in the asm file in the first place.

The main convenience factor I find in using an include file is that it
can be used by many different asm files. By having your macros in one
place, any changes made to the include file's contents will be applied
to any asm file that uses it.


Regards, Bob

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2002\07\25@032650 by Bill & Pookie

picon face
I see you got a "yes" answer to your question.

When you use an include file, you are simply
telling the assembler program to unsert the text
from that file here.  And that text becomes part
of the text that is assembked.  The include
derictive does not change euther the .inc nor the
.asm files.

Just "copy" include file, and "paste" it here in
the program befor assembling it.

Bill


{Original Message removed}

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