AnsweredAssumed Answered

strange bit variable code generation

Question asked by r zd on Jan 29, 2008
Latest reply on Feb 16, 2008 by r zd

hello
I have C code like this
#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE
...
struct {
u8 one:1;
u8 two:1
}alm;
#pragma DATA_SEG DEFAULT_RAM

void fun1(void)
{
...
alm.one = alm.two;
alm.one = PTAD_PTAD0;
...
}
and CW translate fun1 to:

343: alm.one = alm.two;
0000 020003 [5] BRSET 1,alm,L6 ;abs = 0006
0003 1100 [5] BCLR 0,alm
0005 65 [3] SKIP2 L8 ;abs = 0008
0006 L6:
0006 1000 [5] BSET 0,alm
0008 L8:
344: alm.one = PTAD_PTAD0;
0008 b600 [3] LDA _PTAD
000a a401 [2] AND #1
000c 2603 [3] BNE L11 ;abs = 0011
000e 1100 [5] BCLR 0,alm
0010 65 [3] SKIP2 L13 ;abs = 0013
0011 L11:
0011 1000 [5] BSET 0,alm
0013 L13:

my question is why PTAD_PTAD0 is not same as alm.two?

Outcomes