Searching \ for 'MPASM question (dt)' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/language/index.htm?key=asm
Search entire site for: 'MPASM question (dt)'.

Truncated match.
PICList Thread
'MPASM question (dt)'
2000\03\03@134504 by smerchock, Steve

flavicon
face
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>example snippet of program: Trying to use &quot;dt&quot; to display data.</FONT>
<BR><FONT SIZE=2>;-------------------------------------------------------</FONT>
<BR><FONT SIZE=2>table:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>dt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x05, 0x07, 0xff, 0xa4, 0x55</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>dt&nbsp; &nbsp;&nbsp;&nbsp; 0x67,&nbsp;&nbsp; 0xd5, 0xdc, 0x97, 0xaa</FONT>
<BR><FONT SIZE=2>;------------------------------------------------------</FONT>
<BR><FONT SIZE=2>practice:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>movlw&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x80</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>movwf&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count_reg</FONT>
<BR><FONT SIZE=2>go&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;Send it to &quot;PORTB&quot; (OUTPUT)!</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>decfsz&nbsp; data_count1,F&nbsp;&nbsp; ;Decrement &quot;data_count&quot;.</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>goto&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do_again</FONT>
<BR><FONT SIZE=2>;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>decfsz&nbsp; count_reg,F</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>goto&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; go</FONT>
<BR><FONT SIZE=2>;-------------------------------------------------------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>nop</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>end</FONT>
</P>
<BR>

<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>

<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>Steven</FONT>
</P>
<BR>

<P><FONT SIZE=2>Steven Kosmerchock</FONT>
<BR><FONT SIZE=2>Father/Student/Engineering Technician</FONT>
<BR><FONT SIZE=2>http://www.geocities.com/researchtriangle/lab/6584 </FONT>
</P>

<P><FONT SIZE=2>&quot;Great spirits have always encountered violent </FONT>
<BR><FONT SIZE=2>oppposition from mediocre minds.&quot;--A.Einstein</FONT>
</P>

</BODY>
</HTML>
</x-html>

2000\03\03@151104 by Jason Harper

picon face
> table:
>         dt      0x05, 0x07, 0xff, 0xa4, 0x55
>         dt      0x67,   0xd5, 0xdc, 0x97, 0xaa

... some code snipped

>         call            table

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:

table:
       movf my_desired_table_index,w
       addwf pcl,f
       dt      0x05, 0x07, 0xff, 0xa4, 0x55
       dt      0x67,   0xd5, 0xdc, 0x97, 0xaa
       

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

2000\03\04@060141 by amalkin

flavicon
face
In-Reply-To: <spam_OUT414C4109ED7BD3119EE700508B55030B15D833TakeThisOuTspampop.az.rfsworld.com>> Steve,
You have to have an incrementing index into your table, which is passed in
w to the instruction addwf pcl which you put at the beginning of the
table.
Hope this helps,
regards,
Anthony

.....Steve.KosmerchockKILLspamspam@spam@RFSWORLD.COM (Kosmerchock, Steve) wrote:


>
> Friends,
> I was hoping somebody could help me with an explanation
> of the "dt" define table directive. If I want to use it to
> send a bunch of data to a display, how would I get it to go
> to each byte? Do I have to increment anything?
>
> example snippet of program: Trying to use "dt" to display data.
> ;-------------------------------------------------------
> table:
         addwf   pcl
>         dt      0x05, 0x07, 0xff, 0xa4, 0x55
>         dt      0x67,   0xd5, 0xdc, 0x97, 0xaa
> ;------------------------------------------------------
> practice:
>         movlw           0x80
>         movwf           count_reg
> go      movlw           0x10
>         movwf           data_count1
         clrf          index
> do_again:
>         movlw           b'00001010'
>         movwf           porta
>         nop
>         bcf             porta,3
       movf    index,w
       incf    index
{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...