On Tue, 2005-05-31 at 14:45 -0700, Harold Hallikainen wrote: > Here's some stuff I did to send strings to an LCD. This is pretty much what I do too. However, in addition I use the assembler to control the creation of an array of strings. m1 db (m1e-m1-1),"Message1 m1e if VERSION < 10 #define _VERSION VERSION + '0' else #define _VERSION '1',VERSION - 10 + '0' endif m2 db (m2e-m2-1),"Version: ",' ',_VERSION,"\r\n" m2e m3 db (m3e-m3-1),"Message3" m3e m4 db (m4e-m4-1),"Message4 is a long message that can\r\n" db " wrap around to the next line\r\n" m4e Messages data m1,m2,m3,m4 LastMessage M_STARTUP EQU 0 M_VERSION EQU 1 M_INFO EQU 2 M_LONG_MESSAGE EQU 3 I use Pascal's string encoding method by making the first byte be the length of the string. Notice how the assembler can figure this out for you. Next, I create an array of pointers to the strings and store that in program memory at the label Messages. In C, one would write something like this for that array: const char *Messages[] = {m1,m2,m3,m4}; (It's a little harder to get C to automatically figure out the length of a string and encode it in the Pascal style.) Finally, the constants M_* are created as symbolic indices. I could have even used the assembler to create these too by writing something like (untested): Messages Lm1 data m1 Lm2 data m2 Lm3 data m3 Lm4 data m4 LastMessage M_STARTUP EQU Lm1-Messages M_VERSION EQU Lm2-Messages etc. To use this assembler generated array, I write: MOVLW M_STARTUP ;Send the Startup message to RCALL SendMessage ;the console or lcd or whatever And for completeness, here's the SendMessage routine that is very similar to Harold's SendMessage: movwf temp0 ;Save the message number CLRF TBLPTRU ;Get a pointer to the MOVLW LOW(Messages) ;start of the messages MOVWF TBLPTRL ; MOVLW HIGH(Messages) ; MOVWF TBLPTRH ; ; RLNCF temp0,W ;Select a particular message ADDWF TBLPTRL,F ; CLRW ; ADDWFC TBLPTRH,F ; TBLRD *+ ;Get the message ptr MOVFF TABLAT,temp0 ;Low byte of message ptr TBLRD *+ ; MOVFF TABLAT,TBLPTRH ;High byte MOVFF temp0,TBLPTRL ; TBLRD *+ ;Get the message Length MOVFF TABLAT,temp1 ;(could reuse temp0...) ; smGetArray TBLRD *+ ;Get a byte of the message MOVF TABLAT,W RCALL DoSomethingWithTheNextByte DECFSZ temp1,f bra smGetArray RETURN Scott PS, I turned the sarcastic tone down a notch or two from the last reply to one of Dave T's questions... -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist