Hi Darrel - Hi Bruce,

Darrel I checked out your new message table code for 16 bit pics. Very Nice!

Bruce I read up on the info you linked me to, and I have a pretty good grasp of what you are doing in your code. I also figured out that the GOTO $-2 is just a slick way to skip backwards without having to use a labeled reference.

Well of course after getting my brain filled with a bit more knowledge I decided to try my hand at writing yet another variation on message string handling, but not without problems (and a smoking head). Check out this code:
Code:
DEFINE LOADER_USED 1
DEFINE OSC 40               ' change to suit oscillator speed
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 19200      ' change to suit baud rate

message var byte[40]
stringsize var byte
x var byte
temp var byte
Clr

Main:
    Call getSTR
@ data "This is a string",0
    Gosub putSTR

'    Call getSTR
'@ data "yet another string again",0
'    Gosub putSTR
Done:
   Goto Done

putSTR:
    For x = 0 To (stringsize-1)
    temp = message[x]
    Hserout [temp]
    Next x
    Hserout [$0D,$0A]       ; send carriage return + line feed
    stringsize = 0          ; reset for next message
    Return    

asm
_getSTR
    LFSR    FSR0,_message   ; set message array base address

;copy return address to TBLPTR and then pop it off the stack
    movf    TOSU,W
    movwf   TBLPTRU
    movf    TOSH,W
    movwf   TBLPTRH
    movf    TOSL,W
    movwf   TBLPTRL
    POP

;TBLPTR should now be pointing to 1st character in string
Next_Char
    tblrd   *+              ; table read and post increment TBLPTR
    movf    TABLAT,W        ; retrieve character to W register
    movwf   POSTINC0        ; xfer to message array and increment FSR
    incf    _stringsize,F   ; keep track of message string size
    movf    TABLAT,W        ; Is character = 0?
    bnz     Next_Char       ; If not, then get next character			

;use incremented value of TBLPTR as new return address (push it)
    movf   TBLPTRU,W
    movwf   TOSU
    movf   TBLPTRH,W
    movwf   TOSH
    movf   TBLPTRL,W
    movwf   TOSL
    PUSH
    return                  ;finished with message, return to caller
endasm
It's more of a variation of what Darrel's code does. Only I wanted to try using the POP and PUSH functions on the PIC18F to allow me to have embedded message strings (this is a pet peeve of mine). Anyway if you run the code as is (leave the 2nd message string commented out) everything works great. However if you try to use more then one message (uncomment the 2nd message string) then all hell breaks loose, and you end up with garbled messages and a runaway processor.

Any ideas what I am doing wroung?