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'
	DB	0C0H
	DW	MESS-10
PTAT	DW	$+2
	POP	D
	LXI	H,PTAT1+1
	MOV	M,E
PTAT1	IN	0
	MOV	L,A
	MVI	H,0
	JMP	HPUSH

	DB	82H	; P!
	DB	'P'
	DB	0A1H
	DW	PTAT-5
PTSTO	DW	$+2
	POP	D
	LXI	H,PTSTO1+1
	MOV	M,E
	POP	H
	MOV	A,L
PTSTO1	OUT	0
	JMP	NEXT


;FORTH INTERFACE TO CHIPMUNK DISK OPERATING SYSTEM

CDOS	EQU	42H	;CDOS Hook Table Pointer
SRSECT	EQU	2	;CDOS 'Read Sector' code
SWSECT	EQU	4	;CDOS 'Write Sector' code

SPT	EQU	18	;Sectors per track (Numbered from 1 to 1440)
SPDRV	EQU	1440	;Sectors per drive

	DB	83H	;SEC
	DB	'SE'
	DB	0C3H
	DW	PTSTO-5
SEC	DW	DOVAR,0

	DB	85H	;TRACK
	DB	'TRAC'
	DB	0CBH
	DW	SEC-6
TRACK	DW	DOVAR,0

	DB	83H	;USE
	DB	'US'
	DB	0C5H
	DW	TRACK-8
USE	DW	DOVAR,BUF1

	DB	84H	;PREV
	DB	'PRE'
	DB	0D6H
	DW	USE-6
PREV	DW	DOVAR,BUF1

	DB	87H	;SEC/BLK
	DB	'SEC/BL'
	DB	0CBH
	DW	PREV-7
SPBLK	DW	DOCON,1

	DB	85H	;#BUFF
	DB	'#BUF'
	DB	0C6H
	DW	SPBLK-10
NOBUF	DW	DOCON,NBUF

	DB	8AH	;DISK-ERROR
	DB	'DISK-ERRO'
	DB	0D2H
	DW	NOBUF-8
DSKERR	DW	DOVAR,0

	DB	84H	;+BUF
	DB	'+BU'
	DB	0C6H
	DW	DSKERR-13
PBUF	DW	DOCOL
	DW	LIT,CO,PLUS,DUP
	DW	LIMIT,EQUAL,ZBRAN,PBUF1-$
	DW	DROP,FIRST
PBUF1	DW	DUP,PREV,AT,SUBB,SEMIS

	DB	86H	;UPDATE
	DB	'UPDAT'
	DB	0C5H
	DW	PBUF-7
UPDAT	DW	DOCOL,PREV,AT,AT
	DW	LIT,8000H,ORR
	DW	PREV,AT,STORE,SEMIS

	DB	8DH	;EMPTY-BUFFERS
	DB	'EMPTY-BUFFER'
	DB	0D3H
	DW	UPDAT-9
MTBUF	DW	DOCOL,FIRST
	DW	LIMIT,OVER,SUBB,ERASEE,SEMIS

	DB	86H	;BUFFER
	DB	'BUFFE'
	DB	0D2H
	DW	MTBUF-16
BUFFE	DW	DOCOL,USE,AT,DUP,TOR
BUFF1	DW	PBUF,ZBRAN,BUFF1-$
	DW	USE,STORE,RR,AT
	DW	ZLESS,ZBRAN,BUFF2-$
	DW	RR,TWOP,RR,AT
	DW	LIT,7FFFH,ANDD
	DW	ZERO,RSLW
BUFF2	DW	RR,STORE,RR,PREV
	DW	STORE,FROMR,TWOP,SEMIS

	DB	85H	;BLOCK
	DB	'BLOC'
	DB	0CBH
	DW	BUFFE-9
BLOCK	DW	DOCOL,OFSET,AT,PLUS,TOR
	DW	PREV,AT,DUP,AT
	DW	RR,SUBB,DUP,PLUS
	DW	ZBRAN,BLOC1-$
BLOC2	DW	PBUF,ZEQU,ZBRAN,BLOC3-$
	DW	DROP
	DW	RR,BUFFE,DUP
	DW	RR,ONE,RSLW,TWO,SUBB
