Sek Wing Siu wrote: > > Hi Scott, > I am interested in how you handle string of arbitrary length. > Can you repost your code? Thanks!! > O.K., Here it is again. Remember, this is a cut-and-paste from a working program. So the comments might be slightly out of context, but there are no bugs (except the one warning I point out in the comments). ;******************************************************************* ;write_string ; ; The purpose of this routine is to display a string on the LCD module. ;On entry, W contains the string number to be displayed. The current cursor ;location is the destination of the output. ; ; Memory used ; buffer2, buffer3 ; Calls ; LCD_WRITE_DATA ; Inputs ; W = String Number ; write_string CLRF buffer2 ;Used as an index into the string table MOVWF buffer3 ;Save a copy of which string we're to write ;Note that no check is made to see if W is within ;bounds (5 for my case, since there are 5 strings) ws1: CLRC RLF buffer3, W ;Get the saved copy and multiply it by two ADDWF PCL, F ;Computed GOTO CALL string0 ;Get next character in the string GOTO ws2 CALL string1 GOTO ws2 CALL string2 GOTO ws2 CALL string3 GOTO ws2 CALL string4 ws2: ANDLW 0xff ;"Return" point for computed goto's. BTFSC STATUS, Z ;If the returned byte is zero, we've reached the end RETURN CALL LCD_WRITE_DATA ;Write a single character INCF buffer2, F ;Point to the next character in the string GOTO ws1 string0 MOVF buffer2, W ;Get the string index ADDWF PCL, F ;and add it to the PC to get the next character dt "SENSOR",0 ;Note the zero termination. string1 MOVF buffer2, W ADDWF PCL, F dt "SMALL",0 string2 MOVF buffer2, W ADDWF PCL, F dt "MEDIUM",0 string3 MOVF buffer2, W ADDWF PCL, F dt "LARGE",0 string4 MOVF buffer2, W ADDWF PCL, F dt "0123456789ABCDEF",0 You're free to use it with no strings attached. (I couldn't resist!) Scott