Hi Al (and gang),
Can you better explain what you're trying to do, please? For example, are you trying to take bits b3..b0 in "varA" and copy them to PORTX bits RX3..RX0 and then copy bits b3..b0 in "varB" to PORTX bits RX7..RX4? It so, can you rely on "varA" and "varB" containing only 4 bits of data and simply combine them and write a single byte to PORTX which contains all 8 bits of data?
If you're doing something else, you could always move the 'source' bits into the proper 'target' bit position and then use XOR and AND instructions to copy them to the target. Here's an (assembler) example;
Code:
;
; copy "varA" b3..b0 to PORTX b7..b4
;
swapf varA,W ; move b3..b0 to b7..b4
xorwf PORTX,W ; differences, hi or lo
andlw b'11110000' ; don't change target b3..b0
xorwf PORTX,F ; apply new b7..b4 bits
Bookmarks