Creating an interrupt?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
computertrick
Member
Member
Posts: 71
Joined: Wed May 29, 2013 1:07 pm

Creating an interrupt?

Post by computertrick »

I am trying to create my first ever interrupt but I have ran into a bit of trouble can anyone explain what I'm doing wrong here

Code: Select all

cli
mov ax, cs
mov ds, ax
mov es, ax

mov bx, 0x00
mov es, bx
mov bx, 0x00
mov word[es:bx], ax
inc bx
inc bx
mov word[es:bx] INT0
sti

int 0h

jmp $

INT0:
mov ah, 0eh
mov al, 65
int 10h
I read that in the interrupt vector table each interrupt uses 4 bytes and is in order

so first 4 bytes is interrupt 0 next 4 bytes is interrupt 1 ect ect
1100110100010011
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Creating an interrupt?

Post by Gigasoft »

There are several errors:
- The address is reversed. The offset needs to come first, then the segment
- The interrupt routine does not end with IRET
- A comma is missing
- Interrupt numbers that are used for processor exceptions should probably not be used for software interrupts

Therefore, it should be more like this:

Code: Select all

push 0
pop ds
mov [80h],INT20
mov [82h],cs
int 20h
jmp $

INT20:
mov ah,0eh
mov al,65
int 10h
iret
Post Reply