;ROUTINE TO DO DIRECT I/O FROM A PORT
;EXTERNAL MODULE FOR PASCAL/Z VERS 3.0
;
;DEFINE THE FOLLOWING TYPE IN YOUR PROGRAM:
;
;	TYPE	BYTE = 0..255;
;
;CALL AS:
;
;	PROCEDURE INPORT(PORT : BYTE; VAR VALUE : BYTE); EXTERNAL;
;
PORT:	EQU	11	;---LOW BYTE OF PORT NUMBER
HADDR:	EQU	10	;---HIGH BYTE OF INPUT VALUE ADDR
LADDR:	EQU	 9	;---LOW BYTE OF INPUT VALUE ADDR
LENGTH: EQU	 8	;---LENGTH OF CALL-BY-REF INTEGER

	NAME	INPORT

	ENTRY	INPORT		;---FOR LINKER

INPORT:
	ENTR	D,2,0		;---NO LOCAL STORAGE
	MOV	C,PORT(IX)	;---C := INPUT PORT
	INP	B		;---INPUT THE VALUE FROM THE PORT
	MOV	H,HADDR(IX)	;---GET HIGH BYTE OF ADDRESS
	MOV	L,LADDR(IX)	;---GET LOW BYTE OF ADDRESS
	MOV	A,LENGTH(IX)	;---GET SIZE
	CPI	2		;---CHECK FOR 2 BYTE INTEGER
	JRNZ	NOPE		;---NO, 1 BYTE INTEGER
	MVI	M,0		;---YES, CLEAR HIGH BYTE
	DCX	H		;---POINT TO LOW BYTE
NOPE:	MOV	M,B		;---STORE LOW (ONLY) BYTE
	EXIT	D,4		;---DONE, 4 BYTES OF PARAMETERS
;
;
;
