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] retlw
The 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_real
However 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.
|file: /Techref/microchip/instr/call.htm, 2KB, , updated: 2012/11/29 12:09, local time: 2023/3/20 12:04,
|©2023 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://piclist.com/techref/microchip/instr/call.htm"> Microchip instruction CALL</A>
|Did you find what you needed?|
PICList 2023 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to piclist.com!