Hi All,
This is probably a very fundametal question, but I've not found the answer yet !
I am using the MPLAB editor for assembler code entry, and was looking for an editor directive that allows for the entry of a text line.
I am writing a program for a 2 line by 16 character LCD display, and wish to entry the messages as 'strings' into to editor, instead of the MOVLW instruction, ie .
MESSAGE: <define string> "THE MESSAGE LINE"
where <define string> would be the assembler directive to produce a 16 byte character string.
I have scoured the MPLAB documentation and Microchip forum's (and this forum) but not found anything.
Thanks for the reply, had a look at the 'String' data function as suggested,
But the format of :-
LABEL: DATA "1234567890123456"
only seemed to produced a single character.
However, the second method of character seperation :-
LABEL: DATA '1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6'
did produce the correct data string in the memory.
Thanks for the reply, had a look at the 'String' data function as suggested,
But the format of :-
LABEL: DATA "1234567890123456"
only seemed to produced a single character.
However, the second method of character seperation :-
LABEL: DATA '1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6'
did produce the correct data string in the memory.
Thanks for that, It does work perfectly with the 'DT' directive, I was using the 'DA' / 'DATA' directive.
Incidentaly, I am using the PIC16F648A just as an LCD message handler holding around 200 pre-defined messages that will be 'called' up from a remote system just telling it which meassage and which line (upper/lower) to display it on.
If you switch to the pin compatible 16F88 then you can use the da directive to place two ascii characters per location and use the read flash ability to access it. It also runs twice as fast if using the internal oscillator.
I'll have a look at that ... its just that I have dozens of the 16F648A's left over that I purchased for another project that is now completed, and was just using these up on this project to get rid of the stock ...
I use a method similar to Eric's but I prefer to store the string tables in-line with my code. Just seems more intuitive to me.
The string tables can be longer than 256 bytes and can straddle 256 byte boundaries?
Regards, Mike
Code:
;
; example usage of the "PutStr" macro in your program
;
movlw Line1+4 ; line 1, tab 4
call LcdCmd ;
PutStr "this is line 1"
movlw Line2+4 ; line 2, tab 4
call LcdCmd ;
PutStr "this is line 2"
;
Code:
;******************************************************************
;
; PutStr macro - print a string to the LCD
;
PutStr macro str ;
local String, Print
movlw low String ;
movwf PTRL ;
movlw high String ;
movwf PTRH ;
goto Print ;
String dt str,0
Print call PutString ; print string
endm
;
;******************************************************************
Code:
;******************************************************************
;
; PutString - setup PTRL and PTRH to string address before entry
; - string must be terminated with a 0 byte
;
PutString
call GetTable ; get a table character |B0
andlw b'11111111' ; |B0
btfsc STATUS,Z ; a 00 byte, last character? |B0
return ; yes, return |B0
call LcdDat ; output char |B0
incfsz PTRL,F ; increment pointer |B0
goto PutString ; |B0
incf PTRH,F ; |B0
goto PutString ; |B0
;
GetTable
movf PTRH,W ; |B0
movwf PCLATH ; |B0
movf PTRL,W ; |B0
movwf PCL ; |B0
;
;******************************************************************