gnupic: function pointers? (was Re: [gnupic] Relocation problems with gplink)


Previous by date: 21 May 2005 03:44:59 +0100 Re: [gnupic] Relocation problems with gplink, Craig Franklin
Next by date: 21 May 2005 03:44:59 +0100 Re: [gnupic] function pointers? (was Re: [gnupic] Relocation problems with gplink), Peter Onion
Previous in thread:
Next in thread:

Subject: function pointers? (was Re: [gnupic] Relocation problems with gplink)
From: Iain Dooley ####@####.####
Date: 21 May 2005 03:44:59 +0100
Message-Id: <428F2F87.8090209@iaindooley.com>


Peter Onion wrote:
> [...]
> 	
> asciitab	CODE 0x1C00
> ASCIITable	
> 	DW	ASCIInul	; 0x00
> 	DW	ASCIIsoh	; 0x01
> 	DW	ASCIIstx	; 0x02
> 	DW	ASCIIetx	; 0x03
> 	DW	ASCIIeot	; 0x04

this is unrelated to your original issue, but how would you go about then calling these functions? a little while ago, i tried to create a function jump table using calculated goto statements, but failed for some reason and then gave up and did it some other way!! 

what i really want to be able to do is have a function table like you have, and then, depending on some variable, execute a function as in the following example (i've marked the part that i'm unsure of!!):

;want to use the idata_init function from another file that does a series of table reads to initialise data from the
;_cinit table
	extern idata_init

;my reset vector
_RESET_VECTOR code 0x00

	goto	init

;some initiliased data
	idata
function_table	db	functionName1,functionName2,functionName3,functionName4
count		db	0x03

;my code block
	code
init:
	;initialise idata using _cinit table generated by the linker
	call idata_init
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
	

Previous by date: 21 May 2005 03:44:59 +0100 Re: [gnupic] Relocation problems with gplink, Craig Franklin
Next by date: 21 May 2005 03:44:59 +0100 Re: [gnupic] function pointers? (was Re: [gnupic] Relocation problems with gplink), Peter Onion
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.