Can some one explaine about puting dos interrupts in a RM OS,in detail how to implement or a good tutor . Most tutors seem to be on PMOS in general .
These are the things that i am most intrerested in ,
1: When a DOS interrupt is called it jumps to the IVT and gets the segment and offset and jumps to it and runs the comands at that address (after first finding the function number) . This is were i get a problem i have been told that you can not use a interrupt inside another interrupt , so how do you get it to do something ????.
2: I also need to know how to implement the above interrupts in to a kernel ?????.
I would very much appresiate any help ,
THANX in advance
\\\///
(@@)
ASHLEY4.
IVT in a DOS clone OS.
Re:IVT in a DOS clone OS.
The INT instruction is basically the same as a far CALL except:
a) it gets the segment and offset from the IVT, not from your code
b) it pushes FLAGS as well as CS:IP
c) it clears IF (the interrupt flag)
There's nothing about the INT instruction which stops you nesting them; this restriction comes from the way DOS is written, so if you're careful (i.e. don't use global data unless necessary) you should be OK. Certainly you can use a BIOS interrupt from within an interrupt routine; indeed, this is how DOS works.
The basic layout of a software interrupt handler is as follows:
1) push all general-purpose registers (pusha on 80186+)
2) push all segment registers (push ds/es, push fs/gs on i386+)
3) enable interrupts (if you want)
4) call your central handler routine (if you want)
5) pop all segment registers
6) pop all general-purpose registers
7) IRET
For a hardware interrupt handler, you need to do this as well as sending an EOI to the PIC(s) at the end. This is the same in protected mode (the PICs are separate from the CPU) so any good tutorial should teach you that.
a) it gets the segment and offset from the IVT, not from your code
b) it pushes FLAGS as well as CS:IP
c) it clears IF (the interrupt flag)
There's nothing about the INT instruction which stops you nesting them; this restriction comes from the way DOS is written, so if you're careful (i.e. don't use global data unless necessary) you should be OK. Certainly you can use a BIOS interrupt from within an interrupt routine; indeed, this is how DOS works.
The basic layout of a software interrupt handler is as follows:
1) push all general-purpose registers (pusha on 80186+)
2) push all segment registers (push ds/es, push fs/gs on i386+)
3) enable interrupts (if you want)
4) call your central handler routine (if you want)
5) pop all segment registers
6) pop all general-purpose registers
7) IRET
For a hardware interrupt handler, you need to do this as well as sending an EOI to the PIC(s) at the end. This is the same in protected mode (the PICs are separate from the CPU) so any good tutorial should teach you that.
Re:IVT in a DOS clone OS.
Tim:
As i am making my kernel in turbo pascal,can i put my interrupt handler in a procedure in the kernel ?????.
Like this:
procedure int20;
begin
asm
push cs
pop ax
mov ds, ax
mov es, ax
ret
end;
end;
Would this work????.
(normaly i would put in "iret")
Thank's.
\\\///
(@@)
ASHLEY4.
As i am making my kernel in turbo pascal,can i put my interrupt handler in a procedure in the kernel ?????.
Like this:
procedure int20;
begin
asm
push cs
pop ax
mov ds, ax
mov es, ax
ret
end;
end;
Would this work????.
(normaly i would put in "iret")
Thank's.
\\\///
(@@)
ASHLEY4.
Re:IVT in a DOS clone OS.
No, it's virtually impossible to do interrupt handlers in high-level languages: the compiler puts in extra code (e.g. to set up the stack frame) which interferes with the hander code itself.
Write your pushes, pops and irets in a separate assembly file (which you can link in to your program: {$L interrupt.obj} IIRC) and have them each call a central Pascal procedure for the actual handling code.
There will also be issues dealing with getting the right segment (i.e. how do you know which DS to use?). I'm not really qualified to answer this point because I've never really done any real-mode code (only 32-bit protected mode).
Write your pushes, pops and irets in a separate assembly file (which you can link in to your program: {$L interrupt.obj} IIRC) and have them each call a central Pascal procedure for the actual handling code.
There will also be issues dealing with getting the right segment (i.e. how do you know which DS to use?). I'm not really qualified to answer this point because I've never really done any real-mode code (only 32-bit protected mode).
Re:IVT in a DOS clone OS.
My pascal kernel is looking more like a asm program,may be i should just addmit that you was right and make it in asm :-\.
One thing i saw when looking at interrupt handler,is that on start up dpmi prog's (like cwsdpmi) swich from PM to RM do a interrupt and then go back to PM,
I know this is looked down on has away to do interrupt's
in protected mode,
But why, is it because it's slow????
Thank's again.
\\\///
(@@)
ASHLEY4.
One thing i saw when looking at interrupt handler,is that on start up dpmi prog's (like cwsdpmi) swich from PM to RM do a interrupt and then go back to PM,
I know this is looked down on has away to do interrupt's
in protected mode,
But why, is it because it's slow????
Thank's again.
\\\///
(@@)
ASHLEY4.