ON 20020903@9:34:23 AM at page:
http://www.piclist.com/techref/microchip/math/bit/swap.htm
kagato-icss- added 'Says
This can be done in four instructions:
MOVF X,W (W:=X)
XORWF Y,W (W:=X^Y)
XORWF X,F(X:=((X^Y)^X)=Y)
XORWF Y,F (Y:=((X^Y)^Y)=X)
(Editors: Please remove my prior, badly formatted comment, and this note to you when you get around to it. Thank you.)'
ON 20020904@11:55:35 AM at page:
http://www.piclist.com/techref/microchip/math/bit/swap.htm
JMN-EFP-786 James Newton edited the page
ON 20020908@6:25:51 PM at page:
http://www.piclist.com/techref/microchip/math/bit/parity.htm
ywmlddqx-address- added 'Code:
; calculate 8 bit parity
; 2002-09-09T00:57:42Z
rlf rxtx,w ; (a)(b)(c)(d)(e)(f)(g)(h)
xorwf rxtx,w ; (a^b)(x)(c^d)(x)(e^f)(x)(g^h)
andlw 0xaa ; (a^b)(0)(c^d)(0)(e^f)(0)(g^h)
addlw 0x66 ; (a^b^c^d)(x)(x)(x)(e^f^g^h)(x)(x)(x)
; a0b0 + 0110 => (a^b)(x)(x)(x) x=dont care
; a=0,b=0 ; 0000 + 0110 => 0110
; a=0,b=1 ; 0010 + 0110 => 1000
; a=1,b=0 ; 1000 + 0110 => 1110
; a=1,b=1 ; 1010 + 0110 => 0000
; we do that for high & low nibbles
andlw 0x88 ; (a^b^c^d)(0)(0)(0)(e^f^g^h)(0)(0)(0)
addlw 0x78 ; (a^b^c^d^e^f^g^h)(x)(x)(x)(x)(x)(x)(x)
; a000b000 + 01111000 => (a^b)(x)(x)(x)(x)(x)(x)(x) x=dont care
; a=0,b=0 ; 00000000 + 01111000 => 01111000
; a=0,b=1 ; 00001000 + 01111000 => 10000000
; a=1,b=0 ; 10000000 + 01111000 => 11111000
; a=1,b=1 ; 10001000 + 01111000 => 00000000
; now bit#7 of w holds even parity
; use 0xf8 for odd parity: a000b000 + 11111000 => ~(a^b)(x)(x)(x)(x)(x)(x)(x)
addlw 0x80 ; put bit#7 of w in carry
'