Hi,
Just pretend it's Mel..........
Othervar=PORTB
Othervar=Othervar & $F0
Othervar=Othervar ^ $F0
Changing $0F to $F0 will check bits 4-7 instead of 0-3.
Since theese bits are on the high nibble, you must get them to the lower nibble. You can do this many ways.
Shift it right four steps........
Othervar=Othervar >> 4
or divide by 16.....
Othervar=Othervar / 16
or use the assemblerinstruction swapf.......
@ swapf _Othervar,f
If you use one of the first two you can skip the"&" stage since those bits will be lost anyway.
Othervar=PORTB
Othervar=Othervar ^ $F0
Othervar=Othervar >> 4
Personally i'd go for......
Othervar= PORTB & $F0 'Read PortB and isolate bits 4-7
Othervar= Othervar ^ $F0 'Invert bits 4-7
@ swapf _Othervar,f 'put bits 4-7 into 0-3(and vice versa)
just because it would be the fastest way to do it.
/Ingvar
Bookmarks