
;	C P N E T S T S - FOR CP/NET-86
;--------------------------------------------
;  CP/NET NETWORK STATUS DISPLAY PROGRAM
;
TITLE	'NETWORK STATUS DISPLAY FOR CP/NET-86'
;
;  AUG-31-1983	BASE 
;
;  EQUATION OF FIXED ADDRESS
;
BDOS	EQU	224			;BDOS ENTRY POINT
;
;  EQUATION OF BDOS FUNCTION CODE
;
FGETV	EQU	12			;GET VERSION NUMBER
FGETNS	EQU	68			;GET NETWORK STATUS
FGETCT	EQU	69			;GET CONFIGURATION TABLE ADDRESS
;
;  EQUATION OF OTHER DATA
;
M	EQU	BYTE PTR 0[BX]
LF	EQU	0AH			;LINE FEED CODE
CR	EQU	0DH			;CARRIAGE RETURN CODE
ETX	EQU	'$'			;TERMINATION CHARACTER
;
;  PROGRAM START
;
	ORG	100H
;
	JMP	START
L_1	EQU	$
	DSEG
	ORG	OFFSET L_1
;
;  DISPLAY MESSAGE AREA
;
MSG1	RS	0
	DB	CR,LF,'CP/NET-86 1.0 Status'
	DB	CR,LF,'===================='
	DB	CR,LF,ETX
MSG2	RS	0
	DB	'Requester ID = '
	DB	ETX
MSG3	RS	0
	DB	CR,LF,'Network Status Byte = '
	DB	ETX
MSG4	RS	0
	DB	CR,LF,'Disk device status:'
	DB	CR,LF,ETX
MSG5	RS	0
	DB	'  Drive '
	DB	ETX
MSG6	RS	0
	DB	' = Drive '
	DB	ETX
MSG7	RS	0
	DB	' on Network Server ID = '
	DB	ETX
MSG8	RS	0
	DB	' = LOCAL'
	DB	ETX
MSG9	RS	0
	DB	'Console Device = '
	DB	ETX
MSG10	RS	0
	DB	'Console #'
	DB	ETX
MSG11	RS	0
	DB	' on Network Server ID = '
	DB	ETX
MSG12	RS	0
	DB	'LOCAL'
	DB	ETX
MSG13	RS	0
	DB	'List Device = '
	DB	ETX
MSG14	RS	0
	DB	'List #'
	DB	ETX
MSG15	RS	0
	DB	' on Network Server ID = '
	DB	ETX
MSG16	RS	0
	DB	'LOCAL'
	DB	ETX
MSG17	RS	0
	DB	CR,LF,'CP/NET-86 has not been loaded.'
	DB	ETX
L_2	EQU	$
	CSEG
	ORG	OFFSET L_2
;
;  START OF PROGRAM
;
START:
	MOV	BX,0
	LAHF
	ADD	BX,SP
	RCR	SI,1
	SAHF
	RCL	SI,1
	MOV	Word Ptr OLDSP,BX	;SAVE SYSTEM STACK
	MOV	SP,(OFFSET NEWSP)
	CALL	GETVER			;GET CP/M VERSION NUBMER
	MOV	DX,0200H
	CALL	ANDHD
	MOV	AL,0
	CALL	SUBHD
	OR	AL,BL			;CHECK CP/NET LOADED
	JNZ	L_3	
	JMP	NOTNET			;CP/NET UNLOADED
L_3:
	MOV	CX,(OFFSET MSG1)	;TITLE DISPLAY
	CALL	MSGOUT
	CALL	GETCTA			;GET CONFIGURATION TABLE ADDRESS
	MOV	WORD PTR CTBADR,BX	;SAVE TABLE ADDRESS
	MOV	CX,(OFFSET MSG2)	;'REQUESTER ID = '
	CALL	MSGOUT
	MOV	BX,WORD PTR CTBADR	;GET CONFIG TABLE ADDRESS
	LAHF
	INC	BX
	SAHF
	MOV	CL,ES:M			;GET REQUESTER ID CODE
	CALL	DSPBCD			;DISPLAY ID NUMBER
	MOV	CX,(OFFSET MSG3)	;'NETWORK STATUS BYTE = '
	CALL	MSGOUT
	CALL	GETNST			;GET NETWORK STATUS
	MOV	CL,AL
	CALL	DSPBCD			;DISPLAY NETWORK STATUS BYTE
	MOV	CX,(OFFSET MSG4)	;'DISK DEVICE STATUS: '
	CALL	MSGOUT
	MOV	BX,(OFFSET DEVCNT)
	MOV	M,0
;
DRVDSP:
	MOV	AL,15
	MOV	BX,(OFFSET DEVCNT)	;SET DEVICE COUNT
	CMP	AL,M
	JNB	L_4	
	JMP	CONDSP			;CONSOLE DEVICE DISPLAY
