Hi Grissiom,

Thanks for the fast reply. It's pretty clear now. Bit operation works
only if the register address is multiple of 8.

Regards,
Zafi.

On Sun, Aug 7, 2011 at 3:44 PM, Grissiom <chaos.pro...@gmail.com> wrote:
> Hi Zafi,
>
> On Sun, Aug 7, 2011 at 9:27 PM, Zafi Ramarosandratana <zram...@gmail.com> 
> wrote:
>> Hello,
>>
>> __sbit is heavily used in the mcs51 include files of sdcc.
>> My understanding is that __sbit selects a specific bit from a
>> register. For example, __sbit at (0x83) P0_3 means P0_3 is bit 3 of
>> register 0x80.
>>
>> With the following C source file:
>>
>> #include <8051.h>
>>  main()
>> {
>>   P0_3 = 1; // set bit 3 of P0 to 1
>>   P0_5 = 0; // set bit 5 of P0 to 0
>>   return 0;
>>  }
>>
>>  the generated asm file contains:
>>  ...
>>  _P0_3=0x0083
>>  _P0_5=0x0085
>>  ...
>>  setb _P0_3
>>  clr _P0_5
>>  ...
>>
>> I don't think that the generated asm instructions do the expected
>> operation. I may probably miss something obvious.
>> I'm running sdcc mcs51 3.0.3 #6571.
>>
>
> No. AFAIK, bit operation and byte operation have different address
> space in mcs51. So CLR 0x85 means clear the 6th bit of register 0x80,
> SETB 0x83 means set the 4th bit of register 0x80.
>
> I think that's why you could only do bit operations on the registers
> whose addresses must be a division of 8.
>
> --
> Cheers,
> Grissiom
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to