XOR A= LD A,0

By thegeps

Paragon (1167)

Аватар пользователя thegeps

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

By gdx

Enlighted (6071)

Аватар пользователя gdx

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

Paragon (1167)

Аватар пользователя thegeps

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

Paragon (1190)

Аватар пользователя konamiman

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.