I have a question on the AND instruction in 64-bit mode. I have this manual telling me that the AND 32-bit immediate is to be sign-extended to 64-bit. But I can't do this
Which is ridiculous I think because 0x800000 is a perfect DWORD operand. The highest I can go with it is
So what's happening here? I can't use MSb=1 to sign-extend an operand? If so, then how's sign-extension is supposed to work against an operand without being able to use it as in 0x80000000?
Thanks for you replies.
“by preventing people from doing something stupid, you might prevent them from doing something clever”: an attitude born of respect and humility; you don’t know all the answers, so don’t impose random stupidity like Jester pointed out in the comments.
fwiw, gcc / gnu as understands:
and $0x80000000, %rax
clang, religiously infused, insisted upon:
and $0xffffffff80000000, %rax
now, quick, are there enough f’s there? Does this help readability? If you don’t understand sign extension, how much assembly are you going to understand anyways?
User contributions licensed under CC BY-SA 3.0