Re: A82: Question
[Prev][Next][Index][Thread]
Re: A82: Question
In a message dated 98-03-28 21:15:05 EST, you write:
> f ld a,0 is the same as xor a...
> Then is ld h,0 the same as xor h???
the answer to your question is no.
xor a only works because a will always equal a...but that's pretty obvious.
recall how xor works:
bit 1 bit 2 result
------ ------ --------
0 0 0
1 0 1
0 1 1
1 1 0
and xor [whatever] xor's a by [whatever], so xor a xor's a with a. This means
xor a could also be written as xor a, a (though TASM would give you an error)
each bit is essentially xor'ed with itself, so if a was %11010010...
(bit by bit, starting at 7, which is the farthest left)
1 XOR 1 = 0
1 XOR 1 = 0
0 XOR 0 = 0
1 XOR 1 = 0
0 XOR 0 = 0
0 XOR 0 = 0
1 XOR 1 = 0
0 XOR 0 = 0
so a ends up containing %00000000. the same thing can be achieved using "sub
a" (which would more logically be written sub a, a; I think it's pretty
obvious how that works). Both are 1 byte shorter and a little bit faster than
ld a, 0 (but they both take up the same amount and are the same speed, I think
4 clock cycles). It doesn't matter which one you use.
As for xor h, that would more logically be written out as xor a, h. You XOR a
by h, and h is never affected. If h equals a, then a will be zero, but h will
still hold the original value (which can be a nice little trick if used
properly).
I _REALLY_ hope this helped because it took me a long time to type :-P
~Adamman
PS: Long time, no see (or email...) Ilya. Where have you been?
Follow-Ups: