Redwood Shores, 6 januari 2009. Dear Harry, They are using the ^-XOR to undo the modification they made to the source variable in the previous xorlw. So the value in W is modified by the check, and by adding the previous value to the next check using ^, it undoes this damage while doing the next check at the same time. I can imagine writing code like this, although with this amount of values I'd probably opt for a jump table instead (if the memory was available). I certainly would've added more comments about what was happening especially in the beginning. Greetings, Maarten Hofman. 2009/1/6 Harry H. Arends > Part of code: > =============================================== > FindCV: > bcf NOCV > bcf RDONLY > xorlw 0x00 ; CV513 > btfsc STATUS,Z > retlw PRIM_ADDR0 > xorlw (0x00 ^ 0x08) ; CV521 > btfsc STATUS,Z > retlw PRIM_ADDR1 > xorlw (0x08 ^ 0x1C) ; CV541 > btfsc STATUS,Z > retlw CVAR_29 > xorlw (0x1C ^ 0x02) ; CV515 > btfsc STATUS,Z > retlw MAX_BRIGHT > xorlw (0x02 ^ 0x03) ; CV516 > btfsc STATUS,Z > retlw E_CV516 > xorlw (0x03 ^ 0x04) ; CV517 > btfsc STATUS,Z > retlw E_CV517 > xorlw (0x04 ^ 0x05) ; CV518 > btfsc STATUS,Z > retlw E_CV518 > xorlw (0x05 ^ 0x20) ; CV545 > btfsc STATUS,Z > retlw E_CV545 > xorlw (0x20 ^ 0x21) ; CV546 > btfsc STATUS,Z > retlw E_CV546 > bsf RDONLY > xorlw (0x21 ^ 0x06) ; CV519 > btfsc STATUS,Z > retlw MFG_VR_CODE > =================================================== > This routine is called with the actual CV value in w eg CV513=0x00 and > CV519=0x06 > > > -----Oorspronkelijk bericht----- > > Van: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] > > Namens Olin Lathrop > > Verzonden: dinsdag 6 januari 2009 22:07 > > Aan: Microcontroller discussion list - Public. > > Onderwerp: Re: [PIC] xorlw question > > > > Harry H. Arends wrote: > > > Could someone explain this construction to me. > > > I looked in the MPASM help file but cant find a description. > > > > > > xorlw (0x05 ^ 0x20) ; CV545 > > > > The "^" is documented in the manual, so I guess you're asking > > why someone would do this? To answer that, we need to see a > > few more lines around this one. > > > > > > ******************************************************************** > > Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products > > (978) 742-9014. Gold level PIC consultants since 2000. > > -- > > http://www.piclist.com PIC/SX FAQ & list archive View/change > > your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist