[A83] Re: ex af,af'


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

[A83] Re: ex af,af'




> What is the difference between
> 
>    push af
>    ld a,d
>    lcddata
>    pop af
> 
> and:
> 
>    ex af,af'
>    ld a,d
>    lcddata
>    ex af,af'
> 
If the lcddata part depends on the initial value of the 
flags register and/or it uses the ex af,af' instruction 
somewhere, the routine is likely to give wrong results. You 
have to keep in mind that the stack is a (normally) safe 
place, but the shadow registers aren't. The most important 
difference is that when you're "saving" af, both a and f 
will be altered if you use "ex af,af'", as opposed to
"push af", which changes only sp and (sp), but preserves 
the old values of a and f.

PG




Follow-Ups: References: