Hi, If datalines is configured as an output Port which I assume it is, then what you write to the port is not necessarily what you read from the port. There are different set of latches at the port pins. This probably justifies the comment >I have this (probably silly) "thing" about writing to a register and >reading from it on the very next instruction. I agree using the xorlw 0xFF will remove at least one source of error ie > call mess2 ;get the character > movwf datalines ;send it to lcd > ; housekeeping for LCD snipped > comf datalines,0 ;end of table has 0xff marker, so I complement it > btfsc status, z ;complemented character = 0? becomes call mess2 ;get the character movwf datalines ;send it to lcd ; housekeeping for LCD snipped xorlw 0xFF ;complement the character using xorlw btfsc status, z ;complemented character = 0? Regards, James Caska caska@virtualbreadboard.com ujVM - 'The worlds smallest java virtual machine' -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Tony Nixon Sent: Monday, 8 October 2001 9:31 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: zero flag after comf Doug Hemingway wrote: > > I am creating a general macro for sending messages to an LCD display, and > have run into a problem. > > Here's my code: > > clrf counter > disloop incf counter,1 ;get next character position from table > movf counter,0 ;put char position into W > call mess2 ;get the character > movwf datalines ;send it to lcd > ; housekeeping for LCD snipped > comf datalines,0 ;end of table has 0xff marker, so I complement it > and check for zero > btfsc status, z ;complemented character = 0? > goto exitaddr ;yes, done > goto disloop ;no, not done, get next character. > exitaddr ;continue on > mess2 addwf pc,1 > retlw 'H' > retlw 'I' > retlw 0xff > > The code does not take the branch to exit. As I read the spec sheet, the > comf command should set the z flag if the result is zero (ie, datalines > contained 0xff before the comf command). > > What am I doing wrong? Even though it would make no difference, I would change... comf datalines,0 to.. xorlw 0xFF I have this (probably silly) "thing" about writing to a register and reading from it on the very next instruction. Question Time :-) Where is the "mess2" jump table located in memory?? Is the PCLATH set up to handle it? Is it crossing a page boundary? Why do you want this as a MACRO? Wouldn't it be better as a subroutine? Can you simulate it in MPLAB and see if the subroutine does in fact return with 0xFF? -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body