Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - flags with I/O block instructions

Reply to topic
Author Message
  • Joined: 03 Aug 2017
  • Posts: 61
  • Location: Munich
Reply with quote
flags with I/O block instructions
Post Posted: Sun Jul 21, 2019 11:58 am
Hi there,

I'm trying to figure out how the Z80's status flags change with I/O block instructions (OUTI etc.)
Unfortunately I don't have a working Z80/SMS debugging-environment.

All my books and Zilog's documentation state that the C flag is unaffected, P, S and H are "unknown" for most instructions, N is unaffected (some instructions), set to 0 (IN r, (C)) or 1 (many output instructions).

For the "unknown" flags I looked into Sean Young's "The Undocumented Z80 Documented", namely the chapter "4.3 I/O Block Instructions". There I find all the answers for these flags, but nevertheless this is where my confusion begins:

1. Sean writes, the N flag is a copy of bit 7 of the value read from or written to an I/O port. This contradicts the Z80 documentation (see above).

2. Sean goes on to state H and C both are set if ((HL) + L > 255) (for output instructions, input instructions have 2 different conditions). This may be correct for the H flag (which is "unknown" according to Zilog), but the C should always be unaffected.

(as with H, determination of P and S may be as stated, they at least don't conflict with "unknown")

Can anyone help me with this?
Block transfer instructions (CPIR etc.) should work the same (no funny algorithm for N and C).


Bye
  View user's profile Send private message
  • Joined: 03 Aug 2017
  • Posts: 61
  • Location: Munich
Reply with quote
Post Posted: Wed Jul 24, 2019 11:01 pm
Hi again,

chapter 7 of Sean's documents seems to address most (all?) of my confusion. Seems, that I have a very flawed official documentation (found a lot of mistakes besids those mentioned by Sean) and my three Z80-books also get many flags wrong.

Did the Z80 flag behaviour change over the years?

Bye
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!