buff var byte[30] $4f0 ; buff is now straddles banks 4 and 5
_buff 000004F0 symbol table
code still works perfectly as expected
buff var byte[30] $4f0 ; buff is now straddles banks 4 and 5
_buff 000004F0 symbol table
code still works perfectly as expected
Richard,
the source of my doubts is that I have some unexpected behaviours and I'm trying to understand where is the problem.
Watching the program memory, I found some "00" chars here and there in the middle of the string
Lets' say the string "Hello",0 when I look the program memory is 48 65 6C 00 6C 6F 00
I'm discovering now that the directive "da" is only for PIC12/16 and not for PIC18
http://ww1.microchip.com/downloads/e...Doc/33014J.pdf
I think I should use "db" or "data", I'm trying to understand
"db" seems to work fine
Last edited by Marcick; - 21st April 2015 at 08:40.
how are you looking at the pgm memory , I think something is not right
for me the da and data directives produce exactly the same result , I left the da directive in, thinking I might try the code on a pic16f1825 for a learning experience , for 7 bit ascii data either will do (pic 18's can store 2x8 bit ,pic 16's 2x7bit )
the relevant listings
Code:0 0013E 6854 7369 6920 00199 data "This is a string",0 2073 2061 7473 6972 676E 0000Code:00013E 6854 7369 6920 00199 da "This is a string",0 2073 2061 7473 6972 676E 0000
Found the problem.
I have a string like this:
say "hello"
I use this format do declare it, the same format I was using with arraywrite
The result in program memory is that before each char 34 is added a char 00Code:@ da "say",34,"hello",34,0
If I use "db" instead the result is correct.
The pdf I linked before says that "da" is not for PIC18
where ?
da – Data ASCII.
Generates a packed 14-bit number representing two 7-bit ASCII characters.
this works
@ da "say \"Hello\"\0"
db is definitely an easier way to pack a mixed string data statement like "say",34,"hello",34,0 . funny I could never see the point of db until now
Hi:
I use this routine to send eeprom stored msg's to display LCD.
It can be modified to send then to a string...
I hope this helps...
'************************************************* ***************
'USED VARS:
SDAT VAR PORTD.1 'I2C EEPROM DATA 'ADJUST TO USED PINS AND
SCLK VAR PORTD.0 'I2C EEPROM CLOCK 'MAKE THEM INPUTS IN USED TRIS REG.
CHAR VAR BYTE
SLAVE VAR BYTE
EEADDR VAR WORD
SLAVE = $A0 'EEPROM SLAVE ADDRESS
'***** SUB TO DISPLAY MSGS STORED IN EEPROM ****************
MSG_DISP:
GOSUB CLRDISP 'CLEAR SCREEN
MSG:
LEENXT: I2CREAD SDAT,SCLK,SLAVE,EEADDR,[CHAR] 'SIN CLEAR
IF CHAR => $80 THEN
LCDOUT $FE,CHAR
GOTO INCADD
ENDIF
IF CHAR <> 0 THEN
LCDOUT CHAR
INCADD: EEADDR = EEADDR + 1
GOTO LEENXT
ENDIF
RETURN
'************************************************* *************
'TO CALL THE ROUTINE:
'SET EEPROM ADDRES:
'YOUR STRING CAN HAVE ANY LENGTH AND MUST BE TERMINATED WITH A NULL CHAR
'"00"
'*********************************************
EEADDR = $0350 'WHEREVER YOUR STRING STARTS
GOSUB MSG_DISP
'*********************************************
' YOU MUST USE AN EEPROM WITH WORD ADDRESS (25LC32A,OR BIGGER)
'PROGRAMM YOUR EEPROM WITH MSGS ENDED WITH 00 (NULL) AND TAKE NOTE OF
'THE START ADDRESSES.
'AND THATS ALL...
Greetings...
Ruben de la Pena V.
I think it might have something to do with the number of bytes (odd or even) in the string.
In both of Richards examples there's an even number of bytes (16 and 22) but your Hello string there's an odd number of bytes (5). I seem to remember an issue with this being discussed in one of the 'Strings in codespace' threads some years ago.
/Henrik.
odd length strings , wastes space but not a problem
00013E 6854 7369 6920 00199 data "This is a string1",0
2073 2061 7473
6972 676E 0031
0000
00013E 6854 7369 6920 00199 da "This is a string1",0
2073 2061 7473
6972 676E 0031
0000
00013E 6548 6C6C 006F 00199 da "Hello",0
0000
there's another little cheat if all the strings are odd length the 0 terminator is redundant
Bookmarks