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

Bug report on C251

Source code:

temp = RS232_OutQueue[OutQRdCounter];       /* Get the byte. */

        if (ParityFlag != RS232_PARITY_NONE)        /* check  to see if parity is required    */
        {
            ACC = temp;                         /* stuff a byte into the ACC to set the parity bit. */
            if (ParityFlag == RS232_PARITY_ODD)     /* ODD of EVEN parity */
            {
                TB8 = ~P;                           /* Load parity transmit bit. */
            }
            else
            {
                TB8 = P;                            /* Load parity transmit bit. */
            }
        }
        SBUF = temp;                                /* Load the tx buffer */

Assembly code generated by C251:
0001AF E500        R  MOV      A,OutQRdCounter
0001B1 0A3B           MOVZ     WR6,R11       ; A=R11
0001B3 09A30000    R  MOV      R10,@WR6+RS232_OutQueue
;---- Variable 'temp' assigned to Register 'R10' ----
                                             ; SOURCE LINE # 513
0001B7 7EB30000    R  MOV      R11,ParityFlag
0001BB 6011           JZ       ?C0035
                                             ; SOURCE LINE # 515
0001BD 7AA1E0         MOV      ACC,R10
                                             ; SOURCE LINE # 516
0001C0 B40107         CJNE     A,#01H,?C0036 ; A=R11
                                             ; SOURCE LINE # 518
0001C3 A2D0           MOV      C,P
0001C5 B3             CPL      C
0001C6 929B           MOV      TB8,C
                                             ; SOURCE LINE # 519
0001C8 8004           SJMP     ?C0035
               ?C0036:
                                             ; SOURCE LINE # 522
0001CA A2D0           MOV      C,P
0001CC 929B           MOV      TB8,C
                                             ; SOURCE LINE # 523
                                             ; SOURCE LINE # 524
               ?C0035:
                                             ; SOURCE LINE # 525
0001CE 7AA199         MOV      SBUF,R10

Notice that at the second testing of the ParityFlag (cjne A, #01H, ?C0036), ACC is holding the temp, not ParityFlag any longer.

This is easy to go around it, but it still is a bug!

0