interrupts and asynchronous events
.. Programming for Asynchronous Events: Interrupts
emu: about interrupts
Interrupts ========== When a hardware component (ex: a peripheral device) needs CPU attention, the controller associated with this component: 1. sends Interrupt Request (INTR) signal to the CPU 2. puts Interrupt Number (0 to FFh) on data bus CPU uses interrupt number to index into interrupt vector table (IVT) Each entry of this table is called an interrupt vector Each entry contains address of Interrupt Handler (ISR) CPU transfers control to the corresponding ISR Interrupt returns with an IRET

.. Interrupts
Allows the program to "call" 1. the operating system 2. the BIOS The program uses functionality already present to accomplish tasks that may be quite complex.
Example: INT 21h / AH=2 - write character to standard output. entry: DL = character to write, after execution AL = DL. ; print character 'a' mov ah, 2 mov dl, 'a' int 21h ; print carrige return and new line: mov ah, 2 mov dl, 0Dh int 21h mov dl, 0Ah int 21h ; prints a byte in binary mov cx, 8 p1: mov ah, 2 mov dl, '0' test bl, 10000000b ;test leftmost bit - "and" & set flag jz zero mov dl, '1' zero: int 21h ;print function. shl bl, 1 loop p1 ; wait 5 seconds (5 million microseconds) mov cx, 4Ch ; 004C4B40h = 5,000,000 mov dx, 4B40h mov ah, 86h int 15h

.. Interrupt Lists