.model small .data int09h dw 2 dup (0) msg db "To exit press ESC! $" tsr_end equ $ ; B_UP equ 1Ch ; вверх .stack 100h .486 .code ; pNewInterrupt PROC far ; PUSHF ; PUSH ax ; in al, 60h ; Читаем сканкод ; cmp al, B_UP ; JE hotkey ; ; ; Наш код ; ; mov dx, offset mesg ; ; MOV ah,09h ; ; INT 21h ; POP ax ; POPF ; PUSHF ; CALL cs:[int09h] ; jmp exit ; hotkey: ; ; Обработка аппаратного прерывания ; in al,61h ; mov ah,al ; or al,80h ; out 61h,al ; xchg ah,al ; out 61h,al ; mov al,20h ; out 20h,al ; ; Наш код ; mov dx, offset mesg ; MOV ah,09h ; INT 21h ; exit: ; POPF ; IRET ; pNewInterrupt ENDP start: JMP program pNewInterrupt PROC far PUSHF CALL dword ptr cs:int09h IRET pNewInterrupt ENDP program: MOV ax, @DATA MOV ds, ax ; MOV ax,3509h ;Hook interrupt 09H ; INT 21h ; MOV word ptr int09h,bx ; MOV word ptr int09h[2],es ; ; MOV ax, 2509h ; ; MOV dx, offset pNewInterrupt ; ; INT 21h ; ; Восстанавливаем прерывание ; MOV ax, 2509h ; MOV ds, word ptr int09h[2] ; MOV dx, offset int09h ; INT 21h ; INT 09h MOV ax, 3509h INT 21h MOV word ptr int09h, bx MOV word ptr int09h[2], es MOV ax, 2509h MOV dx, offset pNewInterrupt INT 21h MOV ah,09h MOV dx, offset msg INT 21h MOV dx, offset tsr_end INT 27h ; ; Выходим из программы ; MOV ax, 4c00h ; INT 21h END start