Re: A85: PUSH and POP


[Prev][Next][Index][Thread]

Re: A85: PUSH and POP



At 09:30 PM 8/26/97 -0500, you wrote:
>Also, I an using a for my pinter in my matrice, sorry I forgot to say
>this earlier!  Well, I xor a or ld a,0 (same thing right?) and then I
>push af so I can load my c which is my y cordinate into a to compare and
>see if the rows need to increase any!  Well, here is what I do
>
>ld a,0
>push af
>ld a,c
>cp 0
>pop af
>jr z,AddCol
>
>When I pop af, I don't reset my z terminated thing do I?  If so, this is
>where my bug is!
>

The f register is the flag register; its value depends on the result of the
last operation, (if it was zero, if it had a carry, etc.).  When you pop
af, you are resetting the flags to what they were when you pushed af, which
means the zero flag does not reflect the result of cp 0.  You could just
eliminate the pushing and popping:

ld a,c
cp 0
ld a,0
jr z,AddCol

The ld instruction does not modify the flags.  However, ld a,0 is two
bytes, whereas xor a, or sub a, is only one but modify the flags.

--
Brian Leech
butvis@mindspring.com
ICQ UIN: 1355611
World Wide Web Pager: http://wwp.mirabilis.com/1355611



Follow-Ups: References: