
;****************************************************************
;*								*
;*	    CONSOLE INPUT INTERRUPT SERVICE ROUTINES		*
;*								*
;****************************************************************

;			OSCOR-1
;			29 OCTOBER 1980
;			R. DAVID POGGE

			NAME CIINT
			ORG 0H

;	GLOBAL ADDRESSES

	OUTPUT	EQU	0043H

;	I/O PORTS

	CI	EQU	0H

;	VARIABLES

	BUFF	EQU	8032H
	IBUFBM	EQU	0H
	IBUFTP	EQU	0H
	INBUFS	EQU	0H

























;****************************************************************
;* CIINT:							*
;*			CONSOLE INPUT INTERRUPT			*
;*								*
;****************************************************************

;	WHEN A CONSOLE INPUT INTERRUPT OCCURS THE PROGRAM MUST
;	DETERMINE IF THE CONSOLE IS IN THE INPUT BUFFER MODE OR THE
;	CONSOLE INPUT COMMAND MODE. IT DOES HIS BY CHECKING
;	THE INPUT BUFFER STATUS REGISTER. IF THE TWO LEAST SIGNIFICANT
;	BITS ARE "01" IT IS IN THE INPUT BUFFER MODE AND WILL CALL
;	THE INBUFI SERVICE ROUTINE. IF THE TWO LEAST SIGNIFICANT BITS
;	ARE "10" IT IS IN THE CONSOLE INPUT COMMAND MODE, AND WILL
;	CALL THE CIC SERVICE ROUTINE.

CIINT:	PUSH PSW	; SAVE ALL REGISTERS
	PUSH B
	PUSH D
	PUSH H
	LDA INBUFS
	ANI 11B		; CHECK TWO LSB'S OF INPUT BUFFER STATUS REGISTER
	CPI 01B
	CZ INBUFI	; IF "01", CALL INPUT BUFFER INTERRUPT SERVICE ROUTINE
	LDA INBUFS
	ANI 11B
	CPI 10B
	CZ CIC		; IF "10", CALL CONSOLE INPUT COMMAND SERVICE ROUTINE
	POP H		; RESTORE REGISTERS
	POP D
	POP B
	POP PSW
	EI		; ENABLE INTERRUPTS
	RET		; AND RETURN






















;****************************************************************
;* INBUFI:							*
;*		INPUT BUFFER INTERRUPT SERVICE ROUTINE		*
;*								*
;****************************************************************

;	IF THE INPUT BUFFER IS FILLED WHEN THIS ROUTINE IS CALLED,
;	IT WILL SIMPLY RING THE BELL AND IGNORE THE INPUT. OTHERWISE,
;	IT WILL PUT THE NEW DATA ON THE TOP OF THE BUFFER AND INCREMENT
;	THE "INPUT BUFFER TOP" POINTER (MODULO 80). WHEN THERE ARE 79
;	CHARACTERS IN THE BUFFER, THE BUFFER IS FULL, SO THE BUFFER FULL
;	BIT (BIT 6) OF THE INPUT BUFFER STATUS REGISTER IS SET.
;	EACH TIME A CHARACTER IS INSERTED INTO THE BUFFER, THE BUFFER
;	EMPTY STATUS BIT (BIT 7) OF THE INPUT BUFFER STATUS REGISTER
;	IS CLEARED.

INBUFI:	RAL		; CHECK BUFFER FULL BIT OF INPUT BUFFER STATUS REGISTER
	RAL
	JNC IB2A
IB1:	MVI A,07H	; BUFFER IS FULL
	JMP OUTPUT	; RING BELL AND RETURN
IB2A:	IN CI		; LET A = DATA FROM CONSOLE INPUT DEVICE
	LXI D,BUFF
	LHLD IBUFTP
	MVI H,0
	DAD D		; LET H/L = BUFFER STARTING ADDRESS + TOP POINTER
	MOV M,A		; MOVE DATA TO TOP OF BUFFER
IB2B:	LDA IBUFTP
	INR A		; LET IBUFTP = IBUFTP + 1 (MODULO 80)
	CPI 80
	JNZ IB2B1
	XRA A
IB2B1:	STA IBUFTP
IB2C:	INR A		; IF TOP OF BUFFER IS NOW 1 LESS THAN THE BOTTOM OF BUFFER
	CPI 80
	JNZ IB2C1
	XRA A
IB2C1:	LXI H,IBUFBM
	CMP M
	JNZ IB2D
IB2CA:	LDA INBUFS	; THEN SET THE BUFFER FULL FLAG IN THE IN BUFFER STATUS REG.
	ORI 01000000B
	STA INBUFS
IB2D:	LDA INBUFS	; ALWAYS CLEAR THE BUFFER EMPTY FLAG
	ANI 01111111B
	STA INBUFS
	RET		; AND RETURN








;****************************************************************
;* CIC:								*
;*		CONSOLE INPUT COMMAND SERVICE ROUTINE		*
;*								*
;****************************************************************

;	THE CONSOLE INPUT COMMAND MODE IS USED TO INTERRUPT WHATEVER
;	PROCESSING OSCOR IS CURRENTLY PERFORMING TO EXECUTE A COMMAND.
;	(COMMAND EXAMPLES ARE "STOP THE CART", "TURN ON THE TDD",
;	"BEGIN TAKING DATA", ETC.) AFTER THE COMMAND HAS BEEN SERVICE
;	IT WILL RETURN TO NORMAL PROCESSING.

CIC:	RET

	END
************************************************
;* CIC:								*
;*		CONSOLE INPUT COMMAND SERVICE RO