Hi Charles,

> The first issue I am having is with SDCC's __sbit syntax.
>
> When I compile, this line:
> __sbit DB7 = P1^7;
>
> sdcc.exe returns with:
> lcd.c:31: error 2: Initializer element is not constant
>
> So after consulting some documentation it seems that the following should
> work, but does not:
> __sbit __at (P1^7) DB7 ;

Where did you find that? I'm sure it was not in the manual or on the wiki.

> If P1 is defined and included in  <8051.h> as
> __sfr __at (0x90) P1   ;
> why does __sbit __at (P1^7) DB7 ; still return with Initializer element
> is not constant?

This is incorrect and will place DB7 at the address that happens to be on
P1 xor'ed with 0x07. Luckily the compiler cannot predict the value of all
P1's of the mcu's the code will run on later and just presents you an
error.

> If i do this, it compiles:
> __sbit __at (0x90^7) DB7 ;
> but the code generated by the compiler does not work in EDSim51, yet does
> work with C51 (C51 accepts the syntax sbit DB7 = P1^7)

No idea why this would not work with EDSim51. This code is ok.

You can also just use a define:
#define DB7 P1_7

> Regards,
> Charles

Greetings,
Maarten

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to