Searching \ for 'PIC page seleclt macros' 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: 'PIC page seleclt macros'.

Truncated match.
PICList Thread
'PIC page seleclt macros'
1998\12\04@061151 by White Horse Design

flavicon
face
Has anyone written a simple macro to call subroutines across page boundaries?

e.g.

pcall func_in_page0
pcall func_in_page1

???

Regards

Adrian
---
WWW    WWW   Adrian Gothard
WWW WW WWW   White Horse Design
WWWWWWWWWW   +44-385-970009 (Mobile/SMS), +44-118-962-8913/4 (voice/fax)
WWWW  WWWW   spam_OUTwhdTakeThisOuTspamzetnet.co.uk, http://www.users.zetnet.co.uk/whd
---
Developers of GPS satellite-based tracking systems for vehicles/helicopters

1998\12\04@095323 by Fisher, Tom L (FISHER)

flavicon
face
This is part of a too-elaborate "super-assembler" I've developed, which I
hope to post on the Web soon.  I use a 16C76 or '77 because of the "bankless
ROM" feature, a good location for TempW.  This works on MPLAB 3.99.

;***************************************************************************
***

GoSub   MACRO   Subrtn

;Perform a "call subroutine" anywhere in memory.
;Note: W is preserved, so GoSub behaves just like a call.

;***************************************************************************
***

       movwf   TempW
       movlw   HIGH Subrtn
       movwf   PCLATH
       movfw   TempW

       call    Subrtn

       movwf   TempW
       movlw   HIGH $
       movwf   PCLATH
       movfw   TempW

       ENDM


{Quote hidden}

1998\12\04@141349 by Harold Hallikainen

picon face
On Fri, 4 Dec 1998 10:58:50 +0000 White Horse Design <EraseMEwhdspam_OUTspamTakeThisOuTZETNET.CO.UK>
writes:
>Has anyone written a simple macro to call subroutines across page
>boundaries?
>
>e.g.
>
>pcall func_in_page0
>pcall func_in_page1
>

       I think it's built into mchip's assembler...  try LCALL k


Harold



Harold Hallikainen
haroldspamspam_OUThallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1998\12\04@152053 by evan

picon face
>Has anyone written a simple macro to call subroutines across page
>boundaries?

I've listed two below:  one that preserves W to and from the called routine
and one that doesn't.  Both use an assembler variable _CallCounter that must
be already declared, it's used to reset PCLATH with the best value so future
local calls & gotos don't go into orbit.  The W-preserving macros use a
_TEMP_W RAM location that also must be declared.  If _TEMP_W is not mirrored
in all RAM banks (the upper bytes of a 16C67 are mirrored), it's up to you
to babysit the initial & returning bank number.

-Ed V
Agile Controls
@spam@agileKILLspamspamidmail.com

; Do a long call across address boundries
_call   macro   Routine_Label
_CallCounter  += 1
       movlw   high Routine_Label      ;set upper address byte
       movwf   PCLATH
       call    Routine_Label
       movlw   high Call_Return_Point#v(_CallCounter)  ;reset PCLATH
       movwf   PCLATH
Call_Return_Point#v(_CallCounter):
       endm

; Do a long call AND preserve W register
_wcall  macro   Routine_Label
_CallCounter  += 1
       movwf   _TEMP_W                 ;preserve W
       movlw   high Routine_Label      ;set upper address byte
       movwf   PCLATH
       movf    _TEMP_W, W              ;restore W
       call    Routine_Label
       movwf   _TEMP_W                 ;preserve W
       movlw   high Call_Return_Point#v(_Call_Counter)  ;reset PCLATH
       movwf   PCLATH
Call_Return_Point#v(_CallCounter):
       movf    _TEMP_W, W              ;restore W
       endm

; Do a long goto across address boundries
_goto   macro   GotoLabel
       movlw   high GotoLabel          ;capture and set upper address byte
       movwf   PCLATH
       goto    GotoLabel
       endm

