String format question
mynet43
Posts: 644
I'm trying to figure out the format of a string in a calling sequence.
e.g. disp.str(string("this is a string..."))
I know that the str routine will work with a zero terminated string.
I haven't been able to locate the string( ) routine.
I'd like to know the difference between a string in quotes in a calling sequence and one that uses a pointer to a zero terminated string.
Like this:
OOPS byte "Oops, cog start failed...",0
If I say disp.str(@OOPS), it works fine.
If I say disp.str("Oops, cog start failed..."), it doesn't work.
If you'll point me to the string( ) routine, I'm sure I can figure it out.
Thanks for your help.
e.g. disp.str(string("this is a string..."))
I know that the str routine will work with a zero terminated string.
I haven't been able to locate the string( ) routine.
I'd like to know the difference between a string in quotes in a calling sequence and one that uses a pointer to a zero terminated string.
Like this:
OOPS byte "Oops, cog start failed...",0
If I say disp.str(@OOPS), it works fine.
If I say disp.str("Oops, cog start failed..."), it doesn't work.
If you'll point me to the string( ) routine, I'm sure I can figure it out.
Thanks for your help.
Comments
Another way to define a string constant is, as you've demonstrated, in a DAT section with a label. Also, as you've shown, you can't just pass a string constant longer than 4 bytes. The compiler will complain. If the string constant is 4 or fewer bytes, it is treated as a 32 bit numeric value with the first character as the least significant byte (bits 0-7), the second character as bits 8-15, the third character as bits 16-23, and the fourth character as bits 24-31. If there are fewer than 4 characters, the space is filled with zero bits. Note that this can't be passed to one of the string output routines like disp.str() which expects an address.
I searched through all the code but I missed it in the manual.
That really helps. Maybe I can write a str( ) routine that uses string( ) only when it needs to...