It will run a normal dos console, but at the same time the freebasic program (the DO...LOOP cycle in the subroutine "task") will keep running (a normal ISR would not allow to use a cycle). So, I guess this can be called multitasking (2 tasks)
Code: Select all
#include "dos/dpmi.bi"
#include "dos/go32.bi"
#include "dos/sys/farptr.bi"
#include "libco.bi"
dim shared as any ptr t0,t1
dim shared as _go32_dpmi_seginfo old_handler_0x08, new_handler_0x08
sub task
dim z as integer
do
z+=1
dim as integer x,y
x=csrlin:y=pos
locate 1,1:print "this is the thread, iteration ";z
locate x,y
co_switch(t0)
loop
end sub
sub Int_0x08 cdecl()
static D as ubyte
if d=0 then
d=255
co_switch(t1)
d=4
elseif d<255 then
d-=1
end if
end sub
private sub Int_0x08_end cdecl()
end sub
sub InstallInt0x08()
dim as byte ptr ptr_end = cast( byte ptr, @Int_0x08_end )
dim as byte ptr ptr_start = cast( byte ptr, @Int_0x08 )
_go32_dpmi_lock_code(@Int_0x08, ptr_end-ptr_start)
_go32_dpmi_get_protected_mode_interrupt_vector( &h08, @old_handler_0x08 )
new_handler_0x08.pm_offset = cast(integer,@Int_0x08)
new_handler_0x08.pm_selector = _go32_my_cs()
_go32_dpmi_chain_protected_mode_interrupt_vector( &h08, @new_handler_0x08 )
end sub
sub RemoveInt0x08()
_go32_dpmi_set_protected_mode_interrupt_vector( &h08, @old_handler_0x08 )
end sub
t0=co_active()
t1=co_create(65536,@task)
InstallInt0x08
shell
RemoveInt0x08