;; A simple replacement for TCC's int86() function
;; Used to allow the compilation of T3X programs
;; without having to link against the TCC RT libraries.
;;
	.model	small
	.code
	public	_int86
_int86:	push	bp
	mov	bp,sp
	push	si
	push	di
	mov	ax,[bp+4]
	mov	byte ptr cs:patchme,al
	call	return		;; destroy prefetch queue
	mov	si,[bp+6]
	mov	ax,[si]
	mov	bx,[si+2]
	mov	cx,[si+4]
	mov	dx,[si+6]
	mov	di,[si+10]
	mov	si,[si+8]
	push	es
	push	ds
	db	0cdh		;; INT
patchme:db	0
	pop	ds
	pop	es
	push	di
	mov	di,[bp+8]
	mov	[di],ax
	mov	[di+2],bx
	mov	[di+4],cx
	mov	[di+6],dx
	mov	[di+8],si
	pop	ax
	mov	[di+10],ax
	pop	di
	pop	si
	pop	bp
return:	ret
	end
