i'm using 16f877 and i want to make a table using pcl:
movlw number
addwf pcl
retlw ...
retlw...
and you know the table i want is bigger than 256and i was wondering what is the method to increase the table elements when pcl becomes 256
i think i should increment pclath or something like that
could you help me i'd appreciate it if you could write a little piece of code to help me
thanks
and maybe if there's another method to do tables with 16f877 assembly
I use this code - Load the full address to lookup into AdrHi - AdrLo and then call lookup. It increases
the address every time Lookup is called and returns the data in W
Code:
Lookup
CALL Dummy ;A dummy call - Puts this adress on the stack to return to
INCF AdrLo, F ;the table's RETLW returns here with data in W - now increase address
BTFSC STATUS, Z
INCF AdrHi, F
RETURN
Dummy
MOVF AdrHi, W
MOVWF PCLATH ;prewrite PCLATH...
MOVF AdrLo, W
MOVWF PCL ;and write PCL - This jumps to table adress - There should be a RETLW there
Now for an example on how to call it:
Code:
MOVLW HIGH(String)
MOVWF AdrHi ;load high byte of lookup table's address
MOVLW Low(String)
MOVWF AdrLo ;load low byte of lookup table's address
GetNext
CALL Lookup ;and call Lookup - this returns the data on AdrHi-AdrLo in W
MOVWF Scratch ;save W
MOVF Scratch, W ;and move it back to W (modifies Z flag)
BTFSC STATUS, Z; ;result is Z?
GOTO End ;yes? then end
;Do something with the byte here!
GOTO GetNext
End ;Code ends here
String db "This is a test!",0 ;the lookup table!