part 0 6086 bytes<P><FONT SIZE=2>Friends,</FONT>
<BR><FONT SIZE=2>I was hoping somebody could help me with an explanation</FONT>
<BR><FONT SIZE=2>of the &quot;dt&quot; define table directive. If I want to use it to </FONT>
<BR><FONT SIZE=2>send a bunch of data to a display, how would I get it to go </FONT>
<BR><FONT SIZE=2>to each byte? Do I have to increment anything? </FONT>
</P>

<P><FONT SIZE=2>This routine sends 2048 bytes of data on portb, only problem is </FONT>
<BR><FONT SIZE=2>that it is the &quot;same&quot; 2048 bytes of data. Only the first expression</FONT>
<BR><FONT SIZE=2>in the table. Any ideas would be greatly appreciated!</FONT>
</P>

The DT directive is just another way of saying RETLW, the only difference
is that you can specify multiple values per line (which get assembled as
multiple RETLW instructions). Calling your table as it is written will
simply execute the first RETLW 0x05, there's no way to get to the other
table values. To do so, you need to skip over them. Here's a common
technique:

A value of zero in my_desired_table_index (I'm not sure if that should be
data_count1 or count_reg, in your code) will return 5, a value of one will
return 7, a value of ten or greater will cause the Earth to fall out of its
orbit and plunge into the Sun (or other sub-optimal behavior) since you'd
jump completely over the table and execute whatever happens to be there.

Note that the technique as shown here can handle of a table of at most 255
entries, since the ADDWF and all the entries must fit within the bottom 256
bytes of a single memory page - this limitation is due to the fact that the
ADDWF is only an 8-bit operation. Larger tables require a 16-bit addition
of the index and the table's starting address: the high byte of the result
goes into the PCLATH register (or page select bits, in 12-bit core PICs),
then the low byte goes into PCL.
Jason Harper