71 lines
1.0 KiB
NASM
71 lines
1.0 KiB
NASM
; Get pointer to interrupt vector
|
|
; IN al number
|
|
; OUT 0:bx ptr to vector
|
|
intr_ptr:
|
|
xor bh, bh
|
|
mov bl, al
|
|
add bx, bx
|
|
add bx, bx
|
|
ret
|
|
|
|
; Set interrupt vector
|
|
; IN al number
|
|
; ds:dx ptr
|
|
intr_set:
|
|
push bx
|
|
call intr_ptr
|
|
ss mov [bx], dx
|
|
ss mov [bx+2], ds
|
|
pop bx
|
|
ret
|
|
|
|
; Get interrupt vector
|
|
; IN al number
|
|
; OUT es:bx ptr
|
|
intr_get:
|
|
call intr_ptr
|
|
ss mov es, [bx+2]
|
|
ss mov bx, [bx]
|
|
ret
|
|
|
|
; Save BIOS vectors
|
|
; Trashes ax, cx, bx, ds
|
|
intr_backup:
|
|
mov cx, 0x20
|
|
xor bx, bx
|
|
mov ds, bx
|
|
.loop: ; load segment
|
|
mov ax, [bx+2]
|
|
; skip transfer if not pointing to BIOS
|
|
cmp ax, 0xA000
|
|
jc .skip
|
|
; store segment
|
|
mov [bx+ivt2+2], ax
|
|
; copy offset
|
|
mov ax, [bx]
|
|
mov [bx+ivt2], ax
|
|
; iterate to next vector
|
|
.skip: add bx, 4
|
|
loop .loop
|
|
ret
|
|
|
|
; Restore BIOS vectors
|
|
intr_restore:
|
|
mov cx, 0x20
|
|
xor bx, bx
|
|
mov ds, bx
|
|
.loop: ; load segment
|
|
mov ax, [bx+ivt2+2]
|
|
; skip if not a vector to BIOS
|
|
cmp ax, 0xA000
|
|
jc .skip
|
|
; store segment
|
|
mov [bx+2], ax
|
|
; copy offset
|
|
mov ax, [bx+ivt2]
|
|
mov [bx], ax
|
|
; iterate to next vector
|
|
.skip: add bx, 4
|
|
loop .loop
|
|
ret
|