.186
;This program steels vector 21h. The reason is so that the two MS-DOS calls
;set vector and get vector can not change the vector for int 13h.
;***************************************************************
;MACROS
data	segment
	dw	100 dup(?)
stack_top   dw	?
data   ends

GET_VECTOR	MACRO	INTERRUPT
			MOV	AL,INTERRUPT
			MOV	AH,35h
			INT	21H
		ENDM			    

;***********************************************************
;EQUATES

DOS_INT		EQU	21H
;******************************************************

code	segment
	assume 	cs:code,ds:data,es:nothing,ss:nothing

steel21	proc	far
;***************************************************************
;GET NEEDED INTERRUPT VECTORS AND SAVE

START: 
	mov  ax, data
	mov  ss, ax
	mov  sp, offset stack_top

	GET_VECTOR DOS_INT
	MOV	DI,OFFSET DOS_VECTOR_21		;GET OLD INTERRUPT 21H
	MOV	CS:[DI],BX			;SAVE IT
	MOV	CS:[DI+2],ES
						      

;*********************************************************************
;STEAL NEEDED VECTORS

			cli	      
			mov	ax,0
			mov	es,ax
			MOV	AX,CS	    
;STEAL INTERRUPT 21H
			MOV	DX,OFFSET NEW_21
			mov	bx,84h			;INTERRUPT 21H
			mov	es:[bx],dx
			mov	es:[bx+2],ax	
			mov	cx,ax
			
			sti	     
;*************************************************************
;EXIT AND STAY_RESIDENT	
				MOV	DX,OFFSET FINISH
				MOV	BX,OFFSET START
				SUB	DX,BX
				mov	cX,4
				SHR	DX,cl
				ADD	DX,20H
				MOV	AH,31H
				mov     al, 0
				INT	21H
			  
;***************************************************************
;OLD INTERRUPT VECTORS AND NEW SEVICE ROUTINES
			  
DOS_VECTOR_21		DD	?

NEW_21:		cmp	ah,25H 			;2513
		JNZ	TEST_2
		CALL	TEST 
		JMP	SHORT OUT
TEST_2:		CMP	AH,35H
		JNZ	OUT
		call	test 
OUT:   		JMP	DOS_VECTOR_21
       
TEST		PROC	NEAR
		CMP	AL,13h		    ;THIS IS SLICER TIMER
		JNZ	TEST3		    ;BESIDES IBM DRIVES
		MOV	AL,0FDH		    ;THIS IS MORE LIKE DRIVES
		JMP	SHORT TEST_DONE
TEST3:
 		CMP	AL,24H			 ;DRIVES FATAL ERROR SAVE
       		JZ	NO_NO
		JNZ	TEST_DONE
NO_NO:		POPF				;RETURN
		IRET
TEST_DONE:	RET
TEST		ENDP


;************************
;END OF PROGRAM
		DW	10H DUP(?)
FINISH:		DB	?
steel21		endp
code		ends
		end	start
