Searching \ for 'Making Long Calls' 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/index.htm?key=making+long+calls
Search entire site for: 'Making Long Calls'.

Truncated match.
PICList Thread
'Making Long Calls'
1999\10\06@215517 by Fansler, David

flavicon
face
I realize this has come up before, and I thought I understood it - but it is
not working as I thought it should.
I am doing development with a 16C74A while waiting on TechTools to come out
with the 16C87X family module.  To make sure I understood how to make a long
call (i.e. cross a 2k boundary) I wrote the following test code:
device  pic16c74A,xt_osc,wdt_off,protect_off
       org 00
       goto START
       org 05h
START
       bsf pclath,3
       call TEST
       goto START
       org 090fh
TEST
       retlw 0

As I understood, the call would push the entire return address to the stack,
so the "retlw 0" would return to the "goto START", which it does, however,
since I set the pclath bit 3 to 1 before the call, it is staying 1 on the
"retlw 0" and the "goto START" is going to location 1005h rather than 0005h.
If I put a "bcf pclath,3" before the "retlw 0" then the program does goto
location 0005h.

I thought the pclath was cleared by the retlw - is it not?
Thanks,

David V. Fansler
Network Administrator
AutoCyte, Inc.
336-222-9707 Ext. 261
spam_OUTdfanslerTakeThisOuTspamautocyte.com
Now Showing! http://www.mindspring.com\~dfansler\  Updated September 23, 1999

1999\10\07@003154 by Peter Grey

picon face
At 09:53 PM 6/10/99 -0400, you wrote:

It is a real pain with the 2 pages. You must set and clear the PCLATH when
moving between pages. You are correct in saying that it must be cleared
before doing the goto START.

good luck,

Peter
{Quote hidden}

1999\10\07@080718 by Fansler, David

flavicon
face
               -----Original Message-----
From:   Peter Grey [martechspamKILLspamOZEMAIL.COM.AU]
Sent:   Thursday, October 07, 1999 12:20 AM
To:     .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Subject:        Re: Making Long Calls

At 09:53 PM 6/10/99 -0400, you wrote:

It is a real pain with the 2 pages. You must set and clear the PCLATH when
moving between pages. You are correct in saying that it must be cleared
before doing the goto START.

good luck,

Peter

Thanks Peter - you have confirmed what I was afraid of!

David V. Fansler
Network Administrator
TriPath Imaging, Inc.
336-222-9707 Ext. 261
EraseMEdfanslerspam_OUTspamTakeThisOuTautocyte.com <dfanslerspamspam_OUTautocyte.com>
Now Showing! http://www.mindspring.com/~dfansler
<http://www.mindspring.com/~dfansler>   Updated September 23, 1999

1999\10\07@094715 by Andy Kunz

flavicon
face
>since I set the pclath bit 3 to 1 before the call, it is staying 1 on the
>"retlw 0" and the "goto START" is going to location 1005h rather than 0005h.

That's because the RET instructions only update the program counter.  They
don't "fix" the bits for the next jump.

Andy

==================================================================
Eternity is only a heartbeat away - are you ready?  Ask me how!
------------------------------------------------------------------
@spam@andyKILLspamspamrc-hydros.com      http://www.rc-hydros.com     - Race Boats
KILLspamandyKILLspamspammontanadesign.com  http://www.montanadesign.com - Electronics
==================================================================

1999\10\07@135229 by Harold M Hallikainen
picon face
On Wed, 6 Oct 1999 21:53:14 -0400 "Fansler, David"
<RemoveMEDFANSLERTakeThisOuTspamAUTOCYTE.COM> writes:
{Quote hidden}

       First, note  that there is a "secret instruction" of LCALL that
handles the page setting bits for you on the call.  That way you don't
have to keep track of them.
       Also, you are correct, the return or retlw instructions do not
modify pclath.  You can substitute an LGOTO for the goto and it should
work.

Harold



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

___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: dl.http://www.juno.com/dynoget/tagj.

1999\10\07@162431 by Randy Brumbaugh

flavicon
face
One other thing that the PICs (at least the 16C63/ 66) do that can bite you
on long calls:  The number of bits loaded from PCLATH into the PC is 2 for
a GOTO or CALL, but 5 when PCL is the destination of an instruction.

This silly design can get you (it did me) -- say you are executing a
routine at the top of the page, then jump to a table look-up (which I
usually place near the end of the page).  The CALL to the table routine
will work fine with no PAGESEL.  But when you get there and try to do an "
ADDWF PCL, F ", The PC will grab more bits from the PCLATH and jump to
someplace (probably) not in the table.

In other words, anyplace you use a computed GOTO, not only does the
destination have to be in the same 255 address block, but PCLATH has to be
set.  So a PAGESEL is sometimes needed even when you are not jumping
between pages.

Maybe this is obvious, but I hope I can save somebody else the time of
making this mistake.

Also, I tried to use the LCALL and LGOTO instructions when I first started
using the PICs, but they seemed to not work properly and generate more
instructions than needed.  Could well be operator error, but I gave them up.

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