;========================================================================
;
;	ＡＲＩのキャンセルルーチン
;
	.386p

code	segment	use32
	assume	cs:code,ds:code


;	INT 24hベクタの設定

	public	set24h
set24h	proc	near

	pushad
	
	push	es
	mov	cl,24h			;旧ネイティブ割り込みベクタの取得
	mov	ax,2502h
	int	21h
	mov	dword ptr [padr],ebx
	mov	word ptr [pseg],es
	pop	es
	jc	#Error

	mov	cl,24h			;旧リアル割り込みベクタの取得
	mov	ax,2503h
	int	21h
	jc	#Error
	mov	dword ptr [radr],ebx

	push	ds			;int24hベクタを登録
	mov	cl,24h
	push	cs
	pop	ds
	mov	edx,offset int24h
	mov	ax,2506h
	int	21h
	pop	ds
	jc	#Error

	popad
	xor	eax,eax
	ret
#Error:
	popad
	mov	eax,-1
	ret
		
set24h	endp


;	INT 24hベクタを戻す

	public	reset24h
reset24h	proc	near

	pushad
	
	push	ds
	mov	ebx,dword ptr [radr]
	mov	edx,dword ptr [padr]
	mov	ds,word ptr [pseg]

	mov	cl,24h			;ネイティブ割り込みベクタの設定
	mov	ax,2507h
	int	21h

	pop	ds
	
	popad
	xor	eax,eax
	ret
		
reset24h	endp


int24h	proc	far
	mov	eax,0
	ret
int24h	endp

	align	4
pseg	dd	0
padr	dd	0
radr	dd	0

code	ends
	end
