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.
[extern _int0]
[global _isr0]
_isr0:
pusha
push gs
push fs
push ds
push es
mov ax, 10h
mov ds, ax
mov es, ax
cld
call _int0 ;i call the function that prints the info about exception
pop es
pop ds
pop fs
pop gs
popa
iret
That's not a mistake. If your code does not halt the computer after catching an exception, and it doesnot, control is returned to program, to the place stated by EIP in stack.
There is a difference: after an INT, the EIP-on-stack points to the next instruction to be handled. So asm("int $0") is executed once.
After a faulty opcode, like x = x / 0, the EIP-on-stack does not point to the next instruction; it points to the faulty one, so returning to it causes the exception to rehappen.
You could 1) halt comp after exception, 2) try to see if it is caused by INT of a fault, 3) if caused by fault try to understand the opcode and change EIP-on-stack.
[extern _int0]
[global _isr0]
_isr0:
pusha
push gs
push fs
push ds
push es
mov eax, cr2
push eax
call _int0 ;Divide Error
pop eax
pop es
pop ds
pop fs
pop gs
popa
iret
one more question, i hope the last one.
where could i find the information about operation codes and length of the commands.
i have such information about the 8086 commands
for example:
000 trm __ ADD rm8 r8
............
207 trm __ XCHG r16 rm16
and so on ...
P.S.
if someone answered me i am 100 % sure that topic will be closed and i won't bother you with exceptions.
at least hope so ;D
hm, wierd.
why when i call __asm__("int $1"); or __asm__("int $0");
i get the same value of operation code value : 0x83
and it is not equal to non of the listed in intel documentation : CC, CD(i think that i should get this) or CE.
but when exception is caught here:
hey, hey ... remember that IP value saved on the stack by int n instruction is the value of the *next* instruction, while the IP value saved on the stack because of a fault is the address of the faulty instruction ...
btw, why do you want to generate "int 0" manually ? this makes no sense, and will usually lead to flaws for other exceptions that require an error code (provided by the CPU) ... and you should rather set your IDT descriptors so that user code is not allowed to call exception or hardware interrupts manually.
run user-level code at DPL3 and set the "DPL" field of the interrupt gates at level 0. Any attempt from user-level code to call an exception handler will result in a GPF exception with the interrupt descriptor as error code.
i can't understand why i get general protection error in that line? maybe it is because my IRQ handlers are with the same settings as exceptions?
i am lost ???
i foound out that i get general exception error only trying to unmask IRQ0. if comment unmaskIRQ(0); and leave unmaskIRQ(6) everything is fine.
i thought that it is maybe because of mine timer initialization procedure but i commented that procedure and got the same general protection exception while trying to unmask IRQ0
what's that for a weird code ? what are you trying to do with AX ? Why pushing something for a function that takes no parameter ? and why the hell pushing the return value of a void function before popping segments ?
Are you aware that what you'll pop into es,fs,gs, etc. will *not* be what you pushed earlier on the stack, but that there are chances that it will just be garbage or that your handler will invert some values ? ...
what's that for a weird code ? what are you trying to do with AX ? Why pushing something for a function that takes no parameter ? and why the hell pushing the return value of a void function before popping segments ?
i have no idea why i am doing this .... d*amn. now i removed those nasty push ax statements, so now i am pushing segments and poping them back.
and now unmaskIRQ(0); doesn't generate any error.
thank you.
<pype> i moved your other question into a new fresh post as it starts drifting away from the initial problem ...</pype>