cpik C compiler for PIC c -18 devices Version 0.7.1 - PiKdev, An IDE ...
cpik C compiler for PIC c -18 devices Version 0.7.1 - PiKdev, An IDE ...
cpik C compiler for PIC c -18 devices Version 0.7.1 - PiKdev, An IDE ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
}<br />
ROM_POINTER(p) ;<br />
READ_ROMBYTE ;<br />
while( prodl )<br />
{<br />
putchar( prodl ) ; READ_ROMBYTE ;<br />
}<br />
Not really complex, isn’t it ? But the next way to access ROM is even more simple, and more<br />
powerful.<br />
8.7.4 Accessing data in ROM with a ROM accessor<br />
In the previous sections, ROM data were traversed in sequence. Using a ROM accessor, ROM data<br />
can be traversed randomly. A ROM accessor is simply a function that mimic the behaviour of an<br />
access to array’s elements.<br />
Five macros are available to declare a ROM accessor. For example, the ROMF_TXT macro allows to<br />
declare a text, and the way to access it:<br />
ROMF_TXT( atext , "whiizz !\0")<br />
Here, atext is a ROM accessor <strong>for</strong> the specified string. It means that atext(0) returns ’w’,<br />
atext(1) returns ’h’ , and so on. The type of atext is ROMF i8 t. The F stands <strong>for</strong> function,<br />
because accessors are technically functions receiving an unsigned int.<br />
Here is another flavor of the usual puts() function :<br />
void RFputs(ROMF_i8_t p)<br />
{<br />
uint8_t k ;<br />
<strong>for</strong>( k = 0 ; p(k) ; ++k)<br />
putchar(p(k)) ;<br />
}<br />
The following table shows the available accessors, and their corresponding types.<br />
accessor declaration accessor type value type example<br />
ROMF_TXT ROMF_i8_t int8_t ROMF_TXT(a,"hello\0")<br />
ROMF_DATA8 ROMF_i8_t int8_t ROMF_DATA8(b,"-1,2,0xFF")<br />
ROMF_DATA8U ROMF_ui8_t uint8_t ROMF_DATA8U(c,"1,2,0xFF")<br />
ROMF_DATA16 ROMF_i16_t int16_t ROMF_DATA16(d,"-1,0xFF34")<br />
ROMF_DATA16U ROMF_ui16_t uint16_t ROMF_DATA16U(e,"1,12300")<br />
20