****************************************************
*      DIRECTORY ASSISTANT ROUTINES                *
****************************************************
	ORG	0
	DC.W	RTEND
	DC.W	8
	DC.B	'LDINTL      '
	DC.W	LDINTL
	DC.B	'LDINTEL2    '
	DC.W	LDINTL
	DC.B	'LDINTEL4    '
	DC.W	LDINTL4
	DC.B	'STDNTL      '
	DC.W	STDNTL
	DC.B	'STINTEL2    '
	DC.W	STDNTL
	DC.B	'STINTEL4    '
	DC.W	STDNTL4
	DC.B	'NXTFAT      '
	DC.W	NXTFAT
	DC.B	'EXGO        '
	DC.W	EXGO
*****************************************************
	ORG	0
;---- these routines help htpl cope with MSDOS disks
;---- load intel word  ( adrs -- word )
LDINTL	MOVEA.L	(A4),A0		;GET ADRESS
	CLR.L	D0		;HIGH ORDER 0
	ADDQ.W	#2,A0
	MOVE.B	-(A0),D0	;GET HIGH BYTE
	LSL.W	#8,D0		;MOVE LEFT
	MOVE.B	-(A0),D0	;GET LOW BYTE
	MOVE.L	D0,(A4)		;PUT ON STACK
	RTS
;---- load intel long  ( adrs -- long )
LDINTL4	MOVEA.L	(A4),A0		;GET ADRESS
	CLR.L	D0		;HIGH ORDER 0
	ADDQ.W	#4,A0
	MOVE.B	-(A0),D0	;GET HIGH BYTE
	LSL.L	#8,D0		;MOVE LEFT
	MOVE.B	-(A0),D0
	LSL.L	#8,D0
	MOVE.B	-(A0),D0
	LSL.L	#8,D0
	MOVE.B	-(A0),D0	;GET LOW BYTE
	MOVE.L	D0,(A4)		;PUT ON STACK
	RTS
;---- store intel word ( word adrs -- )
STDNTL	MOVEA.L	(A4)+,A0	;GET ADRESS
	MOVE.L	(A4)+,D0	;GET DATA
	MOVE.B	D0,(A0)+	;SAVE LOW
	LSR.W	#8,D0
	MOVE.B	D0,(A0)+	;SAVE HIGH
	RTS
;---- store intel long ( long adrs -- )
STDNTL4	MOVEA.L	(A4)+,A0	;GET ADRESS
	MOVE.L	(A4)+,D0	;GET DATA
	MOVE.B	D0,(A0)+	;SAVE LOW
	LSR.L	#8,D0
	MOVE.B	D0,(A0)+
	LSR.L	#8,D0
	MOVE.B	D0,(A0)+
	LSR.L	#8,D0
	MOVE.B	D0,(A0)+	;SAVE HIGH
	RTS
;---- get next alloc from fat ( fatadr aloc -- naloc )
NXTFAT	MOVE.L	(A4)+,D0	;OLD ALLOC BLOCK
	MOVEA.L	(A4),A0		;FAT ADRS
	CLR.L	D2		;SET FOR BYTES
	MULU	#3,D0		; 12 BIT WORDS *3/2
	LSR.L	#1,D0
	BCS	NXT100
	MOVE.B	1(A0,D0),D2	;RESULT WAS EVEN
	LSL.L	#8,D2		;MAKE HIGH
	MOVE.B	0(A0,D0),D2	;GET LOW
	ANDI.W	#0FFFH,D2	;MASK IT
	MOVE.L	D2,(A4)		;PUT BACK ON STACK
	RTS
NXT100	MOVE.B	1(A0,D0),D2	;RESULT WAS ODD
	LSL.L	#8,D2		;GET HIGH
	MOVE.B	0(A0,D0),D2	;GET LOW
	LSR.L	#4,D2		;ALIGN ON RIGHT
	ANDI.W	#0FFFH,D2	;KEEP ONLY LAST 12
	MOVE.L	D2,(A4)		;BACK ON STACK
	RTS
***********************************************************
EXGO				;GO TO EXCEPTION HANDLER
	MOVEA.L	(A4)+,A0	;POINTER TO INFO SPACE
	ADDA.W	#64,A0		;POINT ABOVE NEW STACK POINTER
	MOVE.L	(A0),D0		;GET NEW STATUS REGISTER
	MOVEA.L	-(A0),A1	;GET NEW STACK POINTER
	BTST	#13,D0		;IF SUPERVISOR HANDLER
	BEQ.S	EXGO10
	MOVEA.L	A1,SP		;  THEN LOAD NEW SSP
	BRA.S	EXGO20
EXGO10	MOVE.L	A1,USP		;  ELSE LOAD NEW USP
EXGO20	MOVE.L	(A4)+,-(SP)	;PUSH ADDRESS OF HANDLER FOR RTE
	MOVE.W	D0,-(SP)	;PUSH NEW STATUS REGISTER FOR RTE
	MOVEQ	#14,D0
EXGO30	MOVE.L	-(A0),-(SP)	;PUSH NEW A6..A0,D7..D0
	DBRA	D0,EXGO30
	MOVEM.L	(SP)+,#07FFFH	;LOAD NEW A6..A0,D7..D0
	RTE			;LOAD NEW SR,PC
***********************************************************
RTEND	EQU	$		;RTL SIZE
	END

