Bit masking rules
I have not done any masking of bits for some 30 years, and it seems to me that the masking rules have changed in PBP?
My memory of this is : to mask off the high nibble of a byte, the unwanted nibble would be ANDed with "0"s and the wanted nibble would be ANDed with "1"s IE %01100101 AND %00001111 would = %00000101 that is the high nibble would be ignored while the lower nibble would be effectively unchanged. However, the way I read the manual the operation is oposite.
indata = %01011011
debug "raw data ",bin8 indata," "
outdata = indata and %11110000
indata = indata and %00001111
debug "indata ",bin8 indata," "
debug "outdata ",bin8 outdata
.....Is what I have been playing around with, but the first byte comes out correct (No modification so it should) Both the next two results come out as % 11111111
This seems to be way out of kilter with my memory of ANDing stuff with real logic gates (remember them?)
Once again I figure I'm doing something wrong, but damned if I can figure out what.
I have some stuff feeding the lower 4 bits of porta and i want to mask off the higher bits so I can come up with a straight HEX digit, but it don't appear to be working. Dammit!!
If I don't mask anything and simply debug hex1 indata it is OK, but using the whole byte is not useful as the other bits are also active with other stuff that I don't want at the time.
Another night of frustration coming up, I see.
Thanks in advance for any pointers folks.
Peter Moritz.
Up the bush, Western Plains,
New South Wales,
Australia.
Bookmarks