ON 20081008@5:23:06 AM at page: http://www.piclist.com/techref/microchip/math/bit/mask.htm#39729.224375 [mark_jeronimus-gmail-] Code:
Still, a simple table lookup or 8-bits is less instruction cycles and doesn't need a temp register.

And it can do a little math too (set bit 7-WREG instead of bit WREG)

GET_BIT
	ADDWF	PCL,F
	RETLW	B'00000001'
	RETLW	B'00000010'
	RETLW	B'00000100'
	RETLW	B'00001000'
	RETLW	B'00010000'
	RETLW	B'00100000'
	RETLW	B'01000000'
	RETLW	B'10000000'

GET_BIT2
	ADDWF	PCL,F
	RETLW	B'10000000'
	RETLW	B'01000000'
	RETLW	B'00100000'
	RETLW	B'00010000'
	RETLW	B'00001000'
	RETLW	B'00000100'
	RETLW	B'00000010'
	RETLW	B'00000001'
ON 20081008@5:38:33 AM at page: http://www.piclist.com/techref/microchip/math/bit/index.htm#39729.2351041667 [mark_jeronimus-gmail-] Code: /techref/microchip/math/bit/shift4.htm
Shift by 4 bits at a time
ON 20081008@5:42:30 AM at page: http://www.piclist.com/techref/microchip/math/bit/shift4.htm#39729.2378472222 [mark_jeronimus-gmail-] Code:
This will shift an array of values to the right by 4 bits, filling the leftmost nibble with zeroes.

Example:
Before:
  Temp3 = 12h
  Temp2 = 34h
  Temp1 = 56h
  Temp0 = 78h
After:
  Temp3 = 01h
  Temp2 = 23h
  Temp1 = 45h
  Temp0 = 67h

It can be extended to any length and shofting to the left works on the same principle.

	SWAPF	TEMP0,W
	ANDLW	0x0F
	MOVWF	TEMP0

	SWAPF	TEMP1,W
	MOVWF	TEMP1
	ANDLW	0xF0
	IORWF	TEMP0,F
	MOVLW	0x0F
	ANDWF	TEMP1,F	

	SWAPF	TEMP2,W
	MOVWF	TEMP2
	ANDLW	0xF0
	IORWF	TEMP1,F
	MOVLW	0x0F
	ANDWF	TEMP2,F	

	SWAPF	TEMP3,W
	MOVWF	TEMP3
	ANDLW	0xF0
	IORWF	TEMP2,F
	MOVLW	0x0F
	ANDWF	TEMP2,F	

	...
ON 20081008@5:44:37 AM at page: http://www.piclist.com/techref/microchip/math/bit/index.htm#39729.2351041667 [mark_jeronimus-gmail-] Replied to post 39729.2351041667 by mark_jeronimus-gmail- |Insert 'hmm how do I add a page the right way?' at: '' mark_jeronimus-gmail- shares this code: " /techref/microchip/math/bit/shift4.htm
Shift by 4 bits at a time
" ON 20081008@1:57:12 PM at page: http://www.piclist.com/techref/microchip/math/bit/index.htm#39729.2393171296 James Newton[JMN-EFP-786] removed post 39729.2393171296 |Delete 'mark_jeronimus-gmail- replies: hmm how do I add a page the right way?

' ON 20081009@6:20:34 AM at page: http://www.piclist.com/techref/microchip/math/bit/shift4.htm# [mark_jeronimus-gmail-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\bit\shift4.htm&version=1