On Fri, 2005-05-06 at 09:36 +0000, noname notregistered wrote: (a.k.a) Arjen Roelof Vellekoop > > Is it possible to assign two pointers (in my case to strings to compare) in > the 16F628. One pointer is possible via the FSR. > Arjen, Since the 16f628 (and all mid-range PICs) have only one FSR, you'll have to switch between the two pointers constantly to do a compare. E.g. suppose your pointer variables are named 'ptr1' and 'ptr2', you can do something like this: ; Enter with ptr1 and ptr2 pointing to two strings stored in RAM movlw MAX_STRING_LENGTH movwf max_length CompareLoop: ; Get a byte from the first string movf ptr1,W movwf FSR incf ptr1,F movf INDF,W movwf temp ; Get a byte from the second string movf ptr2,W movwf FSR incf ptr2,F movf INDF,W skpnz ;Did we reach the end of the string? goto CompareMatch ;yep - found a match xorwf temp,F skpz goto CompareMisMatch decf maxLength,F goto CompareLoop CompareMisMatch: ... CompareMatch: ... The has not been tested. Furthermore, I'm not even sure it's what you want. It sounds like you want to compare a string in RAM with one in ROM. I'd suggest storing program memory strings using two tables. One table is a table of pointers to the strings and the other contains the strings. Here is a cut-n-paste from an example program part of gpsim: ; The first part of the table contains pointers to the start of the ; strings. Note that each string has a two word pointer for the low ; and high bytes. ws_table: retlw LOW(string0) retlw HIGH(string0) retlw LOW(string1) retlw HIGH(string1) string0: dt "GPSIM WROTE THIS",0 string1: dt "A STRING ON ROW 2",0 In my case, I'm accessing the strings for an LCD display and not comparing them. But here's the full routine for doing the access: ;******************************************************************* ;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. ; This routine can be located anywhere in the code space and may be ;larger than 256 bytes. ; ; psuedo code: ; ; char *string0 = "foo"; ; char *string1 = "bar"; ; ; char *strings[] = { string0, string1}; ; char num_strings = sizeof(strings)/sizeof(char *); ; ; void write_string(char string_num) ; { ; char *str; ; ; str = strings[string_num % num_strings]; ; ; for( ; *str; str++) ; LCD_WRITE_DATA(*str); ; ; } ; ; Memory used ; buffer2, buffer3 ; Calls ; LCD_WRITE_DATA ; Inputs ; W = String Number ; write_string andlw WS_TABLE_MASK ;Make sure the string is ;in range movwf buffer3 ;Used as an index into ;the string table addwf buffer3,w ;to get the string offset ; addlw LOW(ws_table) ;First, get a pointer to ; the string movwf buffer3 ; ; movlw HIGH(ws_table) ; skpnc ; movlw HIGH(ws_table)+1 ; movwf PCLATH movf buffer3,w call ws2 ;First call is to get string ; offset in table movwf buffer2 incf PCLATH,f incfsz buffer3,w decf PCLATH,f call ws2 ;get the high word (of the ; offset) movwf PCLATH ; ws1: ;Now loop through the string movf buffer2,w call ws2 andlw 0xff skpnz ;If the returned byte is zero, return ; we've reached the end call LCD_WRITE_DATA incf PCLATH,f ;Point to the next character ; in the string incfsz buffer2,f decf PCLATH,f goto ws1 ws2 movwf PCL The full source for this code can be found in gpsim CVS repository at SourceForge: http://cvs.sourceforge.net/viewcvs.py/gpsim/extras/lcd/examples/ in the file screen.asm In your case, you'll want to access one of the strings in program memory and then compare it to one in RAM. The analogous code for the 18F family is *much* simpler! Scott -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist