h45428
s 00090/00000/00000
d D 1.1 83/03/17 17:43:31 bog 1 0
c date and time created 83/03/17 17:43:31 by bog
e
u
4
U
t
T
I 1
;
;  CP/M 80 I/O ROUTINES - ***** FOR 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.
;  SUBROUTINES TTYOUT, LPTOUT AND PCHOUT USE A CP/M MONITOR CALL TO
;  PERFORM THEIR 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.  SUBROUTINES TTYIN, TTYINW  AND RDRIN ALSO USE
;  A MONITOR CALL TO GET A CHARACTER FROM THE CONSOLE OR READER DEVICE.
;  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.
;
;  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 PCHOUT - CALLS MONITOR TO OUTPUT A CHARACTER TO THE PUNCH DEVICE
;
PCHOUT:        ENTRY          PCHOUT
               MOV            E,M     ;PUT CHARACTER IN E
               MVI            C,4D    ;SET PUNCH OUT 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 RDRIN - CALLS MONITOR TO GET A CHARACTER FROM THE READER DEVICE
;
RDRIN:         ENTRY          RDRIN
               SHLD           SAVADR  ;SAVE ARGUMENT ADDRESS
               MVI            C,3D    ;SET READER IN OPCODE
               CALL           0005    ;INPUT CHARACTER INTO A
               ANI            7FH     ;STRIP OFF HIGH ORDER BIT
               LHLD           SAVADR  ;GET ARGUMENT ADDRESS
               MOV            M,A     ;RETURN CHARACTER TO CALLING ROUTINE
               RET
;
;  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
               END
E 1
