i am working through the following tutorial: http://www.jamesmolloy.co.uk/tutorial_h ... 20PIT.html
My irq_handler_stub with the following code:
Code: Select all
irq_common_stub:
pusha
mov %ds, %ax
push %eax
mov $0x10, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
call irq_handler
pop %eax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
popa
add $8, %esp
sti
iret
Code: Select all
typedef struct registers
{
u32int ds; // Data segment selector
u32int edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha.
u32int int_no, err_code; // Interrupt number and error code (if applicable)
u32int eip, cs, eflags, useresp, ss; // Pushed by the processor automatically.
} registers_t;
void irq_handler(registers_t regs){
if (regs.int_no >= 40)
{
outb(0xA0, 0x20);
}
outb(0x20, 0x20);
printf("Got HARDWARE-Interrupt %x\n", regs.int_no);
}
http://prntscr.com/7t8vru
both mov-instructions above the green marked instruction change the top of the stack, the second stack-value on the right (the red marked) is actually my EAX which was pushed (and will eventually get poped) in assembler, so once the CPU reaches the instruction mov %ax, %ds it will interrupt me because EAX is at this point in time just garbage. How could i fix this problem?