Terminal interrupts notify a program when the host terminal supplies an input byte. Start the input thread with:
$ ./emulator -terminal program.hex
For ordinary input, the terminal callback stores the byte in Emu_TermBuffer and raises a request under the emulator mutex:
Emu_MutexLock(); INT[INT_TERMINAL] = 1; Emu_MutexUnlock();
The callback first disables canonical input and echo on the host terminal. It has special handling for backtick, which prints registers, and Escape, which stops emulation; these are not ordinary guest input events.
Delivery requires an installed handler and clear terminal and global mask bits. The emulator writes cause three, allowing a shared handler to distinguish terminal input from timer or software events.
The handler reads the input register at 0xFFFFFF04. Storage is a latest-byte buffer rather than an input queue, so slow handling can lose intermediate characters. Restoring registers and using iret returns to the interrupted program with its saved status.
Source: emulator.c.