48k Spectrum
Technical Information
ULA Input

As an input device the ULA sends data to the CPU concerning the state of the EAR input and the keyboard.

Each key on the keyboard is arranged so that when depressed a horizontal wire joins a vertical wire. The eight horizontal wires are connected to bits 8 to 15 of the address bus. The five vertical wires are connected to five pins of the CPU and are sent as bits 0 to 4 on the data bus. The vertical input lines are connected to the +5V and return a 1 when no key is pressed.

When IN 254 is read the address of the address bus is such that all of bits 8 to 15 are 0, i.e. low voltage. If a single key is pressed the vertical line it connects to the address line will be connected to a low voltage and returns 0 in the bit-pattern. To determine which of the 8 keys on the vertical line is pressed you need to set all but one of bits 8 to 15 to 1.

For example, to read the row of keys connected to address line 15 (Space, SYM SHIFT, m, n b) you set the following bit-pattern for the I/O address: 0111111111111110 which is 32766 in decimal. That is, IN 32766 will return a value that has bits 0 to 4 set according to which key was pressed. This gives us:

Bit Address Keys
15 32766 Space to b
14 49150 Enter to h
13 57342 P to y
12 61438 0 to 6
11 63486 1 to 5
10 64510 q to t
09 65022 a to g
08 65278 Caps Shift to V

Bit 6 returns the state of the EAR cassette socket. To read the state of the EAR (i.e. whether it is being played) then IN 65534 will return 255 if nothing is being played. (bit 6 to zero and the rest to 1).

Because the EAR is connected to the ULA via a low voltage capacitor, it cannot be used to monitor slowly changing voltages.


Expansion Connector
Built in I/O
ULA Output
ULA Input
System Variables
ZX Basic
I/O Streams
Video Display
Tape, Sound, Printer
Interface 1
©2002 ZeDeX82