From: SourceForge.net <no...@so...> - 2004-06-17 16:25:46
|
Bugs item #974835, was opened at 2004-06-17 09:25 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=974835&group_id=599 Category: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Bug in bit logical operation. Initial Comment: #include "8051.h" unsigned char value; //-------------------------------- // This does not work..P1_2 is always 1, even if value=2... //-------------------------------- void func1() { P1_2= (value==2)? 0: ~P1_0; return; } //This Works fine( same job):- void func2() { if(value==2) P1_2=0; else P1_2= ~P1_0; return; } //=========================== The 1st function (func1())is compiled (erroneously)as below(I have removed the genxxx & peephole comments) _func1: ar2 = 0x02 ar3 = 0x03 ar4 = 0x04 ar5 = 0x05 ar6 = 0x06 ar7 = 0x07 ar0 = 0x00 ar1 = 0x01 ;E:/sdcode/Trials/trial.c:7: P1_2= (value==2)? 0: ~P1_0; mov a,_value cjne a,#0x02,00103$ ;00106$: 00107$: mov r2,#0x00 sjmp 00104$ 00103$: clr a mov c,_P1_0 rlc a cpl a mov r2,a ;<------if P1_0==1, then r2=0xfe, else r2=0xff; 00104$: mov a,r2 add a,#0xff ;<------in both cases c will be set.. mov _P1_2,c ; <-----so P1_2 will always be output as 1. ;E:/sdcode/Trials/trial.c:9: return; ; genRet 00101$: ret ;----------------------------------------------------- ------- ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=974835&group_id=599 |