L_4:
	MOV	CX,(OFFSET MSG5)	;'DRIVE '
	CALL	MSGOUT
	MOV	AL,BYTE PTR DEVCNT	;GET DEVICE COUNT
	ADD	AL,'A'			;ADJUST TO A-P
	MOV	CL,AL
	CALL	CONOUT			;DISPLAY DRIVE NUMBER
	MOV	CL,':'
	CALL	CONOUT			;DISPLAY ':'
	MOV	BX,WORD PTR DEVCNT
	MOV	BH,0
	MOV	CX,2
	SHL	BX,1
	ADD	BX,CX
	XCHG	BX,DX
	MOV	BX,WORD PTR CTBADR	;GET CONFIG TABLE ADDRESS
	ADD	BX,DX
	MOV	BL,ES:M
	MOV	AL,BL
	MOV	BYTE PTR WCDFLG,AL
	AND	AL,80H
	CMP	AL,0
	JZ	DLOCAL			;DISPLAY 'LOCAL'
	MOV	CX,(OFFSET MSG6)	;' = DRIVE '
	CALL	MSGOUT
	MOV	AL,BYTE PTR WCDFLG
	AND	AL,0FH
	ADD	AL,'A'
	MOV	CL,AL
	CALL	CONOUT			;DISPLAY DRIVE NUMBER
	MOV	CL,':'
	CALL	CONOUT			;DISPLAY ':'
	MOV	CX,(OFFSET MSG7)	;' ON NETWORK SERVER ID = '
	CALL	MSGOUT
	MOV	BX,WORD PTR DEVCNT
	MOV	BH,0
	MOV	CX,2
	SHL	BX,1
	LAHF
	ADD	BX,CX
	SAHF
	XCHG	BX,DX
	MOV	BX,WORD PTR CTBADR	;GET CONFIG TABLE ADDRESS
	LAHF
	ADD	BX,DX
	RCR	SI,1
	SAHF
	RCL	SI,1
	LAHF
	INC	BX
	SAHF
	MOV	AL,ES:M
	MOV	CL,AL
	CALL	DSPBCD
	JMPS	DSKEND
;
;  DISPLAY 'LOCAL' FOR DISK DRIVE
;
DLOCAL:
	MOV	CX,(OFFSET MSG8)	;' = LOCAL'
	CALL	MSGOUT
DSKEND:
	CALL	CRLF			;CR,LF
	MOV	BX,(OFFSET DEVCNT)
	INC	M
	JZ	L_5	
	JMP	DRVDSP
L_5:
;
CONDSP:
	MOV	CX,(OFFSET MSG9)	;'CONSOLE DEVICE = '
	CALL	MSGOUT
	MOV	CX,34
	MOV	BX,WORD PTR CTBADR	;GET CONFIG TABLE ADDRESS
	ADD	BX,CX
	MOV	BL,ES:M			;GET CONSOLE DEVICE CONDITION FLAG
	MOV	AL,BL
	MOV	BYTE PTR WCDFLG,AL	;STORE CONDITION BYTE
	AND	AL,80H			;MSB CHECK
	CMP	AL,0
	JZ	CLOCAL			;DISPLAY 'LOCAL'
	MOV	CX,(OFFSET MSG10)	;'CONSOLE #'
	CALL	MSGOUT
	MOV	AL,BYTE PTR WCDFLG	;GET CONDITION BYTE
	AND	AL,0FH			;CLEAR UPPER NIBBLE
	MOV	CL,AL
	CALL	HEXDSP
	MOV	CX,(OFFSET MSG11)	;'ON NETWORK SERVER ID = '
	CALL	MSGOUT
	MOV	CX,34
	MOV	BX,WORD PTR CTBADR	;GET COFING TABLE ADDRESS
	LAHF
	ADD	BX,CX
	RCR	SI,1
	SAHF
	RCL	SI,1
	LAHF
	INC	BX
	SAHF
	MOV	AL,ES:M			;GET CONSOLE DEVICE (SERVER ID)
	MOV	CL,AL
	CALL	DSPBCD
	JMPS	LSTDSP			;LIST DEVICE DISPLAY
;
CLOCAL:
	MOV	CX,(OFFSET MSG12)	;'LOCAL'
	CALL	MSGOUT
;
LSTDSP:
	CALL	CRLF
	MOV	CX,(OFFSET MSG13)	;'LIST DEVICE = '
	CALL	MSGOUT
	MOV	CX,36
	MOV	BX,WORD PTR CTBADR	;GET COFIG TABLE ADDRESS
	ADD	BX,CX
	MOV	BL,ES:M			;GET LIST DEVICE CONDITION FLAG
	MOV	AL,BL
	MOV	BYTE PTR WCDFLG,AL
	AND	AL,80H			;MSB CHECK
	CMP	AL,0
	JZ	LLOCAL			;DISPLAY 'LOCAL'
	MOV	CX,(OFFSET MSG14)	;'LIST # '
	CALL	MSGOUT
	MOV	AL,BYTE PTR WCDFLG
	AND	AL,0FH
	MOV	CL,AL
	CALL	HEXDSP
	MOV	CX,(OFFSET MSG15)	;' ON NETWORK SERVER ID = '
	CALL	MSGOUT
	MOV	CX,36
	MOV	BX,WORD PTR CTBADR	;GET CONFIG TABLE ADDRESS
	LAHF
	ADD	BX,CX
	RCR	SI,1
	SAHF
	RCL	SI,1
	LAHF
	INC	BX
	SAHF
	MOV	AL,ES:M			;GET LIST DEVICE
	MOV	CL,AL
	CALL	DSPBCD			;DISPLAY LIST DEVICE NUMBER (SERVER ID)
	JMPS	ENDSTS
