Electronic – Confused about IN/OUT architecture of z80 chip

outputpinoutpinsz80

I am reading the manual, and it's a bit complex. I can't understand the machine code encoding for the life of me, but that's not my main concern … my main concern is the address/data buses.

I do not understand the difference between the "address out" from the OUT instruction, and the port configuration as well, AND the involvement of the register data operands.

Quoted directly from the z80 manual:

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.

Question time:

1.What does "the bottom half" mean?

2.Where/what are the 256 possible ports, and how does it select one, and where does it go exactly from there?

Next quote:

If the contents of register C are 01H, and the contents of register D are 5AH,
at execution of OUT (C),D byte 5AH is written to the peripheral device
mapped to I/O port address 01H.

So if I have 1 in register C, and 90 in D, and I write OUT(C), D 90 is written to the something mapped to 1? How do I know what is mapped at 1?

PS: Also, if I have hardware at mapped address 1, where does 90 (the value represented) go to in that hardware?

Do not get me wrong by my confusion here, I am a programmer … I just have very limited experience coding at this low-level, and just need some clarification.

Best Answer

The address bus of the Z80 is 16-bits wide (bits A0 through A15), meaning it can address 65536 locations. The low 8 bits of the bus are bits A0-A7, which can address 256 locations. Each of the I/O ports connected to the Z80 has a corresponding address of 0-255 (256 total addresses). Only one port responds to a particular address.

If the contents of register C are 01H, and the contents of register D are 5AH, at
execution of OUT (C),D byte 5AH is written to the peripheral device mapped to I/O port
address 01H.

The address of the peripheral (01) will be placed on the address bus A0-A7. The contents of the D register will be placed on the 8-bit data bus, and written to the peripheral whose port number is 01.