61 lines
698 B
NASM
61 lines
698 B
NASM
; Register a interrupt handler
|
|
; in: AL interrupt number
|
|
; ES:DI far ptr to routine/data
|
|
intr_register:
|
|
; backup original values
|
|
push ax
|
|
push es
|
|
push di
|
|
|
|
; pop as ax later
|
|
push es
|
|
push di
|
|
|
|
; DI = AL * 4
|
|
mov ah, 4
|
|
mul ah
|
|
mov di, ax
|
|
|
|
; ES = 0
|
|
xor ax, ax
|
|
mov es, ax
|
|
|
|
; store offset
|
|
pop ax
|
|
stosw
|
|
|
|
; store segment
|
|
pop ax
|
|
stosw
|
|
|
|
pop di
|
|
pop es
|
|
pop ax
|
|
ret
|
|
|
|
; Get address for a interrupt vector
|
|
; in AL interrupt number
|
|
; out DS:SI far ptr to routine/data
|
|
intr_load:
|
|
push ax
|
|
|
|
; SI = AL * 4
|
|
mov ah, 4
|
|
mul ah
|
|
mov si, ax
|
|
|
|
; ES = 0
|
|
xor ax, ax
|
|
mov ds, ax
|
|
|
|
; load offset
|
|
lodsw
|
|
mov si, ax
|
|
|
|
; load segment
|
|
lodsw
|
|
mov ds, ax
|
|
|
|
pop ax
|
|
ret
|