.PAGE
;*******************************************************
;*						       *
;*	     PORT INPUT/OUTPUT			       *
;*						       *
;*  COPYRIGHT (c) 1982, 1983  SAGE Computer Technology *
;*  All Rights Reserved				       *
;*						       *
;*******************************************************

CMPX
	BSR	TERMSPAC
	BSR	TERMSPAC
	LEA	SCMP,A1		;Execute command
	BRA	SRCHCMND
	
;Port input commands

CMPIX
	LEA	SCMPI,A1	;Execute command
	BRA	SRCHCMND

;PIB [$X+]XXXXXX - input a byte from a port

CMPIB
	BSR	CNVTADDR	;Get port address
	BNE	CMNDERRA	;Address error
	MOVE.L	A1,D0		;Print address
	BSR	TERMHEXL
	BSR	TERMCOLN
	MOVE.B	(A1),D0		;Print port value
	BSR	TERMHEXB
	RTS

;PIW [$X+]XXXXXX - Input word from port

CMPIW
	BSR	CNVTADDR	;Get port address
	BNE	CMNDERRA	;Address error
	MOVE.W	A1,D6		;Must be on word boundry
	BTST	#0,D6
	BNE	CMNDERRA
	MOVE.L	A1,D0		;Print address
	BSR	TERMHEXL
	BSR	TERMCOLN
	MOVE.W	(A1),D0		;Print port value
	BSR	TERMHEXW
	RTS
	
;Port output commands

CMPO
	LEA	SCMPO,A1	;Execute command
	BRA	SRCHCMND

;POB [$X+]XXXXXX - Output a byte to a port

CMPOB
	BSR	CNVTADDR	;Get port address
	BNE	CMNDERRA	;Address error
	MOVE.L	#0FFH,D1	;Get data to move to port
	BSR	GETDATA
	BNE	CMNDERRA	;No
	MOVE.B	D0,(A1)		;Print port value
	RTS

;POW [$X+]XXXXXX - Output a word to a port

CMPOW
	BSR	CNVTADDR	;Get port address
	BNE	CMNDERRA	;Address error
	MOVE.W	A1,D6		;Must be on word boundry
	BTST	#0,D6
	BNE	CMNDERRA	;Not on word boundry
	MOVE.L	#0FFFFH,D1	;Get data to move to port
	BSR	GETDATA
	BNE	CMNDERRA	;No
	MOVE.W	D0,(A1)		;Print port value
	RTS
	
;PS X - Set auxillary baud rate

CMPS
	BSR	SKIPSPAC	;Move to baudrate
	MOVEQ	#7,D2		;Get baudrate
	BSR	GETNUM
	BMI	CMNDERRA	;Error detected
	MOVE.L	D0,D1
	BRA	AUXBAUD		;Set aux baud

                                                                                                                                                                                             