Z80 Assembly 72: Beeper Sound and Color Control (The FEH Port)
The Combined I/O Port: FEH The ZX Spectrum uses the same I/O port address **FEH′** for multiple output functions. When you execute an OUT (FEH), A` instruction, every bit in the Accumulator (A) controls a different piece of hardware. The Output Byte Breakdown (OUT to `FEH′): Bit Function Value (If Set) Purpose 0-2 Border Color 000B - 111B Sets the color of the screen border (0=Black, 7=White). 3 Beeper Output `08H′ Toggles the speaker (0=Off, 1=On). 4 EAR Socket `10H′ Controls the tape recorder output (used for data saving/loading). 5-7 Unused N/A Ignored by the 48K Spectrum hardware. Controlling the Beeper To produce sound, you must create a fast timing loop (Part 28) that toggles Bit 3 of the output byte. ...