BLOC3	DW	DUP,AT,RR,SUBB,DUP,PLUS
	DW	ZEQU,ZBRAN,BLOC2-$
	DW	DUP,PREV,STORE
BLOC1	DW	FROMR,DROP,TWOP,SEMIS


	DB	87H	;T&SCALC - Includes sector range checking
	DB	'T&SCAL'
	DB	0C3H
	DW	BLOCK-8
TSCALC	DW	DOCOL
	DW	DUP,ZLESS
	DW	OVER,LIT,SPDRV-1,GREAT
	DW	ORR,LIT,6,QERR
	DW	LIT,SPT,SLMOD
	DW	TRACK,STORE,ONEP,SEC,STORE,SEMIS



IOSET	LHLD	TRACK+2	;This routine sets up the registers prior to calling
	MOV	D,L	;a CDOS routine.
	LHLD	SEC+2	;D = Track # (0 to 79)
	MOV	E,L	;E = Sector # (1 to 18)
	LHLD	USE+2	;HL= Address to read/write the sector
	RET

IORET	MOV	A,E	;This routine cleans up after a CDOS call.
	JC	IORET1	;If carry is set, an error occured, so store its

	XRA	A	;error code in DISK-ERROR.
IORET1	STA	DSKERR+2
	POP	B	;Restore IP before returning to forth
	JMP	NEXT

	DB	88H	;SEC-READ - Instruct CDOS to read a sector
	DB	'SEC-REA'
	DB	0C4H
	DW	TSCALC-10
SECRD	DW	$+2
	PUSH	B	;Save the IP
	CALL	IOSET	;Setup the registers
	RST	7	;These two lines...
	DB	CDOS,SRSECT  ;are the CDOS call to do the read
	JMP	IORET

	DB	89H	;SEC-WRITE - Instruct CDOS to write a sector
	DB	'SEC-WRIT'
	DB	0C5H
	DW	SECRD-11
SECWT	DW	$+2
	PUSH	B	;Save the IP
	CALL	IOSET	;Setup the registers
	RST	7	;These two lines...
	DB	CDOS,SWSECT  ;are the CDOS call to do the write
	JMP	IORET

	DB	83H	;R/W - The Forth sector read/write command
	DB	'R/'
	DB	0D7H
	DW	SECWT-12
RSLW	DW	DOCOL,USE,AT,TOR
	DW	SWAP,SPBLK,STAR,ROT,USE,STORE
	DW	SPBLK,ZERO,XDO
RSLW1	DW	OVER,OVER,TSCALC
	DW	ZBRAN,RSLW2-$
	DW	SECRD,BRAN,RSLW3-$
RSLW2	DW	SECWT
RSLW3	DW	ONEP,LIT,80H,USE,PSTOR
	DW	XLOOP,RSLW1-$
	DW	DROP,DROP,FROMR,USE,STORE,SEMIS

	DB	85H	;FLUSH
	DB	'FLUS'
	DB	0C8H
	DW	RSLW-6
FLUSH	DW	DOCOL,NOBUF,ONEP,ZERO
	DW	XDO
FLUS1	DW	ZERO,BUFFE,DROP
	DW	XLOOP,FLUS1-$,SEMIS

	DB	84H	; LOAD
	DB	'LOA'
	DB	0C4H
	DW	FLUSH-8
LOAD	DW	DOCOL
	DW	BLK,AT,TOR,INN,AT,TOR
	DW	ZERO,INN,STORE
	DW	BSCR,STAR,BLK,STORE
	DW	INTER
	DW	FROMR,INN,STORE,FROMR,BLK,STORE,SEMIS

	DB	0C3H	; -->
	DB	'--'
	DB	0BEH
	DW	LOAD-7
ARROW	DW	DOCOL,QLOAD
	DW	ZERO,INN,STORE
	DW	BSCR,BLK,AT
	DW	OVER,MODD,SUBB,BLK,PSTOR
	DW	SEMIS


;M100 INTERFACE FOR TERMINAL

CHGET	EQU	12CBH	;Get a character from the keyboard
BRKCHK	EQU	729FH	;Check if shift-break pressed
LCD	EQU	4B44H	;Display a character of the LCD screen
LPT	EQU	6D3FH	;Send a character to the printer

