Mr RB
Well-Known Member
Hi, I'm working on a small application using a 12F675 and a serial LCD. The PIC only has 64 ram and 1kb ROM. I can't use a bigger PIC due to special circumstances.
I need to store a number of text strings in ROM efficiently and access them with minimal code size. When I used to do LCD routines in assembler I would store the text strings in PIC ROM doing something like this;
Which gave a result something like this;
So the text strings are all stored using just 1 ROM per character (Plus a NULL) and can be read from a table read (an indirect addressed call).
What is the simplest way to do this in C?? Or is there another simple way to store text strings using just 1 ROM per character? I don't mind using some inline assembler in the C code and I can adapt an assembler table read function easily enough.
It's the storing part that has me puzzled. In MikroC I can use something like;
But that is truly ugly code!
Does anyone have a nice solution for this?
I need to store a number of text strings in ROM efficiently and access them with minimal code size. When I used to do LCD routines in assembler I would store the text strings in PIC ROM doing something like this;
Code:
ORG 0x300
dt = {"Up","Down"}
Which gave a result something like this;
Code:
ORG 0x300
retlw 'U'
retlw 'p'
retlw 0x00
retlw 'D'
retlw 'o'
retlw 'w'
retlw 'n'
retlw 0x00
So the text strings are all stored using just 1 ROM per character (Plus a NULL) and can be read from a table read (an indirect addressed call).
What is the simplest way to do this in C?? Or is there another simple way to store text strings using just 1 ROM per character? I don't mind using some inline assembler in the C code and I can adapt an assembler table read function easily enough.
It's the storing part that has me puzzled. In MikroC I can use something like;
Code:
void messages (void) ORG 0x300
{
asm retlw 85; // U
asm retlw 80; // p
asm retlw 0; // NULL
}
But that is truly ugly code!