summaryrefslogtreecommitdiff
path: root/sem2/lab5/test.asm
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-10-22 21:03:24 +0400
committerAndrew <saintruler@gmail.com>2020-10-22 21:03:24 +0400
commit143f34d941f32e0808fc9344d4c4126ff530d64a (patch)
treec79fcf309ad00e52100c0da544d96d3cc6ab6617 /sem2/lab5/test.asm
Добавил решения второго семестра
Diffstat (limited to 'sem2/lab5/test.asm')
-rw-r--r--sem2/lab5/test.asm105
1 files changed, 105 insertions, 0 deletions
diff --git a/sem2/lab5/test.asm b/sem2/lab5/test.asm
new file mode 100644
index 0000000..4006e27
--- /dev/null
+++ b/sem2/lab5/test.asm
@@ -0,0 +1,105 @@
+.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 \ No newline at end of file