Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Converting bit fields

Help
2011-09-12
2013-03-12
  • Stephen Gaunt
    Stephen Gaunt
    2011-09-12

    Hi
    I am attempting to convert code written for the HiTech 8051 compiler (now unsupported) to work with SDCC

    The line (first of several)

    static __bit pa0 @ 0x90;      // PORT 1.0

    Gives this error, I already added the leading underscores to bit

    381001.c:532: syntax error: token -> '0x90' ; column 23

    Is there any way around this (or other way to assign a bit variable to  specific location)

     
  • BLRCalvin
    BLRCalvin
    2011-09-13

    Hi,

    The syntax for absolute addressing in SDCC is as below:

    __bit __at (0x02) bvar;

    Please go through the sdccman.pdf, the usermanual of SDCC for more details on syntax and example code.

    Best Regards,
    Raghunath Lolur.

     
  • Maarten Brock
    Maarten Brock
    2011-09-13

    SDCC makes a difference between a __bit and an __sbit. An __sbit lives in the SFR space above address 0x80.
    So you would need:
    __sbit __at(0x90) pa0; // PORT 1.0

    But sfr's and sbit's are usually defined in a header file for your device. Is yours not already supported by SDCC?
    Have a look in C:\Program Files\SDCC\include\mcs51\