Mike - K8LH
Well-Known Member
Hi Astronomer',
Sorry to hear you're having trouble.
I was referring to implementing the PutString in-line string sub-system on 18F' devices. Basically you save memory for each macro call because the PutString subroutine can pull the string table address from the stack and then return to the calling program one instruction past the in-line string table. Another advantage on the 18F' is that you use the DB storage directive which stores 2 characters in each 16-bit memory word.
Here are the components;
Mike
Sorry to hear you're having trouble.
I was referring to implementing the PutString in-line string sub-system on 18F' devices. Basically you save memory for each macro call because the PutString subroutine can pull the string table address from the stack and then return to the calling program one instruction past the in-line string table. Another advantage on the 18F' is that you use the DB storage directive which stores 2 characters in each 16-bit memory word.
Here are the components;
Mike
Code:
;
; PutStr macro
;
PutStr macro str ; print in-line string macro
call PutString ;
db str,0 ; null terminated in-line string
end
Code:
;******************************************************************
;
; PutString - print in-line string via Stack and TBLPTR
;
; string must be terminated with a 00 byte and does not need
; to be word aligned
;
PutString
movff TOSL,TBLPTRL ; copy return address into TBLPTR
movff TOSH,TBLPTRH ;
clrf TBLPTRU ; assume PIC with < 64-KB
PutNext
tblrd *+ ; get in-line string character
movf TABLAT,W ; last character (00)?
bz PutExit ; yes, exit, else
rcall Put232 ; print character
bra PutNext ; and do another
PutExit
btfsc TBLPTRL,0 ; odd address?
tblrd *+ ; yes, make it even (fix PC)
movf TBLPTRH,W ; setup new return address
movwf TOSH ;
movf TBLPTRL,W ;
movwf TOSL ;
return ;
Last edited: