Computed goto problem

Status
Not open for further replies.

Mosaic

Well-Known Member
Hi guyz , need a bit of help.

I am using a full 512 bytes in a computed goto, so I do the auto update of the PCLATH based on this

Code:
movlw High(Table)
        addwf SuboffsetH,W
        movwf PCLATH
        movlw Low(Table)
        addwf SuboffsetL,W
        btfsc STATUS,C ;test if rollover 256 byte page, else skip skpnc
        incf PCLATH,F
......

Table        addwf PCL,f
              dt      byte,byte,byte,byte etc........

which does the job of rollover.

BUT!!, the addwf PCL,f starts as the first item on a new page boundary and when my goto offset (SuboffsetL) reaches 255. The code hangs on an infinite loop at the addwf PCL,w instruction. If I skip # 255 altogether and bump SuboffsetL to 0 and increment the PCLATH it will continue but SKIP the databyte at location 255.

Can't figure how to get the byte at location #255?
 
Last edited:
As you have calculated the actual address rather than an offset, it should be,
Code:
		movlw	High(Table)
		addwf	SuboffsetH,W
		movwf	PCLATH
		movlw	Low(Table)
		addwf	SuboffsetL,W
		btfsc	STATUS,C	;test if rollover 256 byte page, else skip skpnc
		incf	PCLATH,F
......             [COLOR="red"]<-------Edit, there shouldn't be any code here.[/COLOR]
Table		[COLOR="red"]mov[/COLOR]wf	PCL
		dt	byte,byte,byte,byte etc........

Mike.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…