; ASY (8250/16550A "com" port) interrupt hooks
; Copyright 1991 Phil Karn, KA9Q

	.MODEL	MEMMOD,C
	%MACS

	extrn	doret:proc,asyint:far,eoi:proc

	.DATA
	extrn	Sssave:word
	extrn	Spsave:word
	extrn	Stktop

	.CODE
dbase	dw	@Data

; asy0vec - asynch channel 0 interrupt handler
	public	asy0vec
	label	asy0vec	far
	push	ds		; save on user stack
	mov	ds,cs:dbase	; establish interrupt data segment

	mov	Sssave,ss	; stash user stack context
	mov	Spsave,sp

	mov	ss,cs:dbase
	lea	sp,Stktop

	push	ax		; save user regs on interrupt stack
	push	bx
	push	cx
	push	dx
	push	bp
	push	si
	push	di
	push	es
	call	eoi

	mov	ax,0		; arg for service routine
	push	ax
	call	asyint
	pop	ax
	jmp	doret

; asy1vec - asynch channel 1 interrupt handler
	public	asy1vec
	label	asy1vec	far
	push	ds		; save on user stack
	mov	ds,cs:dbase	; establish interrupt data segment

	mov	Sssave,ss	; stash user stack context
	mov	Spsave,sp

	mov	ss,cs:dbase
	lea	sp,Stktop

	push	ax		; save user regs on interrupt stack
	push	bx
	push	cx
	push	dx
	push	bp
	push	si
	push	di
	push	es
	call	eoi

	mov	ax,1		; arg for service routine
	push	ax
	call	asyint
	pop	ax
	jmp	doret

; asy2vec - asynch channel 2 interrupt handler
	public	asy2vec
	label	asy2vec far
	push	ds		; save on user stack
	mov	ds,cs:dbase	; establish interrupt data segment

	mov	Sssave,ss	; stash user stack context
	mov	Spsave,sp

	mov	ss,cs:dbase
	lea	sp,Stktop

	push	ax		; save user regs on interrupt stack
	push	bx
	push	cx
	push	dx
	push	bp
	push	si
	push	di
	push	es
	call	eoi

	mov	ax,2		; arg for service routine
	push	ax
	call	asyint
	pop	ax
	jmp	doret

; asy3vec - asynch channel 3 interrupt handler
	public	asy3vec
	label	asy3vec far
	push	ds		; save on user stack
	mov	ds,cs:dbase	; establish interrupt data segment

	mov	Sssave,ss	; stash user stack context
	mov	Spsave,sp

	mov	ss,cs:dbase
	lea	sp,Stktop

	push	ax		; save user regs on interrupt stack
	push	bx
	push	cx
	push	dx
	push	bp
	push	si
	push	di
	push	es
	call	eoi

	mov	ax,3		; arg for service routine
	push	ax
	call	asyint
	pop	ax
	jmp	doret

; asy4vec - asynch channel 4 interrupt handler
	public	asy4vec
	label	asy4vec far
	push	ds		; save on user stack
	mov	ds,cs:dbase	; establish interrupt data segment

	mov	Sssave,ss	; stash user stack context
	mov	Spsave,sp

	mov	ss,cs:dbase
	lea	sp,Stktop

	push	ax		; save user regs on interrupt stack
	push	bx
	push	cx
	push	dx
	push	bp
	push	si
	push	di
	push	es
	call	eoi

	mov	ax,4		; arg for service routine
	push	ax
	call	asyint
	pop	ax
	jmp	doret

	end
