.MODEL SMALL .DATA MESSAGE DB "You pressed:$" .CODE .STARTUP ;Read the keys with echo until ESC key is pressed ;Print a message each time LABEL1: mov ah, 9 ; Select function 9, print a string mov dx, OFFSET MESSAGE int 21h ; Interrupt 21h (DOS functions) ;Read the key (BIOS) WAITKEY: mov ah, 01 ; Select function 1, check the buffer int 16h ; Interrupt 16h (BIOS functions) ;If flag Z is set, the keyboard buffer is empty JZ WAITKEY mov ah, 0 ; Select function 0, read the first key from the buffer int 16h cmp al,1BH ; Compare to ESC code (ASCII) jne LABEL1 ; If not ESC - continue .EXIT END