I am trying to do
and eax, 0fh
and I know 0fh
means 15
.
From
and eax, 0fh
I am supposed to clear all but the last 4 bits of eax
. I don't understand how you get (32-4)=28 bits of 1 and 4 0s.
15 in binary is 1111
(in facts 15=8+4+2+1); adding the padding zeroes to reach 32 bits (the width of eax
) we get
00000000000000000000000000001111
Now, if you do a binary and
with the content of eax, obviously you clear all the bits of eax
but the last 4, since the zeroes "kill" whatever digit is in the corresponding position, while the ones let it "survive".
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx AND
00000000000000000000000000001111
----------------------------------------
0000000000000000000000000000xxxx