From: <no...@so...> - 2002-09-16 17:22:25
|
Bugs item #609947, was opened at 2002-09-16 07:35 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=609947&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 inverting constants Initial Comment: The following code snippet produces the assembly code below it. It appears to NOT invert the constant value in the ELSE statement. idata unsigned char KArray[MAX_RELAY_BLK]; const unsigned char BIT_POS[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; void proc_relay_outputs( char Status) { if (Status > 0) {KArray[0] |= BIT_POS[1]; } else { KArray[0] &= !BIT_POS[1]; } } _proc_relay_outputs: ar2 = 0x02 ar3 = 0x03 ar4 = 0x04 ar5 = 0x05 ar6 = 0x06 ar7 = 0x07 ar0 = 0x00 ar1 = 0x01 push ar2 push ar3 push ar0 push ar1 ;C:\Projects\American_Technologies\F2_Source_Relay\F2_ Outputs.c 0 mov r2,dpl ;C:\Projects\American_Technologies\F2_Source_Relay\F2_ Outputs.c 44 clr c ; Peephole 159 avoided xrl during execution mov a,#(0x00 ^ 0x80) mov b,r2 xrl b,#0x80 subb a,b ; Peephole 108 removed ljmp by inverse jump logic jnc 00102$ 00107$: ; C:\Projects\American_Technologies\F2_Source_ Relay\F2_Outputs.c 46 mov r0,#_KArray mov ar2,@r0 mov dptr,#(_BIT_POS + 0x0001) clr a movc a,@a+dptr ; Peephole 105 removed redundant mov mov r3,a orl a,r2 mov r0,#_KArray mov @r0,acc ; Peephole 132 changed ljmp to sjmp sjmp 00104$ 00102$: ; C:\Projects\American_Technologies\F2_Source_ Relay\F2_Outputs.c 49 mov r0,#_KArray mov ar2,@r0 mov dptr,#(_BIT_POS + 0x0001) clr a movc a,@a+dptr ; Peephole 105 removed redundant mov mov r3,a cjne a,#0x01,00108$ 00108$: clr a rlc a ; Peephole 105 removed redundant mov mov r3,a anl a,r2 mov r0,#_KArray mov @r0,acc 00104$: pop ar1 pop ar0 pop ar3 pop ar2 ret ---------------------------------------------------------------------- >Comment By: Jesus Calvino-Fraga (jesusc) Date: 2002-09-16 10:22 Message: Logged In: YES user_id=603650 Shouldn't use the complement '~' instead of the logical not '!' on the 'and' part? Like this: else { KArray[0] &= ~BIT_POS[1]; } otherwise KArray[0] will always be set to zero. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=609947&group_id=599 |