Re: A85: PUSH and POP


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

Re: A85: PUSH and POP



Brian Leech wrote:
> 
> 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
> >
> 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

In all this worrying about keeping this small, and not modifying the
flags after the compare instruction, why don't you do something like
this:

sub a         ; Acc=0
cp  c         ; If Acc=C, z is set.. Acc not changed.
jr  z, AddCol

Total: 4 bytes.. Does what you wanted..
-- 
* * * * * * * * * * * * * * *
*  Wolfgang Amadeus Mozart  *
* <mozart@technologist.com> *
* * * * * * * * * * * * * * *


References: