PICdude wrote: > Anyone have thoughts on how to work with strings in PIC assembly? > Specifically, I want a cleaner (simpler code) way to send various > strings to an LCD, rather than one char at a time. > > I thought of doing something like a lookup table (with DT "String > text..." etc) but I expect there's a more elegant way, though not > finding much else so far on the net. What is so bad about the DT method? On a PIC 18 you'd use DB, but the concept is the same. Don't forget to put the DB statements in a CODE_PACK section though. You won't get what you expect in a regular CODE section. The real question is what data structure to use. If you know you'll never send a NULL (or some other byte value), you can use that to indicate end of string. To be more general, you put the length in the first byte. Sometimes the length is passed separately to facilitate re-using string snippets. Either way, this can all be wrapped in a macro that hides the data structure details. Then you need a subroutine that is passed a pointer to the string in progra= m memory that sends it. You can even wrap the subroutine call in a macro to make it look a little cleaner in the code. For example, here are some fixe= d strings from a PIC 18 project: str_enone db "disable", cr_k, 0 ;parameter to disable encryption str_ew64 db "wep64", cr_k, 0 ;parameter for WEP64 encryption str_ew128 db "wep128", cr_k, 0 ;parameter for WEP128 encryption I created the KSTRING macro to cause a string of this type to be emitted. = A example of sending a string is: kstring str_ew128 ;select WEP128 encryption type If you wanted to get really fancy, you could make a macro to write a fixed string, with the string on that line. Something like: sendstr "Enter self-destruct abort code: " I think you'd need my preprocessor (http://www.embedinc.com/pic/prepic.txt.htm) to implement that macro, as it has to save some state for another macro or subroutine to write in a CODE_PACK section later. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .