; cmslcml.asm
; SLC Machine language assist

; L. Stewart, September 10, 1982  11:07 AM
; added reset interrupts, September 10, 1982  11:07 AM
; removed stat stuff, December 3, 1982  2:21 PM

; interrupt data

slrcmd	EQU	020H
slrccbhi EQU	021H
slrccblo EQU	022H
sltcmd	EQU	024H
sltccbhi EQU	025H
sltccblo EQU	026H
stoffset EQU	004H
ctoffset EQU	003H
adoffset EQU	001H
cmoffset EQU	000H

C←CODE SEGMENT

C←DATA	SEGMENT

←eneta	DB	?
←lccb	DB	5 DUP(?)
sltmode	DB	?
slrmode	DB	?

C←DATA	ENDS

ASSUME CS:C←CODE, DS:C←DATA

; start slt, address of ccb in BX
←sltstart	PROC	NEAR
	XOR	AL,AL
	MOV	[stoffset+BX],AL
	MOV	AL,BL
	OUT	sltccblo,AL
	MOV	AL,BH
	OUT	sltccbhi,AL
	MOV	AL,0CH
	OUT	sltcmd,AL
	RET
←sltstart	ENDP

; start slr, address of ccb in BX
←slrstart	PROC	NEAR
	XOR	AL,AL
	MOV	[stoffset+BX],AL
	MOV	AL,BL
	OUT	slrccblo,AL
	MOV	AL,BH
	OUT	slrccbhi,AL
	MOV	AL,0CH
	OUT	slrcmd,AL
	RET
←slrstart	ENDP

; initialize SLR
←slrinit	PROC	NEAR
; reset SLR 
	MOV	AL,0
	MOV	slrmode,AL
	MOV	AL,0FH
	OUT	slrcmd,AL	; reset IO
	MOV	AL,0C8H
	OUT	slrcmd,AL	; disable interrupts
; set modes and address
	MOV	BX,OFFSET ←lccb
	MOV	BYTE PTR [cmoffset+BX],0E0H
	MOV	WORD PTR [adoffset+BX],OFFSET slrmode
	MOV	BYTE PTR [ctoffset+BX],0FFH
	CALL	←slrstart
	CALL	←waitccb
	MOV	BYTE PTR [cmoffset+BX],0C0H
	MOV	WORD PTR [adoffset+BX],OFFSET ←eneta
	MOV	BYTE PTR [ctoffset+BX],0FFH
	CALL	←slrstart
	CALL	←waitccb
	RET
←slrinit	ENDP

; initialize SLT
←sltinit	PROC	NEAR
; reset SLT
	MOV	AL,0
	MOV	sltmode,AL
	MOV	AL,0FH
	OUT	sltcmd,AL	; reset
	MOV	AL,0C8H
	OUT	sltcmd,AL	; disable interrupts
; set modes and address
	MOV	BX,OFFSET ←lccb
	MOV	BYTE PTR [cmoffset+BX],0E0H
	MOV	WORD PTR [adoffset+BX],OFFSET sltmode
	MOV	BYTE PTR [ctoffset+BX],001H
	CALL	←sltstart
	CALL	←waitccb
	RET
←sltinit	ENDP

; initialize SLC. address in BL
←slcinit	PROC	NEAR
; save address
	MOV	←eneta,BL
	CALL	←slrinit
	CALL	←sltinit
	RET
←slcinit	ENDP

; wait for completion of ccb in BX
←waitccb	PROC	NEAR
wsl:	MOV	AL,[stoffset+BX]
	AND	AL,080H
	JZ	 wsl
	RET
←waitccb	ENDP

; return SLR status in BL
←slrstat   PROC   NEAR
   XOR  AH,AH
   IN   AL,slrcmd
   MOV  BX,AX
   RET
←slrstat   ENDP

PUBLIC	←slrstart
PUBLIC	←sltstart
PUBLIC	←slrinit
PUBLIC	←slcinit
PUBLIC	←waitccb
PUBLIC  ←slrstat

C←CODE ENDS
	END