IND/INDR/INI/INIR/OUTD/OTDR/OUTI/OTIR
I'm looking for confirmation that the official Z80 User Guide from Zilog is wrong and that these composite instructions actually change the value of B first. You'd only notice this when reading or writing from a 16-bit I/O address using one of these instructions. Also is there a test suite to see if these instructions are emulated correctly?
Post edited by chev on
Comments
The official Z80 User Guide from Zilog says the BC <- (HL), DEC B, ... and I can't find an unofficial doc that categorically states something different. I expect there are quite a few emulators out there with broken Z80 cores as a result of this.
Here it is for OTIR:
The contents of the HL register pair are placed on the address bus to select
a location in memory. The byte contained in this memory location is temporarily stored in the CPU. Then, after the byte counter (B) is decremented, the contents of register C are placed on the bottom half (A0 through A7) of the address bus to select the I/O device at one of 256 possible ports. Register B may be used as a byte counter, and its decremented value is placed on the top half (A8 through A15) of the address bus at this time
Unnecessarily wordy; my other z80 book does it more economically.
Write games in C using Z88DK and SP1
God, I'm good. :)
Ok, so the book isn't completely wrong, but the summary has resulted in at least two broken Z80 cores.
I'd agree that the example for OTDR of:
BC <- (HL), DEC B, ...
could lead one to believe it worked in the way suggested, but the Z80 Family CPU User Manual UM008005-0205 (PDF, revision 5, 2005) from zilog.com gives the operation of OTDR as:
(C) <- (HL), B <- B - 1, HL <- HL - 1
There would appear to be several different versions of the Z80 user manual, with different ways of describing the same thing, some clearer than others.
Although UM008005-0205 isn't absolutely reliable either; eg. INDR operation is given as:
(HL)<- (C), B <- 131, HL <- HL1
...
Not only that - it also affects how/when/if the contention is applied.
Patrik
instructions before."
Anyhow, this is the opposite of what the UM008005-0205 manual says.
My old Z80 manual by Rodnay Zaks (programming the z80) states that in OTIR DEC B is executed after (I understand this is wrong).
+3DOS couldn't write a disk sector without a pre-decremented B register in OUTI.
Thanks. I presume that +3 emulators that have broken Z80 cores get away with it because they don't emulate the OS at a low level?
There are other emulators that don't get that instruction right. It's really very unclear from the manual.
My copy of Rodnay Zaks (third edition) says for OTIR: "C supplies bits A0 to A7 of the address bus. B supplies (after decrementation) bits A8 to A15)" (pag. 364)
Write games in C using Z88DK and SP1
I am one of said developers, and Spiffy was one of the z80 cores to which Andrew was referring.
I can categorically state that I did RTFM, in fact not just the manual but also The Undocumented Z80 Documented. This is an easy thing to get wrong and someone who maintains some kind of technical document probably ought to do something about it. Or something.
Sure, if you read the manual in full. But if you just read the summary in another document you could be forgiven for getting it wrong.
And in summary:
IND,INDR,INI,INIR - All modify B after/post use
OTDR,OTIR,OUTD,OUTI - All modify B before/pre use
Clearly Sean Young should have stuck to acting.
He will update the document and publish it soon.