Ernst Bachmann wrote:
> On Mittwoch, 18. Juli 2007, sdcc@... wrote:
>
>> I have a problem where i couldnt find a clear answer in the manual/list.
>> I want to initialize an 4x4 array like:
>>
>> char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
>> but this only works if i add the code keyword infront of it. If code is
>> omitted the array does not work.
>> Is this the intended behavior? or am i doing something wrong?
>>
>> sdcc -v: SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
>> device: pic18f2550
>
> Well, that pic should have enough ram for the array, but:
>
> if the Array is in RAM, the startup code has to initialize it by copying the
> values from Flash.
> That is usually done by the initialization code in crt0iz.o, which should be
> linked automatically.
> There are however also other versions of that init code available (crt0i.o,
> crt0.o) which skip the variable initialization in order to save code space.
yes crt0.z was used in my Makefile since i had some startup problem for
the USB Code with crt0i(z) while ago. It seems all to rune fine now with
crt0iz.
So what/where is the prefered location for putting arrays/structs
1. without any option?
2. with the code option?
3. or with the #pragma udata ... option?
thx allot for your effort.
jan

On Mittwoch, 18. Juli 2007, sdcc@... wrote:
> I have a problem where i couldnt find a clear answer in the manual/list.
> I want to initialize an 4x4 array like:
>
> char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
> but this only works if i add the code keyword infront of it. If code is
> omitted the array does not work.
> Is this the intended behavior? or am i doing something wrong?
>
> sdcc -v: SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
> device: pic18f2550
Well, that pic should have enough ram for the array, but:
if the Array is in RAM, the startup code has to initialize it by copying the
values from Flash.
That is usually done by the initialization code in crt0iz.o, which should be
linked automatically.
There are however also other versions of that init code available (crt0i.o,
crt0.o) which skip the variable initialization in order to save code space.
Check your makefiles if you're linking the right one.
/Ernst

hi
it mite be possible that the capacity of UC's SRAM is low to store a hole
program in it so when u add word "CODE" in front of it the part of code
gets store in Flash memory of ur UC...
On 7/18/07, sdcc@... <sdcc@...> wrote:
>
> Hello,
>
> I have a problem where i couldnt find a clear answer in the manual/list.
> I want to initialize an 4x4 array like:
>
> char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
> but this only works if i add the code keyword infront of it. If code is
> omitted the array does not work.
> Is this the intended behavior? or am i doing something wrong?
>
> sdcc -v: SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
> device: pic18f2550
>
> thx allot in advance
>
> jan
>
>
>
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@...
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
--
Regards-----
Abhishek..
(M)+91 9820475899
(O)+91 22 25720700
http://www.triindia.co.inhttp://abhishekworld.wordpress.com/http://www.flickr.com/photos/abhishekworld/
/********************************************************************************/
"Imagination is more important than knowledge..." Albert Einstein
/********************************************************************************/

Hello,
I have a problem where i couldnt find a clear answer in the manual/list.
I want to initialize an 4x4 array like:
char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
but this only works if i add the code keyword infront of it. If code is
omitted the array does not work.
Is this the intended behavior? or am i doing something wrong?
sdcc -v: SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
device: pic18f2550
thx allot in advance
jan