I've got a subroutine which, when called normally, executes fine and does not crash, but when I call it from an ISR, the system has some fault or another (not sure which kind, but it causes the machine to reset itself).
The subroutine is called "beep":
Code: Select all
beep:
inb al, #0x0061
or al, #0x03
outb #0x0061, al
mov cx, #0xFFFF
mov dx, #0x0FFF
mov bx, #0x0000
loopba:
mov ax, #0x0000
loopaa:
inc ax
cmp ax, cx
jne loopaa
inc bx
cmp bx, dx
jne loopba
inb al, #0x0061
and al, #0xFC
out #0x0061, al
ret
When called from this ISR, the machine completes the beep (as in, the beep is continued for the same duration so it is not crashing part of the way through the beep) and then immediately resets itself:
Code: Select all
call #0x0008:#beep+0x00007C00
push ax
mov al, #0x20
outb 0x20, al
pop ax
iretd
This is in protected mode, without paging. The segments and addresses are all correct, as the "beep" subroutine is executed. I should maybe check if the crash is before the subroutine returns or after (back in the ISR), however I do not have time to check that now so will report back if/when I do.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing