[Sdcc-user] Bug in static local variable

2011-02-21 Thread Krishnendu Chatterjee
Dear All, Consider the following code: - struct S1 { char a, b, c; }; typedef void (*foo_t)(void *arg); struct S2 { __xdata void *p; foo_t f1, f2, f3; }; void foo1 (void *arg) {arg;} void foo2 (void *arg) {arg;} void foo3 (void *arg) {ar

Re: [Sdcc-user] Bug in static local variable

2011-02-21 Thread Krishnendu Chatterjee
Thanks Maarten. I have posted it as a bug in the tracker system. Krish On Mon, Feb 21, 2011 at 10:50 PM, Maarten Brock wrote: > Hi Krish, > > Instead of posting this to the other users, it is better to file this as a > bug report in the SDCC tracker system. Otherwise it runs a great risk of > be

Re: [Sdcc-user] error 2:Initializer element is not constant?

2011-03-22 Thread Krishnendu Chatterjee
Hi Donald, The keyword 'sbit' is used to define special function bits, much like the keyword 'sfr' for the special function registers. The good news is that most of the SFRs in 8051 are already defined in <8051.h> Thus to set the 4th bit of PORT-2 to 0, use the following code: #include <8051.h>

Re: [Sdcc-user] error 2:Initializer element is not constant?

2011-03-22 Thread Krishnendu Chatterjee
Hi Donald, I am trying to re-clarify the concept of __sfr and __sbit. The statement '__sfr __at 0x9A MY_SFR' means that a new SFR is declared at 0x9A which is identified by the name MY_SFR in this program. However, this does not mean that MY_SFR.0 or MY_SFR_0 can be used to access the 'bit 0' of

Re: [Sdcc-user] error 2:Initializer element is not constant?

2011-03-23 Thread Krishnendu Chatterjee
Thus next time I'll check the <.h> file to find out the > specific register name of machine in SDCC. >   Now I really want to know what SDCC compile flow is.How a c code become to > be a assembly code,even the machine code? >   What is the differences between SDCC and GCC? &

Re: [Sdcc-user] error 2:Initializer element is not constant?

2011-03-23 Thread Krishnendu Chatterjee
Hi Doland, The program is perfectly fine. The simulation is producing the expecting result as well. How are you simulating the program? You should not call the assembler or linker explicitly. Let it be called by sdcc itself. Krish On Wed, Mar 23, 2011 at 10:26 PM, duck donal wrote: > Hi roelof

Re: [Sdcc-user] another 'error 2: Initializer element is not constant' case

2011-04-05 Thread Krishnendu Chatterjee
Strange :( Same here with sdcc-3.0.0. Should be reported as a bug. However, it is not severe. You can always remove the type-casting and successfully compile your code. Krish On Tue, Apr 5, 2011 at 9:40 AM, Bob Frankel wrote: > consider the following program, which initializes a static structur

Re: [Sdcc-user] overflow in supposed to be unsigned long

2011-05-05 Thread Krishnendu Chatterjee
Hi, My solution would be: #include union U8x4_n_U32 { uint8_t u8[4]; uint32_t u32; }; union U8x4_n_U32 u8x4_n_u32; // uint32_t to array of uint8_t conversion u8x4_n_u32.u32 = 0xA0459201; /** ** Now you can access the individual bytes as ** u

Re: [Sdcc-user] overflow in supposed to be unsigned long

2011-05-05 Thread Krishnendu Chatterjee
011 09:10, schrieb Krishnendu Chatterjee: > > Hi, > > > > My solution would be: > > > > #include > > > > union […] > > This seems to be the best so far, but none of the presented "solutions" > from this thread is portable or good C. He

Re: [Sdcc-user] overflow in supposed to be unsigned long

2011-05-05 Thread Krishnendu Chatterjee
ds in a union or a struct or the position of bytes in > a long int. > > Maarten > > > Am 05.05.2011 09:10, schrieb Krishnendu Chatterjee: > >> Hi, > >> > >> My solution would be: > >> > >> #include > >> > >> union [

Re: [Sdcc-user] MOVX

2011-07-09 Thread Krishnendu Chatterjee
I agree with Maarten. The XRAM initialization code is always included, but is not executed at runtime. I suggest to use s51 or any other 8051 simulator to verify this. Regards, Krish On Sat, Jul 9, 2011 at 10:31 AM, Maarten Brock wrote: > Hi Charles, > > As Frieder pointed out this code you see

Re: [Sdcc-user] Puts function not working correctly ?

2011-11-06 Thread Krishnendu Chatterjee
s_lcd (char *s) > >{ > >REG_SEL=1; > > > >while (*s) > >{ > >lcd_command(*s++); > >} > > > >REG_SEL=0; > >} > > -- > Jason White > > > -- > RSA(R) Conference 2012 > Save $700 by Nov 18 > Regi

[Sdcc-user] SDCC-3.2.0, 8051 port, problem with inline function.

2012-09-05 Thread Krishnendu Chatterjee
Hi folks, I am facing some problem using inline functions on mcs51 port. Consider the following code: #include int n[10]; inline int *address (void) { return &n[0]; } inline int size (void) { return sizeof (n); } void main (void) { memset (address(), 0, size()); } When it is compiled wi