We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
$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
?C0002: MOV R7,B MOV R6,A LJMP _handleLayer2Event
The root of the problem is that you are using 80C51 registers as variables - you cannot do this in C51 compiled code. C51 does allow access to registers, but this has to be done with great care. You cannot reasonably expect to be able to use the registers in the way that you have in your code. You should write your code using conventional 'C' variables or, if speed is your goal, code the function in assembly language. You cannot have your cake and eat it!