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.
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 */
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
Yes, you are right. If the ParityFlag was declared as volatile, the compiler would reload ACC with it before checking. But, the parity bit P also changes as the consequence. Therefore, the parity is not for the variable temp, but for the ParityFlag.