On Thu, 12 Oct 2000, Paul Reilly wrote: > > Here's extracts of my code. Can anyone spot the bug? I see three. > > > > TABLE_ADDR EQU 0x1800 > > ;-----------------------------------------------------------------------; > ; display_welcome ; > ;-----------------------------------------------------------------------; > > > display_message > movlw 0 > movf offset clrf offset > > movlw ">" > call send_ascii > > movlw LOW TABLE > addwf offset ;since offset may've changed in send_ascii, it's safer to do this: movf offset,w andlw 3 ;There are only 4 entries ;so make sure the upper bits are cleared addlw LOW(TABLE) movwf offset > movlw HIGH TABLE > btfsc status,c > addlw 1 > movwf PCLATH > movf offset,w > > call TABLE > call send_ascii > > movlw "<" > call send_ascii > > return > > ;-----------------------------------------------------------------------; > ; Messages ; > ;-----------------------------------------------------------------------; > > ORG TABLE_ADDR > > TABLE > movwf PCL ; called with displacement in W > retlw "A" > retlw "B" > retlw "C" > retlw "D" > but I'd probably just implement this so: fetchchar: movwf offset movlw HIGH(TABLE) movwf PCLATH ;okay now, this get's used only at the branch movf offset,w andlw 3 ;only 4 table entries addlw LOW(TABLE) ;add the base of the table skpc incf PCLATH,F ;oops, crossing 256 byte boundary movwf PCL TABLE: dt "A" dt "B" dt "C" dt "D" and then in the main code: movlw ">" call send_ascii ;display a ">" movlw 0 ;get first character in the table call fetchchar call send_ascii ; display it movlw 1 ;get second character in the table call fetchchar call send_ascii movlw "<" call send_ascii I think it makes more sense to place the table offset calculation along with the table. Scott PS. look at the archives for even better ways to display strings. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu