h05430
s 00115/00000/00000
d D 1.1 83/03/17 17:43:06 bog 1 0
c date and time created 83/03/17 17:43:06 by bog
e
u
4
U
t
T
I 1
;
;  ALTOS 8000 I/O ROUTINES FOR CP/M 80 (*** VERSION 2.0 AND ABOVE ONLY ***)
;
;  THESE ARE MACRO80 ASSEMBLER ROUTINES TO GET OR PUT A CHARACTER
;  TO THE CONSOLE OR THE READER/PUNCH.
;  THE ROUTINES ARE ALL FORTRAN CALLABLE.  FOR SINGLE ARGUMENTS, FORTRAN
;  PUTS THE ADDRESS OF THE ARGUMENT IN THE H AND L REGISTERS.
;  SUBROUTINE TTYOUT USES A CP/M MONITOR CALL TO PERFORM ITS I/O.
;  THIS MONITOR CALL (JMP 0005) ASSUMES THAT THE OPERATION CODE IS IN
;  THE C REGISTER AND THE DATA IS IN THE E REGISTER.
;  SUBROUTINE TTYIN  ALSO USES A MONITOR CALL TO GET A CHARACTER FROM
;  THE CONSOLE .  THE CHARACTER IS RETURNED IN THE A REGISTER.
;  SUBROUTINE TTYINE USES A MONITOR CALL TO GET A CHARACTER BUFFER
;  FROM THE CONSOLE.  THE ADDRESS OF THE BUFFER IS PASSED IN REGISTERS D AND E.
;
;  STANDARD CP/M FOR THE ALTOS DOES NOT HAVE A READER/PUNCH PORT SYSGENNED,
;  SO WE USE THE PRINTER PORT AS THE READER/PUNCH PORT.  INSTEAD OF USING BDOS
;  CALLS, WE GO DIRECTLY TO THE I/O CONTROLLER ON THE PORT TO SEND AND
;  RECEIVE CHARACTERS.  THE BAUD RATE FOR THE PRINTER PORT (PORT JT)
;  MUST BE SET PRIOR TO USING THESE I/O ROUTINES BY RUNNING THE PROGRAM
;  CALLED CPMSETUP THAT IS SUPPLIED WITH YOUR SYSTEM.
;
JT_CMD		EQU	01FH		; JT COMMAND PORT
JT_DATA		EQU	01EH		; JT DATA PORT
;
;  SUBROUTINE TTYIN - CALLS MONITOR TO GET A CHARACTER FROM THE CONSOLE
;                     WITHOUT ECHO.
;
TTYIN:         ENTRY          TTYIN
               SHLD           SAVADR  ;SAVE ARGUMENT ADDRESS
LOOP:          MVI            C,6D    ;SET DIRECT I/O OPCODE
               MVI            E,0FFH  ;SET INPUT OPCODE
               CALL           0005    ;INPUT CHARACTER INTO A
               CPI            0       ;MAKE SURE WE GOT A CHARACTER
               JZ             LOOP
               ANI            7FH     ;STRIP OFF HIGH ORDER BIT
               LHLD           SAVADR  ;GET ARGUMENT ADDRESS
               MOV            M,A     ;RETURN CHARACTER TO CALLING ROUTINE
               RET
SAVADR:        DS             2
;
;  SUBROUTINE TTYINW - CALLS MONITOR TO GET A CHARACTER FROM THE CONSOLE
;                      WITHOUT ECHO AND WITHOUT WAITING. IT RETURNS -1
;                      IF NO CHARACTER IS AVAILABLE.
;
TTYINW:        ENTRY          TTYINW
               SHLD           SAVADR  ;SAVE ARGUMENT ADDRESS
               MVI            C,6D    ;SET DIRECT I/O OPCODE
               MVI            E,0FFH  ;SET INPUT OPCODE
               CALL           0005    ;INPUT CHARACTER INTO A
               CPI            0       ;MAKE SURE WE GOT A CHARACTER
               JNZ            NW1     ;GOT CHARACTER, STRIP PARITY
	       MVI            A,0FFH  ;NO CHARACTER, RETURN -1
               JMP            NW2
NW1:           ANI            7FH     ;STRIP OFF HIGH ORDER BIT
NW2:           LHLD           SAVADR  ;GET ARGUMENT ADDRESS
               MOV            M,A     ;RETURN CHARACTER TO CALLING ROUTINE
               RET
;
;  SUBROUTINE TTYOUT - CALLS MONITOR TO OUTPUT A CHARACTER TO THE CONSOLE
;
TTYOUT:        ENTRY          TTYOUT
               MOV            E,M     ;PUT CHARACTER IN E
               MVI            C,2D    ;SET STANDARD I/O OPCODE
               JMP            0005    ;OUTPUT CHARACTER
;
;  SUBROUTINE LPTOUT - CALLS MONITOR TO OUTPUT A CHARACTER TO THE PRINTER DEVICE
;
LPTOUT:        ENTRY          LPTOUT
               MOV            E,M     ;PUT CHARACTER IN E
               MVI            C,5D    ;SET PUNCH OUT OPCODE
               JMP            0005    ;OUTPUT CHARACTER
;
;  SUBROUTINE TTYINE - CALLS MONITOR TO GET A BUFFER OF CHARACTERS FROM THE
;                      CONSOLE DEVICE
;
TTYINE:        ENTRY          TTYINE
               XCHG                   ;PUT ADDRESS OF BUFFER IN D AND E
               MVI            C,10D   ;SET READ CONSOLE BUFFER OPCODE
               JMP            0005    ;GET BUFFER OF CHARACTERS
;
;  SUBROUTINE RDRIN - READS A CHARACTER FROM THE READER / PUNCH PORT (PORT JT)
;
RDRIN:		ENTRY	RDRIN
		SHLD	SAVADR
RDLOOP:		MVI	A,010H		; RESET INTERRUPT BIT
		OUT	JT_CMD
		IN	JT_CMD		; GET STATUS
		ANI	001H		; CHAR READY ?
		JZ	RDLOOP		; NOPE
		IN	JT_DATA		; YEP, GET CHAR
		ANI	07FH		; STRIP OFF PARITY
		LHLD	SAVADR
		MOV	M,A
		RET
;
;  SUBROUTINE PCHOUT - WRITES A CHARACTER TO THE READER / PUNCH PORT (PORT JT)
;
PCHOUT:		ENTRY	PCHOUT
		MOV 	C,M		; GET OUTPUT CHAR
PCLOOP:		MVI	A,010H		; RESET INTERRUPT BIT
		OUT	JT_CMD
		IN	JT_CMD		; GET STATUS
		ANI	00001100B 	; BUFFER EMPTY AND DTR ?
		CPI	00001100B
  		JNZ	PCLOOP		; NOPE
		MOV	A,C		; YEP, WRITE CHARACTER
		OUT	JT_DATA
		RET
		END
 
 
 
 
 
E 1
