comp.sys.sinclair FAQ

Hardware Ports

When an port is read from (with 'IN') or written to (with 'OUT'), it will activate a number of devices external to the Z80, depending on the port address. In general, devices respond if certain bits in the binary representation port number are set and/or reset, rather than to a specific port number; this is known as 'partial decoding'. Whilst this makes the decoding hardware easier to make, it does mean that a considerable amount of congestion has occured in the space available for new peripherals to respond to if they do not wish to clash with any current devices.

The next complication is to do with the Z80's I/O instructions: it is quicker and easier to select the low 8 bits of the port number than it is to select the high 8 bits; this means that, when outputting to peripherals for which the upper 8 bits make no difference, this will often be left unset, and may contain garbage. Thus, the 48K ULA, which responds to all even port addresses, is often referred to as Port 0xfe, rather than the full 16-bit port 0xfffe.

Listed below are some of the available peripherals (including those like the ULA, which are in every machine), and the bit fields to which they respond. In the table, '-' means 'don't care', '0' means the bit must be reset for the peripheral to respond, and '1' means it must be set.

All definitions shown below were provided by Erik Kunze, author of the XZX-Pro emulator.