[Icc-avr] Const arrays of pointers to const arrays
Björn Lindgren
bjonaspero at hotmail.com
Wed Sep 5 02:10:25 PDT 2007
Sorry, it didn't work in assembler. It seemed like it did with the condensed
data of 6 bytes below, but with full data range ( 2kbyte) it doesn't.
Basically I want to get rid of:
if( 0 == key ) {
start_a = ptr_a = &sinus_tab[7][0]; // 0
start_b = ptr_b = &sinus_tab[3][0];
}
else if( 1 == key ) {
start_a = ptr_a = &sinus_tab[4][0]; // 1
start_b = ptr_b = &sinus_tab[0][0];
}
...etc...
else if( 15 == key ) {
start_a = ptr_a = &sinus_tab[5][0]; // 2
start_b = ptr_b = &sinus_tab[0][0];
}
and replace it by a look-up table.
Björn
>From: "Björn Lindgren" <bjonaspero at hotmail.com>
>Date: Wed, 05 Sep 2007 09:46:19 +0200
>
>Can someone tell me how to define a constant array of pointers to other
>constant arrays.
>I can do this in assembler but I want the customer to take over the
>maintenance and therefore
>I wish to have 100% of the code in C.
>
>Heres a condensed version:
>
>// pointer_test.c
>
>const signed char sinus_tab[2][3] = {
>{1,2,3},{4,5,6}};
>
>/*** Viritual definition (I want something like this)
>const signed char *pointer[2] = {
> sinus_tab[1],
> &sinus_tab[0][0] };*/
>
>// Working declaration (while the definition is done in assembler)
>extern const unsigned int pointer[2];
>
>// Usage:
>const signed char *get_pointer( unsigned char index ) {
>
> return (void *)pointer[ index ];
>}
>In assenmler (i.e. wanted result):
> .area lit(rom, con, rel)
>_pointer::
> .word _sinus_tab+3
> .word _sinus_tab
>
>The first constant array (sinus_tab) is ok but the second either
>ends up in idata (initiated SRAM) or, I get error message like:
>
>cast from `pointer to const signed char' to `unsigned int' is illegal in
>constant expressions
>
>Thanx for help
>Björn Lindgren
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today it's FREE!
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>_______________________________________________
>Icc-avr mailing list
>Icc-avr at imagecraft.com
>http://dragonsgate.net/mailman/listinfo/icc-avr
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the Icc-avr
mailing list