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

Is this a C51 bug?

struct tag
{
    char a:7;
    char b:1;
};

unsigned char foo(void)
{
    struct tag test;

    test.b = 1;

    return test.b;
}

void main(void)
{
    char dat;

    if(foo() == 1)// ***foo return 0x80 not 0x01
    {
        dat = 2;
    }
    while(1);
}

17: void main(void) 18: { 19: char dat; 20: 21: if(foo() == 1)
C:0x000F 12001A LCALL foo(C:001A)
C:0x0012 BF0103 CJNE R7,#0x01,C:0018 22: { 23: dat = 2;
C:0x0015 750802 MOV 0x08,#0x02 24: }
C:0x0018 80FE SJMP C:0018 8: unsigned char foo(void) 9: { 10: struct tag test; 11: 12: test.b = 1; 13:
C:0x001A 430980 ORL 0x09,#P0(0x80) 14: return test.b;
C:0x001D E509 MOV A,0x09
C:0x001F 5480 ANL A,#P0(0x80)
C:0x0021 FF MOV R7,A 15: }

Parents Reply Children
No data