home *** CD-ROM | disk | FTP | other *** search
- ; **************
- ; * EXITMP.asm *
- ; *******************************************
- ; * Copyright TimeSlice, Inc. 1985, 86, 87. *
- ; *******************************************
- include ts.inc
- ;
- extern_code critend
- ifdef MICROSOFT
- extern_code critstart
- else
- extern_code critstar
- critstart equ critstar
- endif
- extern_code term13
- extern_code intrest
- extern_code exit
- extern_code tickrate
- ;
- start_data
- end_data
- ;
- start_code
- ;
- extrn __jaddr:far
- ;
- ;*******
- ;* EXITMP( STATUS )
- ;* This function is invoked to cleanly exit the multi-tasking application.
- ;* It detaches all interrupt routines attached by the multi-tasking
- ;* application, restores the timer interrupt vector to point to original
- ;* service routine, and then invokes EXIT() the close all files and
- ;* return to dos.
- ;*******
- start_struct
- mbr exbp d_int
- mbr exret d_ret
- mbr exstat d_int
- ;
- routine exitmp ;reset timer interrupt to orig. value
- push bp
- mov bp,sp
- mov ax, 13h ;restore original interrupt 13h
- push ax
- call term13
- mov sp,bp
- mov ax,DOS_CRCLASS
- push ax
- call critstart
- mov sp,bp
- mov ax,1 ;restore normal ticker rate
- push ax
- call tickrate
- mov sp,bp
- call intrest ;detach all functions attached to an interrupt
- mov ax,_slint ;ax <-- interrupt of slicer
- mov cl,2
- shl ax,cl ;ax <-- offset of slicer's IntVector
- mov si,ax ;si <-- slicer's Int Vector
- push ds ;save local data segment
- push es ;save extra data segment
- xor ax,ax ;set ds to IVT segment (0)
- mov ds,ax
- cli ;hold interrupts while replacing intvect
- mov di,offset __jaddr ;reset original offset
- mov ax,seg __jaddr
- mov es,ax
- mov ax,es:[di].off ;reset original interrupt vector
- mov bx,es:[di].sgt
- mov [si].off,ax
- mov [si].sgt,bx
- sti ;reenable interrupts before exiting
- pop es ;restore es to DATA segment
- pop ds ;restore ds to DATA segment
- ldint ax,[bp].exstat ;pass exit status to exit()
- push ax
- call exit ;call regular exit() function
- return exitmp
- ;
- end_code
-