Searching \ for '[PIC]: 12C509 calls and gotos' 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: '12C509 calls and gotos'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 12C509 calls and gotos'
2000\07\11@084221 by Geoff Wootton

flavicon
picon face
Hi,

I've checked the archives and am having trouble sorting
this one out. When I try to build an asm file for a 12C509
in MPLAB I get the error:

jump not allowed at this address (must be in low half of page)

This is in response to a call statement. I realise from the
documentation that I need to set bit 5 in the status register
but I still get the error message when I try this. The commands
I am using are:

bsf status,5
call sub_one

I'd be grateful if anyone could help.

Regards

Geoff.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@085309 by Peter Betts

picon face
The call can only make a relative jump with a certain address range, it's
only got a limited number of bits to store the jump value. It sounds like
your "sub_one" is too far away. It cannot store the fit the required
relative jump into the bits available in the assembly word.

Try just putting the subroutine closer to the call to see if this works.

I can't remember about the 12C509 but in the 16F84 you should load the
PCLATH register with the high part of the address and then call the
subroutine using the low address part. The PCLATH is like a PAGE selection

Others will correct the detail here.

Pete


> {Original Message removed}

2000\07\11@091314 by Geoff Wootton

flavicon
picon face
Pete,

Thanks for the reply. You're right, if I move the subroutine
closer it does work, however I'd rather be able to use the
full address range as documented. The 12C508 has 512 program
memory locations, so setting bit 5 of the status register
will (should) give full addressabilty. The datasheet is
ambiguous on addressing the 12C509. There are 1024 locations
and it says to set bits 5 and 6 of the status register but
later on says that bit 6 is not implemented. If I move the
subroutines closer to the calls then they will be embedded
in my main code which makes it less readable. Also I'd then
have to put gotos in to jump over the subroutines. I've thought
of using nested subroutines but the stack on the 12C509 only
has 2 levels.

Regards

Geoff.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@094412 by Peter Betts

picon face
QUOTE:

For a GOTO instruction, bits 8:0 of the PC are provided
by the GOTO instruction word. The PC Latch (PCL) is
mapped to PC<7:0>. Bit 5 of the STATUS register
provides page information to bit 9 of the PC (Figure 4-8).

For a CALL instruction, or any instruction where the
PCL is the destination, bits 7:0 of the PC again are
provided by the instruction word. However, PC<8>
does not come from the instruction word, but is always
cleared (Figure 4-8).

The STATUS register page preselect bits are cleared
upon a RESET, which means that page 0 is pre-
selected.

Therefore, upon a RESET, a GOTO instruction will
automatically cause the program to jump to page 0
until the value of the page bits is altered.

Because PC<8> is cleared in the CALL
instruction, or any Modify PCL instruction,
all subroutine calls or computed jumps are
limited to the first 256 locations of any pro-gram
memory page (512 words long).

:------------------------------------
The last paragraph is interesting.

Try making sure the sub-routine is in the PAGE1 but within the first 256
locations.

Pete



> {Original Message removed}

2000\07\11@113110 by Bob Ammerman

picon face
In the 12C509 you _cannot_ call code in the second half of a 'page'. This is
because there are not enough bits available in the the instruction to define
the full target address.

"goto" instructions provide 9 bits to store the target address. This allows
use to specify any address in a 'page' of 512 locations.

You select the desired page of 512 locations by setting the PA0 bit in the
status register.

"call" instructions only provide 8 bits to store the target address. The
ninth bit is assumed to be a zero. Thus, the complete address is:

   PA0   0   K K K K K K K K

where the K bits are from the instruction.

Thus, you can only call to the first 256 locations in each 512 location
page.


Bob Ammerman
RAm Systems
(high performance, high function, low-level software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@113113 by Bob Ammerman

picon face
No: Calls are not 'relative', but rather always to the first 256 locations
in a 512 byte page.

Bob Ammerman
RAm Systems
(high performance, high function, low-level software)


----- Original Message -----
From: Peter Betts <spam_OUText-peter.bettsTakeThisOuTspamNOKIA.COM>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Tuesday, July 11, 2000 8:51 AM
Subject: Re: [PIC]: 12C509 calls and gotos


{Quote hidden}

> > {Original Message removed}

2000\07\11@113320 by Bob Ammerman

picon face
This only worked out of luck.  As you moved your code around, you managed to
get the subroutine into the first half of a 512 location page.

As I mentioned in a prior post:

For 'goto', bits A0 through A8 come from the instruction, bit A9 is from PA0
in the status register.

For 'call', bits A0 through A7 come from the instruction, bit A8 is always
zero, bit A9 is from PA0 in the status register.

Bob Ammerman
RAm Systems
(high performance, high function, low-level softare)

{Original Message removed}

2000\07\11@120235 by briang

flavicon
face
In-Reply-To: <Pine.OSF.3.91.1000711135156.32078A-100000spamKILLspamisdux1.bham.ac.uk>

In reply to Geoff Wootton <.....woottongKILLspamspam.....isdugp.bham.ac.uk>:

Isn't the 12C509 like the 16C55 where the call instruction can only call
addresses in the first half on the program memory. Hence subroutines
should be at the beginning of your program memory.

Brian Gregory.
EraseMEbriangspam_OUTspamTakeThisOuTcix.co.uk

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@123016 by Peter Betts

picon face
Bob,
I did point the following out afterwards which is exactly what you are
saying. Therefore I had corrected myself.


{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@145144 by w. v. ooijen / f. hanneman

picon face
> Try just putting the subroutine closer to the call to see if this works.

Not closer to the call but in the first (256 instruction) half of a 512
instruction page (the call sets bit 8 to 0, no way around that). This is a
12-bit-core feature that does not apply to 14-bit-core chips like the f84
and f877. It also a pain in the as for a compiler writer. 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.

Wouter

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@175720 by Bob Ammerman

picon face
Sorry!

Bob

----- Original Message -----
From: Peter Betts <ext-peter.bettsspamspam_OUTNOKIA.COM>
To: <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, July 11, 2000 12:29 PM
Subject: Re: [PIC]: 12C509 calls and gotos


{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\11@214612 by James Cameron

flavicon
face
I'll just put a plug in here for my "porting 16F84 to 12C509" page.

       <http://quozl.netrek.org/porting-16f84-12c509/>

It mentions this curiousity of GOTO and CALL along with numerous other
oddities.  If you've trained up on the 16F84 chip and find yourself
using the 12C series, this page is for you.  Corrections welcome.

--
James Cameron    KILLspamquozlKILLspamspamus.netrek.org     http://quozl.netrek.org/

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\07\13@044224 by Geoff Wootton

flavicon
picon face
James,

Thanks for the pointer to your web page. Regarding the section
on CALL/RETLW usage I was wondering if anyone has an example
of a vector table.

Regards

Geoff.

On Wed, 12 Jul 2000, James Cameron wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\07\13@080355 by James Cameron

flavicon
face
On Thu, Jul 13, 2000 at 09:33:23AM +0100, Geoff Wootton wrote:
> Thanks for the pointer to your web page. Regarding the section
> on CALL/RETLW usage I was wondering if anyone has an example
> of a vector table.

Yeah, goes 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

--
James Cameron    RemoveMEquozlspamTakeThisOuTus.netrek.org     http://quozl.netrek.org/

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\07\13@085548 by Geoff Wootton

flavicon
picon face
James,

Many thanks.

Geoff.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

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