; Do a long goto AND preserve W register
_wgoto  macro   GotoLabel
       movwf   _TEMP_W                 ;preserve W in case it's being used
       movlw   high GotoLabel          ;capture and set upper address byte
       movwf   PCLATH
       movf    _TEMP_W, W              ;restore W to original state
       goto    GotoLabel
       endm

1998\12\07@034654 by ruben
flavicon
face
Here is what I use for 12c50x and 16c63

12c50x:

;---- Long call macro ----------
;
;   Set or clear page bit PA0 if needed before a call. Reset it after return.
;   Only set/clear and reset if the call is to another page.
;
;   Example: The following line...
;
;   xcall   PAGE1,page_1_fun
;
;   ...is expanded to
;
;   bsf     f_PA0
;   call    page_1_fun
;   bcf     f_PA0
;
;   if it is executed in page 0. But to...
;
;   call    page_1_fun
;
;   ...if it is executed in page 1.
;
;   page is needed as a macroparameter because the assembler can't resolve forwa
rd
;   references correctly. (In pass 1 it doesn't know how many instructions the
;   macro will be resolved too if it is to a forward label. This could lead to d
ifferent
;   addresses for labels in pass 1 and 2.)
;

xcall       macro   page,label
           local   this_page

this_page   set ($>>d'9') & 0x01

           if (this_page != page)
               if (page & 0x01)
                   bsf     f_PA0
               else
                   bcf     f_PA0
               endif
           endif
           call    label
           if (this_page != page)
               if (page & 0x01)
                   bcf     f_PA0
               else
                   bsf     f_PA0
               endif
           endif
           endm


;---- Long goto macro ----------
;
;   Set or clear pagebit PA0 before a goto if needed.
;


xgoto       macro   page,label
           local   this_page
this_page   set ($>>d'9') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bsf     f_PA0
               else
                   bcf     f_PA0
               endif
           endif
           goto    label
           endm

;---- page set macro -------------

pset        macro   page
           local   this_page
this_page   set ($>>d'9') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bsf     f_PA0
               else
                   bcf     f_PA0
               endif
           endif
           endm

;---- page reset macro ---------

preset      macro   page
           local   this_page
this_page   set ($>>d'9') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bcf     f_PA0
               else
                   bsf     f_PA0
               endif
           endif
           endm

;-------------------------------

Could be extended to use also PA1 for processors
that have 4 banks (16c57).


And for 16c63:

;---- Long call macro ----------

xcall       macro   page,label
           local   this_page
this_page   set ($>>d'11') & 0x01

           if (this_page != page)
               if (page & 0x01)
                   bsf     PCLATH,3
               else
                   bcf     PCLATH,3
               endif
           endif
           call    label
           if (this_page != page)
               if (page & 0x01)
                   bcf     PCLATH,3
               else
                   bsf     PCLATH,3
               endif
           endif
           endm

;---- Long goto macro ---------------

xgoto       macro   page,label
           local   this_page
this_page   set ($>>d'11') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bsf     PCLATH,3
               else
                   bcf     PCLATH,3
               endif
           endif
           goto    label
           endm

;---- page set macro ----------------

pset        macro   page
           local   this_page
this_page   set ($>>d'11') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bsf     PCLATH,3
               else
                   bcf     PCLATH,3
               endif
           endif
           endm

;---- page reset macro --------------

preset      macro   page
           local   this_page
this_page   set ($>>d'11') & 0x01
           if (this_page != page)
               if (page & 0x01)
                   bcf     PCLATH,3
               else
                   bsf     PCLATH,3
               endif
           endif
           endm

;------------------------------------


Could be extended to also use bit 4 in PCLATH for prcessors with
more than 2 banks (16c66/67)


{Quote hidden}

==============================
Ruben Jvnsson
AB Liros Elektronik
Box 9124, 200 39 Malmv, Sweden
TEL INT +4640142078
FAX INT +4640947388
KILLspamrubenKILLspamspam2.sbbs.se
==============================

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