That looks very helpful Frank... rewriting that code was on my todo list anyway (i still have a few files in my OS that i didnt write from scratch, i'm rewriting them as i feel the need), so i guess it will just be placed at the top.
It seems so obvious now, thank you for explaining, i assumed that the EAX register would be saved as this is the default return register.. silly me =/
anyway, i'll rewrite my ISR routine when i get home, thanks again
isr_common_stub:
pusha ; Pushes all registers to stack
mov ax, ds ; puts data segment into AX
push eax ; pushes AX to stack
mov ax, 0x10 ; puts kernel data segment into AX
mov ds, ax ; sets all segments to kernel segment
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp ; put stack pointer in eax
push esp ; push stack pointer to stack (argument for isr_handler)
call isr_handler
pop eax ; get rid of the default return value??
pop eax ; restore userland segment
mov ds, ax ; reassign this to the segment registers
mov es, ax
mov fs, ax
mov gs, ax
popa ; pop all registers (from stack pointer we modified)
add esp, 8 ; do some cleaning up
sti
iret
this all seems to make sense, but whatever i do i get an EAX value of 5, and even setting EBX doesn't have an effect... i've spent a long time debugging this but i'm having mental block... it must be something simple, but i cant think what would be ruining this routine
Are you trying to set EAX by using inline assembly? That won't work because the isr stub restores all registers at the end before the IRET. You need to change the value of EAX by using
i debugged a fair bit and got nowhere, so whilst playing with my code i decided to pass the memory location of the programs stack, and use a pointer to that. worked a charm.