gnupic: Re: [gnupic] function pointers? (was Re: [gnupic] Relocation problems with gplink)
Subject:
Re: [gnupic] function pointers? (was Re: [gnupic] Relocation problems
with gplink)
From:
Iain Dooley ####@####.####
Date:
21 May 2005 09:33:41 +0100
Message-Id: <428F8143.7040500@iaindooley.com>
Peter Onion wrote:
> On Sat, 2005-05-21 at 12:54 +0000, Iain Dooley wrote:
>
>
>>loop:
>> ;load the value of the function table into fsr
>> lfsr FSR0,function_table
>> ;load the count into WREG
>> movf count,W
>> ;execute the function using PLUSW0
>> movff PLUSW0,PCL ;??????? THIS IS THE STEP THAT I'M NOT SURE OF!!!
>> ;have we executed all our functions?
>> decfsz count
>> ;nope, go and do it again
>> bra loop
>>;yep, finish the program
>>end
>
>
> I think this is 18F code ? Sorry but I've not moved onto these yet, so
> I only have a solution for 16F devices, and I'm not 100% sure it is
> correct as I just discovered it doesn't work if some of the code is NOT
> in the first bank ! Looks like a PCLATH problem.
>
> But here is the "nearly working code I use"
> decode:
> banksel EEADR
> movwf EEADR
> banksel EEADRH
> movlw high ASCIITable
> movwf EEADRH
>
> banksel EECON1
> bsf EECON1 & 0x7F,EEPGD
> bsf EECON1 & 0x7F,RD
> nop
> nop
> banksel EEDATH
> movf EEDATH,W
> movwf PCLATH
> movf EEDATA,W
>
> movwf PCL
>
hmmm okay, so it is possible to jump to a function by writing to the program counter directly, but i've not been able to make it work i the past.
does anyone have some working 18F code writing to PCL or PCLATH/PCLATL in order to form a function jump table?
cheers
iain