EPRINT	DW	0	;Printer echo on/off flag

CPOUT	CALL	LCD	;Display A on the LCD & send to LPT if EPRINT<>0
	MOV	E,A
	LDA	EPRINT
	ORA	A
	RZ
	MOV	A,E	;This checks for linefeeds.
	CPI	LF	;Most printers dont need them.
	RZ		;Make this line a NOP if you do.
	JMP	LPT

PQTER	CALL	BRKCHK	;(?TERMINAL)
	LXI	H,0	;HL=1 if shift-break is pressed
	JNC	PQTE1
	INR	L
PQTE1	JMP	HPUSH

PKEY	CALL	CHGET	;(KEY)
	CPI	CTLC	;If its a ^C, ignore it. (We detect break elsewhere)
	JZ	PKEY
	CPI	DLE	;If its a ^P, toggle the printer echo flag.
	JNZ	PKEY1
	LXI	H,EPRINT
	MOV	A,M
	XRI	1
	MOV	M,A
	JMP	PKEY
PKEY1	MOV	L,A
	MVI	H,0
	JMP	HPUSH

PEMIT	DW	$+2	; (EMIT)
	POP	H
	PUSH	B
	MOV	A,L
	CALL	CPOUT
	POP	B
	JMP	NEXT

PCR	PUSH	B	;(CR)
	MVI	A,ACR
	CALL	CPOUT
	MVI	A,LF
	CALL	CPOUT
	POP	B
	JMP	NEXT

	;BACK TO THE VOCAB

	DB	0C1H	; '
	DB	0A7H
	DW	ARROW-6
TICK	DW	DOCOL,DFIND,ZEQU,ZERO,QERR
	DW	DROP,LITER,SEMIS

	DB	86H	;FORGET
	DB	'FORGE'
	DB	0D4H
	DW	TICK-4
FORG	DW	DOCOL,CURR,AT,CONT,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XLOOP,LIST1-$,CR,SEMIS

	DB	85H	;INDEX
	DB	'INDE'
	DB	0D8H
	DW	LIST-7
INDEX	DW	DOCOL,LIT,FF,EMIT,CR
	DW	ONEP,SWAP,XDO
INDE1	DW	CR,IDO,LIT,3,DOTR,SPACE
	DW	ZERO,IDO,DLINE
	DW	QTERM,ZBRAN,INDE2-$,LEAVE
INDE2	DW	XLOOP,INDE1-$,SEMIS

	DB	85H	;TRIAD
	DB	'TRIA'
	DB	0C4H
	DW	INDEX-8
TRIAD	DW	DOCOL,LIT,FF,EMIT
	DW	LIT,3,SLASH,LIT,3,STAR
	DW	LIT,3,OVER,PLUS,SWAP,XDO
TRIA1	DW	CR,IDO,LIST
	DW	QTERM,ZBRAN,TRIA2-$,LEAVE
TRIA2	DW	XLOOP,TRIA1-$
	DW	CR,LIT,15,MESS,CR,SEMIS

	DB	84H	; .CPU
	DB	'.CP'
	DB	0D5H
	DW	TRIAD-8
DOTCPU	DW	DOCOL,BASE,AT
	DW	LIT,36,BASE,STORE
	DW	LIT,22H,PORIG,TAT,DDOT
	DW	BASE,STORE,SEMIS

	DB	84H	;CALL
	DB	'CAL'	;This word makes it easy to use the M100 ROM routines
	DB	0CCH	;from Forth.
	DW	DOTCPU-7
CALLL	DW	$+2
	MOV	L,C
	MOV	H,B
	SHLD	CALLL2
	POP	H
	SHLD	CALLL1+1
	POP	H
	POP	D
	POP	B
	POP	PSW
CALLL1	CALL	0
	PUSH	PSW
	PUSH	B
	PUSH	D
	PUSH	H
	LHLD	CALLL2
	MOV	C,L
	MOV	B,H
	JMP	NEXT
CALLL2	DW	0

	DB	84H	;TASK
	DB	'TAS'
	DB	0CBH
	DW	CALLL-7
TASK	DW	DOCOL,SEMIS

INITDP	DB	0

	END


