-
Lower 4 Bits?
I am trying to "mask" or "isolate" the lower 4 bits of a byte, and having trouble.I tried using the example on page 26 of the PBP manual:
SecOnes var byte 'should be NIBBLE?
SecOnes = Seconds & $0f
This gives a "Bad Expression" error when compiling. Can someone help, please?
Thank you
-
Try-
SecOnes var byte 'should be NIBBLE?
Seconds var byte
SecOnes = Seconds & $0f
Or-
SecOnes var byte 'should be NIBBLE?
SecOnes = SecOnes & $0f
-
I forgot to add that there already is a SECONDS variable, and it still has the error. Why does it say $0f ???
-
This should not return any errors.
Code:
SecOnes var byte
Seconds var byte
SecOnes = Seconds & $0f
Of course the result will be unknown since none of the variables are initialized, but it
definitely should not return an error.
Quote:
Why does it say $0f ???
Because a value of $0F (%00001111) ANDed with another 8-bit value will return all
0's in the upper 4-bits of the result MASKing the upper 4-bits out.
-
Thank you, Bruce for the explanation. I now understand how it works. I failed to explain that I'm trying to "add-on" (within the Main portion of my program) to DT's Elapsed_INT-18. That's why I said the Seconds variable was already declared. So, when I declare it again, I get the redefinition error. I'll try adding the SecOnes stuff to HIS program!