I investigate to create preemptive multitasking tool project for FB/ DOS, but i've strange problem
First, this is my base :
Code: Select all
INIT_INTERRUPT()
START_INTERRUPT()
while(1)
print "# Main
Wend
End
' ------------------------------------
sub Task1()
while(1)
print " #### Task1"
wend
end sub
sub Task2()
while(1)
print " ######## Task2"
wend
end sub
' ----------------------------------
Sub INIT_INTERRUPT()
asm
jmp 0%f
DS_SEL: .short 0
INT1C_OFF: .int 0
INT1C_SEL: .short 0
0:
mov ax, 0x204
mov bl, 0x1c
int 0x31
jc 1%f
mov INT1C_SEL, cx
mov INT1C_OFF, edx
1:
end asm
ISR_ACTIVE = true
End sub
Sub START_INTERRUPT()
if ISR_ACTIVE = true then
asm
mov ax, 0x205
mov bl, 0x1c ' I use 1Ch timer
push cs
pop cx
mov edx, OFFSET _MY_INTERRUPT
int 0x31
jc 2%f
2:
end asm
end if
End sub
Code: Select all
sub MY_INTERRUPT naked
push eax
' FOR TESTS ONLY , i push directly Task1 address to eax
mov eax, _Task1
' Push "return eip address" in interrupt stack
' !!! I add +4 because i've pushed eax before !!!
mov ss:[esp+4], eax
pop eax
iret
end sub
According to the stack model (Without errors):
We are ok if i push another EIP address in interrupt stack (ss:[ESP]), when iret is executed, it will continue execution from this new EIP ?
This not work.. CRASH :(
PS : According GDB, my new EIP address has been pushed to ss:[ESP] !
Someone have ideas ?
Thank