Thomas N wrote: > Hi everyone, > > Below is a common LCD display code you often see. Anyway, I have a small > problem with it. > > When I trace through the code, it goes from line 00082 to line 00085 then > jump to line 00097 and 00098. At location 00098, you can see that the > program counter is 0x0285 (PCL displays 0x85) and W contains value 0. After > line 00098 is executed, PCL becomes 0x86. Next, the program jump to > location 0x0086 (not 0x0286), which is somewhere else in the code. WHY? I > suspect that the content of PCLATH is overwritten for some reason. Please > help! > Thomas > > 027B 3000 00082 MOVLW 0; Table address > 027C 00083 DISPMSG > 027C 00AF 00084 MOVWF TABLE_TEMP ;start of message > 027D 2285 00085 CALL TABLE O.K. You called TABLE which did a ADDWF to the Program counter, which pointer the program counter to... TABLE and it tried to execute the text as code. I think you want a RETLW for EACH character in the table! > > 027E 39FF 00086 ANDLW 0FFH You don't need to do this when the RETLW is working, it affects the ZERO bit flag as it fetches the text value. > > 027F 1903 00087 BTFSC STATUS,Z > > 0280 2A84 00088 GOTO OUT > 00089 call Send_Char ; Display character > 0281 082F 00090 MOVF TABLE_TEMP,W > 0282 3E01 00091 ADDLW 1 > 0283 2A7C 00092 GOTO DISPMSG > 0284 00093 OUT: > 00094 > 0284 0008 00095 RETURN > 00096 > 0285 00097 TABLE: > 0285 0782 00098 ADDWF PCL,F ; Jump to character > 0286 3454 3468 3469 00099 DT "This is a test!" ; > 3473 3420 3469 > 3473 3420 3461 > 3420 3474 3465 > 3473 3474 3421 > 0295 00100 TABLE_END: > 0295 3400 00101 RETLW 0 > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics -- * | __O Thomas C. Sefranek tcs@cmcorp.com |_-\<,_ Amateur Radio Operator: WA1RHP (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz http://hamradio.cmcorp.com/inventory/Inventory.html http://www.harvardrepeater.org -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics