Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undocumented 16-bit I/O addressing on Z80

I notice from the Zilog datasheet on the Z80 that with the I/O (IN and OUT) group of instructions, the contents of various registers are often placed in the top 8 bits of the address bus (depending on the instruction), with the lower 8 bits selecting one of up to 256 theoretically connected devices.

My question is what is the point of doing this with these upper 8 bits? I know some machines use this in someway related to decreasing decoding complexity, but are they seriously used for anything? I want to implement the instructions exactly as the Z80 suggests, but I don't see the point in implementing this behaviour as it is non-standard. This behaviour is described as undocumented, so on a 'Sega Master System' for example, will I get away with this? Many thanks.

Regards, Phil Potter

like image 581
PhilPotter1987 Avatar asked Dec 14 '11 16:12

PhilPotter1987


2 Answers

The behavior is fully documented by Zilog (pages 269-287).

I guess that some peripherials may use the upper bits A8..A15 of the address bus as a sort of 8-bit parameter.

like image 159
gusbro Avatar answered Nov 12 '22 02:11

gusbro


Some systems use the upper 8 bits as the address and the lower 8 bits as the parameter. The Amstrad CPC is the main example. This makes OUT (C),r almost the only usable instruction, although of course it now acts actually as OUT (B),r; C is often used as the parameter for convenience. The corollary is that OUT (n),A becomes almost completely useless, unless you happen to want to send 0x34 to port 0x34, etc.

like image 29
Daniel Avatar answered Nov 12 '22 01:11

Daniel