loads a 9-bit address into the program counter and resumes program execution from that address.
It is tempting to say that the assembly-language instruction jmp is equivalent to BASIC's GOTO and leave it at that. In fact, the Microchip version of GOTO is called goto, reinforcing this notion.
However, the layout of PIC program memory isn't quite that simple. The instructions jmp and goto accept a nine-bit address, giving them a range of 512 addresses (0 to 511). That's a good fit for the 16C54 and '55, which only have 512 words of program memory. But the '56 and '57 have 1024 and 2048 words, respectively. How do you go to an address beyond location 511?
One way is to do nothing. If your program is executing in a straight line and happens to cross that boundary, the program counter will simply increment into 512+ territory. The first jmp after that crossing will do a peculiar thing, though--it will land back in the previous 512 addresses.
The reason is that a jmp loads the lower nine bits of the program counter from the address supplied. It loads the upper two bits of the program counter from the page-select bits PA0 and PA1 of the status register. Normal incrementing of the program counter does not update these bits. In order to make sure that a jmp lands somewhere other than the first 512-word program-memory page, you must supply an 11-bit address or label to the Parallax long-jump instruction ljmp. It will assemble the bit set/clear instr uctions required to update PA0 and PA1.
If you need to make sure that jmps land in a particular memory page, you can use lset with an 11-bit address. The instruction will move bits 9 and 10 of the address into PA0 and PA1. Thereafter, any jmps executed will land in that memory page.
There is also a long-call instruction, lcall. It works the same way, but is subject to the same restriction as call. That is, its destination must be in the first 256 addresses of a program-memory page. In a nutshell, those are the mechanics of Goto in PIC assembly language. The Microchip data sheets on the various PIC devices have helpful diagrams of the program-memory map.
|file: /Techref/microchip/seepicsrc/psbpix/goto.htm, 2KB, , updated: 2001/1/23 11:16, local time: 2017/11/22 04:54,
|©2017 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://techref.massmind.org/techref/microchip/seepicsrc/psbpix/goto.htm"> microchip seepicsrc psbpix goto</A>
|Did you find what you needed?|
Welcome to massmind.org!
Welcome to techref.massmind.org!