Improve register hygiene for interrupt setup

This commit is contained in:
Nero 2019-09-01 13:48:28 +00:00
parent b5cc332a02
commit 809a959608
2 changed files with 31 additions and 22 deletions

View File

@ -1,23 +1,34 @@
; Register a interrupt handler ; Register a interrupt handler
; in: sp:bp+0 interrupt number ; in: AL interrupt number
; +2 handler offset ; ES:DI far ptr to routine/data
; out: sp:bp+4
intr_register: intr_register:
; use data stack ; backup original values
xchg sp, bp push ax
; ES := 0 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 xor ax, ax
mov es, ax mov es, ax
; DI := intnum * 4
pop di ; store offset
sal di, 1
sal di, 1
; copy offset from arguments
pop ax pop ax
stosw stosw
; copy our segment
mov ax, cs ; store segment
pop ax
stosw stosw
; use code stack
xchg sp, bp pop di
pop es
pop ax
ret ret

View File

@ -37,12 +37,10 @@ str_product:
db "Nero DOS ", 60, 234, 62, 0 db "Nero DOS ", 60, 234, 62, 0
optrom_init: optrom_init:
; setup data stack below code stack push cs
mov bp, sp pop es
sub bp, 0x80 mov di, start
; intnum and offset to data stack mov ax, 0x18
mov word [ss:bp], 0x18
mov word [ss:bp+2], start
call intr_register call intr_register
retf retf