This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to define a bit variable at a specific bit location?

Hi,

I'm trying to define a bit variable at a specific bit location.

I tried the following without succes:

       BSEG AT 02FH.7
MYBIT: DBIT 1
The linker complains with
*** ERROR L107: ADDRESS SPACE OVERFLOW
SPACE: BIT
SEGMENT: ?BI??TEST?1
LENGTH: 000000H.1

The following works but the linker is assigning the address (and that is not what I want):
TEST_BIT SEGMENT BIT
       RSEG TEST_BIT
MYBIT: DBIT 1

Or I could assign the whole byte and then target the bit that I want (but then I have 7 unused bits):

       DSEG AT 02FH
MYBIT8: DS 1
sbit MYBIT=MYBIT8^7;

Shouldn't the first version work?

Geert

  • I have never tried this, but it could be that BSEG needs a regular numeric address like this:

           BSEG AT 07FH
    MYBIT: DBIT 1
    

  • Or I could assign the whole byte and then target the bit that I want (but then I have 7 unused bits):
    Not if you do


           DSEG AT 02FH
    MYBITB8: DS 1
    sbit MYBITF8=MYBITB8^0;
    .....
    sbit MYBITFf=MYBITB8^7;
    

    or you could just do
    sbit MYBIT 0f8h;

    Erik

  • Graham,

          BSEG AT 07FH
    MYBIT: DBIT 1
    

    Yes, that is also a valid syntax, but that didn't work either :(

    Geert

  • Erik,

           DSEG AT 02FH
    MYBITB8: DS 1
    sbit MYBITF8=MYBITB8^0;
    .....
    sbit MYBITFf=MYBITB8^7;
    
    This is also a valid option, but this way I have 7 unused bits which will not be used anymore for assignment by the linker, and I don't want to wast bits ;-)

    sbit MYBIT 0f8h;
    
    This will not stop the linker for re-assigning this bit to another bit variable. (Or am i wrong here?)

    According to the A51-documentation (P112) the declaration should however work with BSEG AT:
    BSEG AT 30h ; absolute bit segment @ 30h
    DEC_FLAG: DBIT 1 ; absolute bit
    INC_FLAG: DBIT 1
    
    The syntax is indeed correct, but is there something more to do to avoid the link error?

    Geert

  • The syntax is indeed correct, but is there something more to do to avoid the link error?
    BSEG AT 30h ; absolute bit segment @ 30h

    yes, locating the BSEG withinthe bit addressable area.

    Erik

  • Erik,

    I was using the LX51 linker.
    It looks like I have to define the address once more in the user segments to get it linked :

    ?BI??TEST?1(0x2F)
    
    Looks strange to me to repeat the address information for the linker.

    When I use the BL51 linker, it links ok without specifying any link option.

    Thank you for your time,

    Geert