I'm trying to rewrite the 0h interrupt (Divide by zero) to a custom label I've made, which is supposed to print a custom message I've made instead of the normal exception which the emulator throws.
I haven't managed to find a good source which explains all this stuff in a good and understandable way, so my code obviously didn't work when I first made it. I've found this post: Is it possible to make a custom Interrupt in Assembly? But I'm still confused.
org 100h jmp main main: xor ax, ax mov es, ax CLI mov bx, offset divideByZero mov es:[0h], bx add bx, 2 mov ax, cx mov es:[bx], ax STI mov ax, 10 mov bx, 0 div bx mov ah, 0 int 16h ret divideByZero: push bp mov bp, sp PRINTN "Error: Divide By Zero Can Break The Universe" pop bp iret Can somebody explain to me how can I make my own interrupt like I tried to do, and how does it work?
offset divideByZeroisn't the full linear address of your function. You need to storecsto linear address2(i.e.es:[2]), not todivideByZero+2