Not an example but proof that you could use it...
Hola Pix,
What follows are excerpts of code I used to get text on the screen of my scope.
They are not related to each other, just examples of the different functions.
Basically, in its simples form, it works like this:
At
programming time, you
write the data you want to read at
running time, for example, as this:
Code:
TEXT_LINE_4 DW "to get on-screen text. ",0
TEXT_LINE_5 DW "The idea sprang while ",0
TEXT_LINE_6 DW "working with the scope. ",0
TEXT_LINE_7 DW "Simple hardware: ",0
TEXT_LINE_8 DW " ",0
TEXT_LINE_9 DW "Micro PIC 18F4431 - Xtal ",0
Then, somewhere in your fantastic code you will come to the point where you need that data for something. You have to read it from the table (here, "TEXT_LINE_X").
For that you load the address of that table, probably this way (there are some other ways much more complex but efficient as well):
Code:
PROCESS_NEXT_CHAR
MOVFF [COLOR="#ff0000"]TBLPTRU[/COLOR],[COLOR="#ff0000"]UPPER[/COLOR] TEXT_LINE_X ;we need TBLPTR pointing
MOVFF T[COLOR="#ff0000"]BLPTRH[/COLOR],[COLOR="#ff0000"]HIGH[/COLOR] TEXT_LINE_X ;to first byte of data
MOVFF [COLOR="#ff0000"]TBLPTRL[/COLOR],[COLOR="#ff0000"]LOW[/COLOR] TEXT_LINE_X ;in the table
Look how the expressions above in
red are used.
Now, that you have the pointer aiming to the right place it will come the moment that you could use the data in the table as this:
Code:
[COLOR="#ff0000"]TBLRD*+ ;TABLAT =X:Y values pair (& incr TBLPTR)[/COLOR]
SWAPF TABLAT,W ;W =Y:X pair
ANDLW MASK_HI_NIBBLE ;W =0:X value
ADDWF CURR_X,W ;add index to show dot in proper column
MOVWF PORT_X ;output value ---> R2R
Or as this:
Code:
[COLOR="#ff0000"] TBLRD*+ ;get next char & incr TBLPTR - byte in TABLAT[/COLOR]
TSTFSZ TABLAT ;TABLAT =0 (ASCII NULL) - means we reached...
BRA PROCESS_NEXT_CHAR ;TABLAT >0 - process next char
DECF CNTR_MSG_LINES,F ;...end of line - go for next text line
I could show maybe two more examples of where I used "TBLRD" but the point is that TABLRD is just for that: reading the table. Whatever follows would be related to what you want to do with the byte in TABLAT.
While typing this reply I run across the reply from Mike who IS telling you about this function.
When you come to something like this which is "new" for you, always test it in the most single program, just by simulating it. Then go to hardware and then increase complexity.
In the past, and sometimes now, I used the press of one (or two) button to increase (decrease) something, be it data or addresses to see if what I did was right.
Hope you are not tired of reading this much of words.