16bit exception handling question

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
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

16bit exception handling question

Post by Ninjarider »

what data is passed when an exception is handles.

lets say the exception is a divide error exception.
the system would call the appropriate code throu the ivt - entry 0
what is the data structure that it pushes onto the stack when calling the appropriate handler. (error code, ip, cs, etc)
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Post by Zenith »

I'd assume it would be the same as in protected mode, but there's no task switching and CPL stuff... So, all you're basically asking is what the INT opcode does in real mode.

See http://pdos.csail.mit.edu/6.828/2005/re ... 86/INT.htm. It pushes the FLAGS, clears IF/TF, pushes CS, IP. There are no error codes, as exceptions like #PF don't exist.

A list of hardware/software interrupts in real/protected mode can be found here: http://www.bioscentral.com/misc/interrupts.htm. I'd say to ignore any of those that have something like (80386) after them and stick with the ones on the original 8086.
"Sufficiently advanced stupidity is indistinguishable from malice."
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

Post by Ninjarider »

thanks for the reading material
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,

Just a quick note...
karekare0 wrote:There are no error codes, as exceptions like #PF don't exist.
A general protection fault is entirely possible in real mode (the CPU won't push an error code on the stack for any exception in real mode, probably because of backward compatability).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

Post by Ninjarider »

ok 1 other question.
int 8 from my understanding are used for 2 things. the system clock irq and double fault exception.

in both 32 and 16, how do you distinguish between the 2?
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

You can remap the PICs so that they do not conflict. The code below will map IRQs 0 to 15 to IDT entries 32 to 47:

Code: Select all

out8(0x20, 0x11);
out8(0xA0, 0x11);
out8(0x21, 0x20);
out8(0xA1, 0x28);
out8(0x21, 0x04);
out8(0xA1, 0x02);
out8(0x21, 0x01);
out8(0xA1, 0x01);
out8(0x21, 0x0);
out8(0xA1, 0x0);
out8 is the same as outb/outportb.
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

Post by Ninjarider »

ok i get the port numbers but what does all the other stuff do?
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Post by Zenith »

STFW :wink: http://www.osdev.org/wiki/PIC

Anyway the commands basically program both PICs to trigger IRQs using different interrupts (32-47) instead of the ones in use at 0-15.
"Sufficiently advanced stupidity is indistinguishable from malice."
Post Reply