PIC Microcontoller Bit Math Method

Copy unaligned bits from one register to another:

With possibility of "jitter" on destination pin

	setb	RA.4
	sb	C
	clrb	RA.4

ie: Assume the bit is one, then change to 0 if it is not. A C/C++ macro for Hitech C is available

Saves 1 instruction over the more standard:

With possibility of error due to change in value on source pin

	snb	C	; load the data
	setb	RA.4
	sb	C
	clrb	RA.4

This macro...

COPY_BIT     MACRO   var_A,bit_N,var_B,bit_M
        NOEXPAND
	snb	var_A.bit_N
	setb	var_B.bit_M
	sb	var_A.bit_N
	clrb	var_B.bit_M
        ENDM

remember to define the dummy macro variables:
var_A	equ	0
bit_N	equ	0

...will produce the same output if called like this:

COPY_BIT STATUS,C,PORTA,4

but can be used on any current bank registers.