zx_saddrpup code question

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

zx_saddrpup code question

Post by derekfountain »

Just following up here on a thread over at Spectrum Computing. The Z88DK library code for finding the Spectrum screen address above a given one is in asm_zx_saddrpup. I noticed these instructions at the bottom of that function:

Code: Select all

and $18
cp $18
What are they for?
User avatar
dom
Well known member
Posts: 2090
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

It will be to handle setting carry when it goes off screen.

H will have values from $40 to $57 in the valid exit case.

In the value range the bits corresponding to $18 can?t both be set.
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Post by derekfountain »

But the very next instruction is to clear carry...?
User avatar
dom
Well known member
Posts: 2090
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

ccf = Complement Carry Flag.

Assuming we've stepped above the screen, then h=$3f. So $3f & $18 = $18. $18 cp $18 resets carry so it needs to be flipped for carry to be set to indicate above the screen.
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Post by derekfountain »

lol... So much to learn... Thanks for the explanation. :)
Post Reply