XOR A= LD A,0

By thegeps

Expert (73)

thegeps's picture

12-12-2018, 09:52

Hi all. I know XOR A can be used instead LD A,0 and is faster. May I assume I can use XOR B too instead LD B,0 and so on?

Login or register to post comments

By gdx

Prophet (2425)

gdx's picture

12-12-2018, 10:08

No because A ⊕ A is not same as A ⊕ B.

https://www.msx.org/wiki/Assembler_for_Dummies_%28Z80%29

In addition XOR A is not exactly the same as LD A,0 because XOR A modifies the flags.

By thegeps

Expert (73)

thegeps's picture

12-12-2018, 10:59

I know XOR A modifies the flags, but I don't need them for this purpouse so they can be discarded. Now I have clear XOR usage.
I misunderstood its usage. I was sure the Xor was between a reg and itself. Now I see it's between reg and A. Thx

By konamiman

Paladin (967)

konamiman's picture

12-12-2018, 21:05

"XOR r" instructions are just shortcuts for "XOR A,r", that meaning "A = A XOR r". The same goes for AND, OR and other instructions that take only one parameter, like CP.

My MSX profile