Undocumented 16-bit I / O Addressing on the Z80

From Zilog on the Z80, I notice that with the instructions of the I / O group (IN and OUT), the contents of various registers are often placed in the upper 8 bits of the address bus (depending on the command), with the lower 8 bits choosing one of 256 theoretically connected devices.

My question is what needs to be done with these top 8 bits? I know that some machines use this in something related to decreasing the complexity of decoding, but are they seriously used for anything? I want to implement the instructions in the same way that the Z80 offers, but I see no reason to implement this behavior, since it is non-standard. This behavior is described as undocumented, therefore, for example, in the "Master Sega System", will I get away with it? Many thanks.

Regards, Phil Potter

+6
source share
3 answers

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

I suggest that some peripherals may use the upper bits of the A8..A15 address bus as a kind of 8-bit parameter.

+5
source

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

+2
source

In ZX Spectrum, the keyboard can only be read by reading from the 0xfe port, while the highest 8 address lines select one of 8 groups of 5 keys. For example, if you want to scan the Q , W , E , R, and T keys, the top 8 bits of the address bus should be 0xfb :

ld bc,#fbfe in a,(c) ; reading from port 0xfe while upper 8 address lines are 0xfb 

This is exactly the same as:

  ld a,#fb in a,(#fe) ; reading from port 0xfe while upper 8 address lines are 0xfb 

Some arcade machines of the 80s communicate with additional equipment, outputting more than 8 bits at a time with one out instruction - additional bits are read from the upper address lines.

0
source

Source: https://habr.com/ru/post/903782/


All Articles