I'm solving one of the assembler questions and I stumbled upon one with logic aspect. The thing that makes me thinking is that after changing the numeral system from HEX to BIN and making a negation and AND operations I got a different answer than other person (which I cannot contact).
MOV eax, 0f0f0f0f0h;
MOV edx, 87654321h;
NOT ax;
INC dx;
AND edx, eax;
I was expecting an output to be like this: 80604020h which is one of the answers, but the other person made a decision and answered: 80600302h which for me doesn't make a sense after doing the math. I'm still new in assembly so I may not know what is wrong, can someone explain what is wrong with my answer, or is it a correct one?
Let's take this one instruction at a time. The NOT ax
will change EAX from
0F0F0F0F0
to
0F0F00F0F
since AX is the lower 16 bits of EAX. Then the INC dx
will change EDX from
87654321
to
87654322
The AND edx,eax
instruction will then combine them
0F0F00F0F
& 87654322
= 80600302
Which makes your friend's answer correct.
If the NOT instruction was NOT EAX
, then the answer would be 07050302.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.