Page 1 of 1

Creating an interrupt?

Posted: Mon Jun 03, 2013 3:51 pm
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

Re: Creating an interrupt?

Posted: Tue Jun 04, 2013 3:22 am
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