-
Notifications
You must be signed in to change notification settings - Fork 0
/
myint.asm
78 lines (78 loc) · 3.16 KB
/
myint.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;Цели программы:
;Создание или замена уже существующего прерывания 87h
;для последующего его использования. В конкретном примере
;при помощи нового прерывания производится изменение цвета
;и создание звукового сигнала.
masm ;Определение компилятора
model small ;Тип необходимой памяти
stack 100h ;Задание размера стека
delay macro time ;Определение макроса задержки или паузы
local ext,iter
push cx
mov cx,time
ext: push cx
mov cx,10000
iter: loop iter
pop cx
loop ext
pop cx
endm
.386 ;Подключение библиотек для использования popa и pusha
.data ;Раздел данных
old_int dd 0 ;Переменная для сохранения предыдущего значения прерывания
.code ;Раздел кода
newint87 proc far ;Процедура, которая будет описана как новое прерывание
pusha
mov dl,al
;Генерация случайных чисел
mov ax,0
out 43h,al
in al,40h
in al,40h
mov bl,al
;Задание цвета для вывода, параметры цвета в BL
mov ah,09h
mov al,00h
mov bh,0
mov cx,1
int 10h
;Создание звукового сигнала через спикер
mov al,0B6h
out 43h,al
in al,61h
or al,3
out 61h,al
;Создание уникального звучания для каждой клавиши
mov ax,1063
shr dl,2
add ah,dl
out 42h,al
xchg al,ah
out 42h,al
delay 500 ;Пауза перед выключением спикера
in al,61h
and al,0FCh
out 61h,al
popa
iret
newint87 endp
start: mov ax,3587h ;Вызов 35 функции 21 прерывания для
int 21h ;сохранения старого прерывания
mov word ptr old_int,bx ;сохранить смещение
mov word ptr old_int+2,es ;и сегментный адрес
mov ax,2587h ;Вызов 25 функции 21 прерывания
;для создания нового описания 87 прерывания
mov dx,seg newint87 ;Назначить новый сегментный адрес
mov ds,dx ;и сохранить его в DS
mov dx,offset newint87 ;а в DX записать смещение
int 21h ;выполнить процедуру регистрации новго прерывания 87
newc: int 87h ;непосредственный вызов прерывания
mov ah,01h ;запрос на ввод символа с последующим выводом на экран
int 21h
cmp al,1bh ;Если ESC то выйти из программы
jne newc ;Если нет повторить запрос по метке NEWC
exit: lds dx,old_int ;Возвратить старое прерывание 87 в таблицу прерываний
mov ax,2587h
int 21h ;Сохранить все как было до изменения
.exit ;Выйти из программы
end start