NASM Forum > Programming with NASM

Use of XOR

(1/2) > >>

JohnG:
Hi all,

What is the purpose of the code line     XOR  EAX,EBP  ?

Have found some explanation of it, but they differ and do not explain it well.


John

debs3759:
XOR performs a bitwise XOR operation between its two operands (i.e. each bit of the result is 1 if and only if exactly one of the corresponding bits of the two inputs was 1), and stores the result in
the destination (first) operand.

So if a bit is 0 or 1 in both operands, it will be set to 0 in EAX, otherwise it will be set to 1. The purpose depends on the rest of the nearby code (ie what EAX and EBP were previously set to, and what your code is going to do with the result)

JohnG:
Hi,

Thanks for the quick response,   if both operands are just hex values ok,  but if they are memory addresses  ?

John

Frank Kotler:
Hi John,

Thanks Debs.

XORing two memory addresses seems a bit unlikely. Can we see some context?

Best,
Frank

debs3759:
As Frank says, it seems unlikely to be XORing two memory addresses. If you can provide a few lines of code either side of the instruction, it might help us understand what the code is trying to do.

Navigation

[0] Message Index

[#] Next page

Go to full version