
	page	59,132
	TITLE -- PASCAL SUBROUTINE to access DOS functions
;
	 COMMENT *		This subroutine provides access to all(?)
					   DOS functions from Pascal


		procedure DOSCALL(var error:boolean,var A,B,C,D,SI,DI:register);

					ERROR is set true if the cary flag is set upon return from DOS
						This may not indicate an error for all DOS calls; the manual
						(pg D-14) is typically vague on this.
					The caller must set the variables to the values required by DOS
						in the registers for the call; A.H is the DOS function code.
					All variables are returned with the register contents as 
						returned by DOS.

			*
;
;		parameter offsets on the calling stack
DIoff	equ	6
SIoff	equ	8
Doff	equ	10
Coff	equ	12
Boff	equ	14
Aoff	equ	16
eroff	equ   18
;
;
;	SUBROUTINE ENTRY POINT
DOSSEG	SEGMENT	PARA PUBLIC 'CODE'
DGROUP	GROUP	DATA
DOSCALL	PROC	FAR
	ASSUME	CS:DOSSEG,ES:DGROUP,SS:DGROUP,DS:DGROUP
	PUBLIC	DOSCALL
;
	PUSH	BP		;save frame pointer for return
;		put contents of Pascal variables into registers for call to DOS
	mov	bp,sp
	mov 	ax,ds
	mov	es,ax
	mov	di,[bp+Doff]
	mov	dx,[di]
	mov	di,[bp+Coff]
	mov	cx,[di]
	mov	di,[bp+Boff]
	mov	bx,[di]
	mov	di,[bp+Aoff]
	mov	ax,[di]
	mov	di,[bp+SIoff]
	mov	si,[di]
	mov	di,[bp+DIoff]
	mov	di,[di]
;  now do the DOS interupt
	INT	21H
;  now pass all the registers back in the variables
	push	di		;save for a moment
	mov	di,[bp+Aoff]
	mov	[di],ax
	mov	di,[bp+Boff]
	mov	[di],bx
	mov	di,[bp+Coff]
	mov	[di],cx
	mov	di,[bp+Doff]
	mov	[di],dx
	mov	di,[bp+SIoff]
	mov	[di],si
;		now set error flag
	jc    error
	mov	bx,0	;set error = false
	jmp	out
error:
	mov	bx,1	;set error = true
out:
	mov	di,[bp+eroff]
	mov	[di],bx
;		;finally put DI	
	pop	ax		; put DI into AX
	mov	di,[bp+DIoff]
	mov	[di],ax


	POP	BP
	RET	14		;Return to caller
DOSCALL 	ENDP
DOSSEG	ENDS
	END