	name	'DIOMOD'
	title	'Direct CP/M Calls From PL/I-80'
;
;***********************************************************
;*                                                         *
;*	cp/m calls from pl/i for direct i/o                *
;*	21.3.84 ph					   *
;*                                                         *
;***********************************************************
	public	reboot	;system reboot (#0)
	public	rdcon	;read console character (#1)
	public	rdstat	;read console status (#6c)
	public  coninp  ;direct console input (#6a)
	public	outg	;transfer to graphics outputdriver
	public  reset	;reset disk system (#13)
;
	extrn	?begin	;beginning of free list
	extrn	?boot	;system reboot entry point
	extrn	?bdos	;bdos entry point
;
;***********************************************************
;*                                                         *
;*        equates for interface to cp/m bdos               *
;*                                                         *
;***********************************************************
cr	equ	0dh	;carriage return
lf	equ	0ah	;line feed
eof	equ	1ah	;end of file
;
readc	equ	1	;read character from console
writc	equ	2	;write console character
rdrf	equ	3	;reader input
punf	equ	4	;punch output
listf	equ	5	;list output function
diof	equ	6	;direct i/o, version 2.0
getiof	equ	7	;get i/o byte
setiof	equ	8	;set i/o byte
printf	equ	9	;print string function
rdconf	equ	10	;read console buffer
statf	equ	11	;return console status
versf	equ	12	;get version number
resetf	equ	13	;system reset
seldf	equ	14	;select disk function
openf	equ	15	;open file function
closef	equ	16	;close file
serchf	equ	17	;search for file
serchn	equ	18	;search next
deletf	equ	19	;delete file
readf	equ	20	;read next record
writf	equ	21	;write next record
makef	equ	22	;make file
renamf	equ	23	;rename file
loginf	equ	24	;get login vector
cdiskf	equ	25	;get current disk number
setdmf	equ	26	;set dma function
getalf	equ	27	;get allocation base
wrprof	equ	28	;write protect disk
getrof	equ	29	;get r/o vector
setatf	equ	30	;set file attributes
getdpf	equ	31	;get disk parameter block
userf	equ	32	;set/get user code
rdranf	equ	33	;read random
wrranf	equ	34	;write random
filszf	equ	35	;compute file size
setrcf	equ	36	;set random record position
rsdrvf	equ	37	;reset drive function
wrrnzf	equ	40	;write random zero fill
;
;	utility functions
;***********************************************************
;*                                                         *
;*       general purpose routines used upon entry          *
;*                                                         *
;***********************************************************
;
getp1:	;get single byte parameter to register e
	mov	e,m		;low (addr)
	inx	h
	mov	d,m		;high(addr)
	xchg			;hl = .char
	mov	e,m		;to register e
	ret
;
getp2:	;get single word value to DE
getp2i:	;(equivalent to getp2)
	call	getp1
	inx	h
	mov	d,m		;get high byte as well
	ret
;
;***********************************************************
;*                                                         *
;***********************************************************
reboot:	;system reboot (#0)
	jmp	?boot
;
;***********************************************************
;*                                                         *
;***********************************************************
reset:		;reset disk system (#13)
	mvi	c,resetf
	jmp	?bdos
;
;***********************************************************
;*                                                         *
;***********************************************************
rdcon:	;read console character (#1)
	;return character value to stack
	mvi	c,readc
chrin:
	;common code for character input
	call	?bdos		;value returned to A
	pop	h		;return address
	push	psw		;character to stack
	inx	sp		;delete flags
	mvi	a,1		;character length is 1
	pchl			;back to calling routine
;
;***********************************************************
;*                                                         *
;***********************************************************
rdstat:	;direct console status read
	lxi	h,rdsret	;read status return
	push	h		;return to rdsret
	lhld	?boot+1		;base of jmp vector
	lxi	d,1*3		;offset to .jmp const
	dad	d		;hl = .jmp const
	pchl
;
;***********************************************************
;*                                                         *
;***********************************************************
coninp:	;direct console input
	lxi	h,chrstr	;return address
	push	h		;to stack for return
	lhld	?boot+1		;base of jmp vector
	lxi	d,2*3		;offset to .jmp const
	dad	d		;hl = .jmp const
	pchl
;
chrstr:				;create character srting length 1
	pop	h		;recall return address
	push	psw		;save character
	inx	sp		;delete psw
	pchl			;return to caller

rdsret:	;return clean true value
	ora	a		;zero?
	rz			;return if so
	mvi	a,0ffh		;clean true value
	ret
;
;
;		28/06/83   14:30  WF
;
;  MAIN PROGRAM FOR NCR DECISION MATE DEVICE DRIVER
;  THIS ACCEPTS PARAMETERS AS PASSED TO GSX, WITH DE POINTING
;  TO A BLOCK OF 5 PARAMETERS AND SETS UP THE PROPER CALLING SEQUENCE
;  FOR THE REAL DRIVER
;

        EXTRN   DDMATE

outg:
	MOV	E,M	; GET LOW ORDER BYTE OF ADDRESS OF CONTRL ARRAY
	INX	H
	MOV	D,M	; GET HIGH ORDER BYTE OF ADDRESS OF CONTRL ARRAY
	PUSH	D       ; PUSH ADDRESS OF CONTRL ARRAY ON STACK
	INX	H
	MOV	E,M	; GET LOW ORDER BYTE OF ADDRESS OF INTIN ARRAY
	INX	H  
	MOV	D,M	; GET HIGH ORDER BYTE OF ADDRESS OF INTIN ARRAY
	INX	H
	PUSH    H	; PUT POINTER TO REST OF ADDRESSES IN BC
	POP	B
	POP     H       ; GET ADDRESS OF CONTRL ARRAY IN HL
	JMP 	DDMATE  ; JUMP TO REAL DRIVER - No RETURN

	END

 