Searching \ for '[PIC]:Program memory subroutine tables' 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/memory.htm?key=table
Search entire site for: 'Program memory subroutine tables'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:Program memory subroutine tables'
2002\02\13@014719 by Andrei B.

picon face
In a LED flasher project I did a while ago I used something like this :

-a sequence variable held which sequence the PIC should play
then :

select_seq:            ; subroutine
bcf STATUS, C
rlf seq, w
addwf PCL, f
call seq1
return
call seq2
return
call seq3
return
...

Is there a more compact way to do something like this? (less program
memory used? Here I need 2*sequences for this).




=====
ing. Andrei Boros
Centrul pt. Tehnologia Informatiei
Societatea Romana de Radiodifuziune

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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


2002\02\13@033913 by Claudio Tagliola

flavicon
face
Yes. Use retlw. Watch out for program memory page breaks though. I'm not
100% shure you can use addwf on PCL, but some of the others will point
that out if not.

select_seq:            ; subroutine
bcf STATUS, C
addwf PCL, f
retlw seq1
retlw seq2
retlw seq3

{Original Message removed}

2002\02\13@050837 by James Hillman

flavicon
face
> In a LED flasher project I did a while ago I used something like this :
>
> -a sequence variable held which sequence the PIC should play
> then :
>
> select_seq:            ; subroutine
>  bcf STATUS, C
>  rlf seq, w
>  addwf PCL, f
>  call seq1
>  return
>  call seq2
>  return
>  call seq3
>  return
> ...
>
> Is there a more compact way to do something like this? (less program
> memory used? Here I need 2*sequences for this).

How about this...

start:                ;the nops are included to enable me to see where
clrf seq             ;the program goes when simulated in mplab
nop
nop
nop
loop:
nop
nop
call select_seq
movwf seq
nop
goto loop

select_seq:            ; subroutine
movf seq,w
addwf PCL, f
goto seq1
goto seq2
goto seq3
goto seq4

seq1:
nop
nop
retlw 0x01
seq2:
nop
nop
retlw 0x02
seq3:
nop
nop
retlw 0x03
seq4:
nop
nop
retlw 0x00

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


2002\02\13@070600 by Andrei B.

picon face
--- Claudio Tagliola <spam_OUTcptagliolaTakeThisOuTspamCHELLO.NL> wrote:
> Yes. Use retlw. Watch out for program memory page breaks though. I'm
> not
> 100% shure you can use addwf on PCL, but some of the others will
> point
> that out if not.

seq1, seq2, seq3 are program memory pointers, larger then the 8bit wide
w. They represent locations of subroutines one of which I have to call
depending on the value of variable seq.


{Quote hidden}

=====
ing. Andrei Boros
Centrul pt. Tehnologia Informatiei
Societatea Romana de Radiodifuziune

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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


2002\02\13@093113 by Bob Ammerman
picon face
select_seq:
   movf    seq,W
   addwf    PCL,F
   goto     seq1
   goto     seq2
   goto     seq3

The individual 'seqN' routines end up RETURNing for select_seq.

Bob Ammerman
RAm Systems


{Original Message removed}

2002\02\13@114130 by Bob Barr

flavicon
face
On Wed, 13 Feb 2002 08:38:45 -0800, Bob Ammerman wrote:

>select_seq:
>    movf    seq,W
>    addwf    PCL,F
>    goto     seq1
>    goto     seq2
>    goto     seq3
>
>The individual 'seqN' routines end up RETURNing for select_seq.
>

Good one, Bob.
This not only saves a bit of code space but a stack level as well.
While there may be other reasons to do so, the only reason I can think
of to ever follow a call immediately with a return is for setting
breakpoints during debugging.


Regards, Bob

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


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