;
LLOCAL:
	MOV	CX,(OFFSET MSG16)	;'LOCAL'
	CALL	MSGOUT
	JMPS	ENDSTS
;
;  PROGRAM ABORT FOR CP/NET UNLOADED
;
NOTNET:
	MOV	CX,(OFFSET MSG17)	;'CP/NET 1.2 HAS NOT BEEN LOADED.'
	CALL	MSGOUT
;
;  RETURN TO SYSTEM
;
ENDSTS:				;END OF CPNETSTS
	CALL	RETSYS			;RETURN TO SYSTEM
	STI
	HLT				;ERROR STOP
;
;  SET SYSTEM STACK
;
RETSYS:
	MOV	BX,WORD PTR OLDSP	;GET SYSTEM STACK
	MOV	SP,BX
	IRET				;RETURN TO SYSTEM
;
;  CONSOLE OUT
;
CONOUT:
	MOV	DL,CL
	MOV	CL,2
	INT	BDOS
	RET
;
;  MESSAGE STRING OUT
;  INPUT
;  BC:TEXT ADDRESS
;
MSGOUT:
	MOV	DH,CH			;SET MESSAGE TEXT ADDRESS
	MOV	DL,CL
	MOV	CL,9
	INT	BDOS
	RET
;
;  GET CP/M VERSION NUMBER
;  OUTPUT
;   H:CP/M OR MP/M
;   L:VERSION NUMBER
;
GETVER:
	MOV	DX,0
	MOV	CL,FGETV
	INT	BDOS
	RET
;
;  GET NETWORK STATUS
;  OUTPUT
;   A:NET WORK STATUS BYTE
;
GETNST:
	MOV	DX,0
	MOV	CL,FGETNS
	INT	BDOS
	RET
;
;  GET REQUESTER CONFIGURATION TABLE ADDRESS
;  OUTPUT
;  HL:TABLE ADDRESS
;
GETCTA:
	MOV	DX,0
	MOV	CL,FGETCT
	INT	BDOS
	RET
;
;  PUT CR,LF TO CONSOLE
;
CRLF:
	MOV	CL,CR			;SET CR CODE
	CALL	CONOUT
	MOV	CL,LF			;SET LF CODE
	CALL	CONOUT
	RET
;
;  DISPLAY HEXA DECIMAL
;
HEXDSP:
	MOV	BX,(OFFSET WHEXVA)
	MOV	M,CL
	MOV	AL,9
	MOV	BX,(OFFSET WHEXVA)
	CMP	AL,M
	JNB	HEXOVR
	MOV	AL,BYTE PTR WHEXVA
	ADD	AL,'A'			;ADJUST TO ASCII CODE
	SUB	AL,10
	MOV	CL,AL
	CALL	CONOUT
	RET
;
HEXOVR:
	MOV	AL,BYTE PTR WHEXVA
	ADD	AL,'0'			;ADJUST TO ASCII CODE
	MOV	CL,AL
	CALL	CONOUT
	RET
;
;  DISPLAY BCD VALUE
;
DSPBCD:
	MOV	BX,(OFFSET WACONV)
	MOV	M,CL
	MOV	AL,BYTE PTR WACONV
	AND	AL,0F8H
	RCR	AL,1
	RCR	AL,1
	RCR	AL,1
	RCR	AL,1
	MOV	CL,AL
	CALL	HEXDSP
	MOV	AL,BYTE PTR WACONV
	AND	AL,00FH
	MOV	CL,AL
	CALL	HEXDSP
	MOV	CL,48H
	CALL	CONOUT
	RET
;
ANDHD:
	MOV	AL,DL
	AND	AL,BL
	MOV	BL,AL
	MOV	AL,DH
	AND	AL,BH
	MOV	BH,AL
	RET
;
SUBHD:
	MOV	DL,AL
	MOV	DH,0
	MOV	AL,DL
	SUB	AL,BL
	MOV	BL,AL
	MOV	AL,DH
	SBB	AL,BH
	MOV	BH,AL
	RET
L_6	EQU	$
	DSEG
	ORG	OFFSET L_6
;
;  WORKING STRAGE AREA
;
	RS	40			;LOCAL STACK AREA
NEWSP	RS	0			;LOCAL STACK POINT
OLDSP	RS	2			;SYSTEM STACK SAVE
OUTCHR	RS	1			;OUTPUT CHARACTER
WHEXVA	RS	1			;WORK FOR HEX CONVERT
WACONV	RS	1			;FOR ASCII CONVERT
DEVCNT	RS	1			;DEVICE COUNTER
WCDFLG	RS	1			;CONDITION BYTE SAVE AREA
CTBADR	RS	2			;COFIGURATION TABLE ADDRESS SAVE AREA
;
	END
