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

compiler bug when using B and ACC

Anyone here with the same Problem?

I think that C51 V6.14 generates wrong code.

Chris


the following code

#pragma src
#include "80CL580.H"

extern handleLayer2Event( unsigned int );
//extern HandleLayer2Event( unsigned char, unsigned char );

#define EV_CHAR 0
#define EV_BADC 1

#pragma SAVE
#pragma AREGS
#pragma RB(1)

void isrHost() small
{
        CY = RB8;
        ACC = S0BUF;
        if( CY != P )
        {
            B = EV_BADC;
        }
        else
        {
            B = EV_CHAR;
        }

        handleLayer2Event( (unsigned int)B << 8 | ACC );
//        HandleLayer2Event( B, ACC );
}

#pragma RESTORE

results in

$NOMOD51

?PR?isrHost?M        SEGMENT CODE 
	EXTRN	CODE (_handleLayer2Event)
	PUBLIC	isrHost

	RSEG  ?PR?isrHost?M
isrHost:
	USING	1
	MOV  	C,RB8
	MOV  	A,S0BUF
	JNB  	P,?C0004
	CPL  	C
?C0004:
	JNC  	?C0001
	MOV  	B,#01H
	SJMP 	?C0002
?C0001:
	CLR  	A
	MOV  	B,A
?C0002:
	MOV  	R7,B
	MOV  	A,R7
	MOV  	R6,A
	MOV  	R7,A
	LJMP 	_handleLayer2Event

	END

with error in generating the unsigned int for handleLayer2Event().

Why it not generates the following.

?C0002:
	MOV  	R7,B
	MOV  	R6,A
	LJMP 	_handleLayer2Event

0