See Pageing
On the 12-bit-core PIC (does not apply to 14-bit-core chips like the f84 and f877) and on the SX chips a subroutine to be called can only exist in the first (256 instruction) half of a 512 instruction page (the call sets bit 8 to 0, no way around that). The only way to call a subroutine anywhere in memory is to have a vector (a goto) in a lower half of a page and call that vector. James Cameron [quozl at us.netrek.org] http://quozl.netrek.org/ says:
[vector tables go] sort of like this ...org 0x0 goto main ; vector table alpha goto alpha_real beta goto beta_real delta goto delta_real main call alpha [code] call beta [etc] goto main alpha_real [lots of code] retlw beta_real [lots of code] retlw delta_real [lots of code] retlwThe point being that this allows the *_real entry points to exist anywhere within the bank memory. You CALL the vector table entry point, and it does a GOTO to the real entry point. It works because GOTO has the extra bit for the address that CALL does not.
If your code extended beyond 0x200, you could place a different vector table at the low end of the second page ...
org 0x200 ; vector table alpha bank0 goto alpha_real beta bank0 goto beta_realHowever with this trick your code would have to take care to restore PA0 before it tries the next CALL or GOTO within 0x200 to 0x3fe ...
high call alpha bank1 goto high --
/Techref/member/roger_froud-virgin-/index.htm Here's a handy little program for a 18F2480 that allows you to embed a string in your program which is accessed by the preceding call. In this case, it's used to write strings to an LCD display but the principle is useful elsewhere.
See also:
file: /Techref/microchip/instr/call.htm, 2KB, , updated: 2012/11/29 11:09, local time: 2024/11/22 09:29,
3.149.24.143:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/Techref/microchip/instr/call.htm"> Microchip instruction CALL</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.