*
*	Disassembled by:
*		DASMx object code disassembler
*		(c) Copyright 1996-2003   Conquest Consultants
*		Version 1.40 (Oct 18 2003)
*
*	File:		12k.bin
*
*	Size:		23296 bytes
*	Checksum:	5F56
*	CRC-32:		6977611D
*
*	Date:		Tue Jan 05 08:51:51 2021
*
*	CPU:		Signetics 2650 (2650 family)
*
*
*	BASIC START AT 'STRT'


P	EQU	1
N	EQU	2
Z	EQU	0
LCOM	EQU	$02	;LOGICAL COMPARE
CAR	EQU	$01	;CARRY BIT
SENSE	EQU	$80	;SENSE BIT
FLAG	EQU	$40	;FLAG BIT
II	EQU	$20	;INTERRUPT INHIBIT BIT
IDC	EQU	$20	;INTERDIGIT CARRY (BCD)
OVF	EQU	$04	;OVERFLOW
*R0	EQU	0	;R0      ALWAYS AVAILABLE
*R1	EQU	1	;R1 }
*R2	EQU	2	;R2 } BANK 0 (PSL bit4 = 0 )
*R3	EQU	3	;R3 }
UN	EQU	3	;R1
EQ	EQU	0	;R2 } BANK 1 PSL bit4 = 1 )
LT	EQU	2	;R3
GT	EQU	1
WC	EQU	$08	;WITH CARRY , WHEN SET ADD /SUB CONSIDER CARRY
RS	EQU	$10	;REGISTER BANK SELECT
ZSPAC	EQU	$20	;SPACE
BMAX	EQU	3	;NUMBER OF SETTABLE BKPTS-1
DELE	EQU	$7F	;DELETE
CR	EQU	13	;ASCII FOR CARRIAGE RETURN
LF	EQU	10	;ASCII  FOR LINE FEED (NOTUSED)
BLEN	EQU	20	; length of buffer
STAR	EQU	':'	;ASCII FOR :
PLUS	EQU	'+'	;ASCII FOR +
BDSI	EQU	$0F	;VALUE IN DLY IN/OUT ROUTINE FOR 9600 BD INPUT
BDSO	EQU	$11	;VALUE IN DLY OUT ROUTINE FOR 9600 BD
BDS2	EQU	$07	;VALUE IN DLY50 ROUTINE FOR 9600 BD  at 2MHz 0f
BLOCK	EQU	$20	;block size on dump
VERSIE	EQU	'3'	;VERSION NUMBER
V1	EQU	'9'
V2	EQU	'3' 	; VERSION 12.2

RETU	EQU	$0083
SERIN	EQU	$0219	;supervisor address / change for pipbug
SEROUT	EQU	$024F
SUMC	EQU	$17F6
L0733	EQU	$6667    ; UIT PAPER LISTING ERROR ?

*TEXT BUFFER AT 6000
*INSERT BUFFER AT 5A00


	org	$2000
*

*
STRT:
X2000		bcta,un	BSET
*
BUFFSTART		db	$58
INSBUFF		db	$5D
VARSTART		db	$5E
ENDRAM		db	$60
PRNT		db	$17
PRNVEC		dw	1
TABEND		dw	1
*
BASIC:
	lodi,r0	$02
	lpsl
	lodr,r0	ENDRAM
	stra,r0	SP
	lodr,r0	BUFFSTART
	stra,r0	DATPNT
	bsta,un	PURGES
	stra,r0	PDATA
	stra,r0	ERWAIT
	stra,r0	INON
	stra,r0	SP+1
	stra,r0	PDATA
	stra,r0	PCLFCR
	bcta,un	L3E37
*
BASIC0:
	lodr,r2	INSBUFF
	stra,r2	CTEMP
BASWARM:
	strz	r1
BASIC1	stra,r0	*CTEMP,r1,-
	brnr,r1	BASIC1
	loda,r1	CTEMP	;changes to listing
	addi,r1	$01
	stra,r1	CTEMP
	coma,r1	VARSTART
	bctr,lt	BASWARM
	retc,un
*
	db	$45, $91
*
L204C:
	lodi,r3	$00
	bsta,un	DECSP
	bsta,un	FPSIN
	retc,un
*
	DS	2
*
SBLIN:
	bsta,un	LFCR
SBLIN2:
	brnr,r2	SBLIN3
	lodi,r0	$5E
	bsta,un	WRT
SBLIN3:
	subi,r2	$01
	lodr,r0	*SBPNT
	bsta,un	CHKCR
	retc,eq
	comi,r0	$0A
	bctr,eq	SBLIN4
SBLIN5:
	bsta,un	WRT
	lodr,r0	SBPNT+1
	addi,r0	$01
	strr,r0	SBPNT+1
	bcfr,eq	SBLIN2
	lodr,r0	SBPNT
	addi,r0	$01
	strr,r0	SBPNT
	bctr,un	SBLIN2
*
SBLIN4:
	bsta,un	LFCR
	bctr,un	SBLIN5
*
SBPNT	ds	2
*
SAVINP:
	loda,r0	INPT
	strr,r0	SBPNT
	loda,r0	INPT+1
	strr,r0	SBPNT+1
	retc,un
*
RTNADR	ds	2
*
EXEC:
	strr,r0	RTNADR
	strr,r1	RTNADR+1
	loda,r0	*INPT
	comi,r0	"*"
	bcta,eq	REM
	bstr,un	SAVINP
	bsta,un	GETLIN
	lodi,r0	HI(COMTBL2)
	lodi,r1	LO(COMTBL2)
	bsta,un	LOOKUP
	bcfa,eq	LET
EXEC2:
	stra,r0	DCDST
	stra,r1	DCDST
	bcta,un	*DCDST
*
ERASEB:
	bsta,un	ERASE
	bcta,un	NXTLIN
*
POKT:
	bsta,un	EVAL
	bsta,un	ENS
	bsta,un	STRCT
	bsta,un	SKPCOM
	bsta,un	EVAL
	bsta,un	ENS1B
	stra,r1	*CTEMP
	bcta,un	NXTLIN
*
GOSUB:
	bsta,un	FNDLIN
	bcfa,eq	ENTER
	loda,r3	CINFT+1
	bsta,un	DECSP
	loda,r3	CINFT
	bsta,un	DECSP
	lodi,r3	$02
	bsta,un	DECSP
	bcta,un	*RTNADR	
*
RETURN:
	bsta,un	INCSP
	comi,r3	$02
	bcfa,eq	NESTER
	bsta,un	INCSP
	stra,r3	INPT
	bsta,un	INCSP
	stra,r3	INPT+1
	bcta,un	SKPLIN
*
RESTOR:
	bsta,un	FNDLIN
	bcta,lt	ENTER
	bctr,gt	REST2
	loda,r0	INPT
	loda,r1	INPT+1
REST1:
	strr,r0	DATPNT
	strr,r1	DATPNT+1
	bsta,un	CRINPT
	eorz	r0
	strr,r0	PDATA
	bcta,un	CKNXTL
*
REST2:
	bsta,un	CSINT
	loda,r0	BUFFSTART
	lodi,r1	$00
	bctr,un	REST1
*
DATPNT:
	DS	2
PDATA:
	DS	1
*
FOR:
	bsta,un	GCVAR
	bcfa,eq	NOSTR
	bsta,un	STRCT
	strz	r2
	lodz	r1
	strz	r3
	bsta,un	DECSP
	lodz	r2
	strz	r3
	bsta,un	DECSP
	loda,r3	INPT+1
	bsta,un	DECSP
	loda,r3	INPT
	bsta,un	DECSP
	bsta,un	SKPEC
	bsta,un	EVAL
	bcfa,eq	NOSTR
	bsta,un	POPCT
	lodi,r0	HI(FORTBL)
	lodi,r1	LO(FORTBL)
	bsta,un	LOOKUP
	bcfa,eq	SYNER
	comi,r1	$01
	bcfa,eq	SYNER
	bsta,un	EVAL
	bcfa,eq	NOSTR
	lodi,r0	HI(FORTBL)
	lodi,r1	LO(FORTBL)
	bsta,un	LOOKUP
	bcfr,eq	FOR2
	comi,r1	$02
	bcfa,eq	SYNER
	bsta,un	EVAL
	bcfa,eq	NOSTR
	bctr,un	FOR3
*
FOR2:
	bsta,un	PUSH1
FOR3:
	lodi,r3	$03
	bsta,un	DECSP
	bcta,un	NXTLIN
*
NTEMPS:
	DS	4
NTEMP:
	DS	8
DTEMP:
	DS	8
*
NEXT:
	bsta,un	INCSP
	comi,r3	$03
	bcfa,eq	NESTER
	lodi,r0	HI(DTEMP)
	lodi,r1	LO(DTEMP)
	bsta,un	POPFP
	lodi,r0	HI(NTEMP)
	lodi,r1	LO(NTEMP)
	bsta,un	POPFP
	lodi,r1	$FF
	lodi,r2	$04
NEXT1:
	bsta,un	INCSP
	lodz	r3
	stra,r0	NTEMPS,r1,+
	bdrr,r2	NEXT1
	bsta,un	LOKVAR
	bctr,gt	NEXTX
	bcta,lt	TTFER
	coma,r0	NTEMPS+2
	bcfa,eq	NESTER
	coma,r1	NTEMPS+3
	bcfa,eq	NESTER
NEXTX:
	loda,r0	NTEMPS+2
	loda,r1	NTEMPS+3
	bsta,un	PUSHFP
	lodi,r0	HI(DTEMP)
	lodi,r1	LO(DTEMP)
	bsta,un	PUSHFP
	bsta,un	FPADD
	bsta,un	POPC2
	lodi,r1	$08
NEXT2:
	loda,r0	CBUF2,r1,-
	stra,r0	*NTEMPS+2,r1
	loda,r0	NTEMP,r1
	stra,r0	CBUF1,r1
	brnr,r1	NEXT2
	bsta,un	COMNUM
	loda,r0	DTEMP
	bctr,lt	NEXT3
	comi,r3	$02
	bctr,eq	NEXT4
NEXT6:
	lodi,r1	$04
NEXT5:
	loda,r0	NTEMPS,r1,-
	strz	r3
	bsta,un	DECSP
	brnr,r1	NEXT5
	lodi,r0	HI(NTEMP)
	lodi,r1	LO(NTEMP)
	bsta,un	PUSHFP
	lodi,r0	HI(DTEMP)
	lodi,r1	LO(DTEMP)
	bsta,un	PUSHFP
	lodi,r3	$03
	bsta,un	DECSP
	loda,r0	NTEMPS
	stra,r0	INPT
	loda,r0	NTEMPS+1
	stra,r0	INPT+1
	bcta,un	SKPLIN
*
NEXT3:
	comi,r3	$01
	bcfr,eq	NEXT6
NEXT4:
	bsta,un	SKPSP
	comi,r0	$2C
	bcta,eq	NEXT
	bsta,un	DECPT
	bcta,un	NXTLIN
*
PURGE:
	bstr,un	PURGES
	bcta,un	NXTLIN
*
PURGES:
	loda,r0	VARSTART
	stra,r0	TABEND
	eorz	r0
	stra,r0	TABEND+1
	bsta,un	L3E40
	retc,un
*
SWAPS:
	DS	2
*
SWAP:
	bsta,un	GCVAR
	bctr,lt	SWAPST
	bcta,gt	ARGER
	bsta,un	STRCT
	bsta,un	SKPCOM
	bsta,un	GCVAR
	bcfa,eq	NOSTR
	lodi,r3	$08
SWAP2:
	strr,r0	SWAPS
	strr,r1	SWAPS+1
SWAP3:
	loda,r0	*SWAPS,r3,-
	strz	r1
	loda,r0	*CTEMP,r3
	stra,r0	*SWAPS,r3
	lodz	r1
	stra,r0	*CTEMP,r3
	brnr,r3	SWAP3
	bcta,un	NXTLIN
*
SWAPST:
	bsta,un	STRCT
	bsta,un	SKPCOM
	bsta,un	GCVAR
	bcfa,lt	NOSTR
	lodi,r3	$03
	bctr,un	SWAP2
*
PCLFCR:
	DS	1
PTYPE:
	DS	1
LPOS:
	DS	1
PUSP:
	DS	1
USINGL:
	db	"USING."
	db	$00, $00, $FF
*
STRPUS:
	strr,r1	PUSP
	retc,un
*
LPPINT:
	lodi,r0	$FF
	strr,r0	PTYPE
	bctr,un	L22B8
*
PRINT:
	eorz	r0
	strr,r0	PTYPE
L22B8:
	lodi,r0	$FF
	stra,r0	PUSP
	bsta,un	SKPSP
	comi,r0	$40
	bcta,eq	PRNTAT
	bsta,un	DECPT
PRTTAI:
	lodi,r0	$0D
	loda,r3	PCLFCR
	bsta,eq	SENDIT
	eorz	r0
	stra,r0	PCLFCR
	lodi,r0	HI(USINGL)
	lodi,r1	LO(USINGL)
	bsta,un	LOOKUP
	bcta,eq	PUSING
PRINT2:
	loda,r0	*INPT
	comi,r0	$26
	bcta,eq	PRINTCT
	bsta,un	CHKCR
	bcta,eq	NXTLIN
	bsta,un	EVAL
	bctr,gt	L2305
	bctr,lt	PRINT4
	bsta,un	PRINTF
	bcta,un	PRINTD
*
PRINT4:
	lodi,r1	$FF
	bstr,un	PRINTS
	bcta,un	PRINTD
*
L2300:
	bcta,eq	PRINTF
	bctr,lt	PRINTS
L2305:
	lodi,r0	HI(TABLIT)
	lodi,r1	LO(TABLIT)
	bsta,un	LOOKUP
	bcfa,eq	SYNER
	bcta,un	PRNTAB
*
PRINTS:
	bsta,un	INCSP
	bsta,un	INCSP
	lodz	r3
	strz	r2
PRINTS2:
	lodz	r2
	bctr,eq	PRINTS3
	loda,r0	*SP,r2,-
	bsta,un	SENDIT
	bdrr,r1	PRINTS2
PRINTS3:
	bcta,un	L179E	; SUPERVISOR
*
	ds	1
*
PRINTF:
	bsta,un	POPC1
	loda,r0	CBUF1+2
	bsta,un	PRTSGN
PRINTF1:
	bsta,un	C1LEN
	iorz	r0
	bcfr,eq	PRINTF2
	bsta,un	SEND0
	retc,un
*
PRINTF2:
	loda,r2	CBUF1
	bctr,lt	PRINTF3
	loda,r1	CBUF1+1
	comi,r1	$10
	bcta,gt	PRTEXP
PRINTF4:
	bsta,un	C1GET
	retc,gt
	retc,eq
	strz	r3
	brnr,r1	PT4A
	lodi,r0	$2E
	bsta,un	SENDIT
PT4A:
	subi,r1	$01
	lodz	r3
	bsta,un	SEND0
	bctr,un	PRINTF4
*
PRINTF3:
	loda,r2	CBUF1+1
	comi,r0	$0A
	bcfr,eq	PT3A
	lodi,r0	$10
PT3A:
	addi,r0	$66
	addz	r2
	dar,r0
	comi,r0	$12
	bctr,gt	PRTEXP
	lodi,r0	$2E
	bsta,un	SENDIT
	loda,r1	CBUF1+1
PT3D:
	brnr,r1	PT3B
PT3C:
	bsta,un	C1GET
	retc,gt
	retc,eq
	bsta,un	SEND0
	bctr,un	PT3C
*
PT3B:
	lodi,r0	$30
	bsta,un	SENDIT
	subi,r1	$01
	bctr,un	PT3D
*
PRTEXP:
	bsta,un	C1GET
	bsta,un	SEND0
	loda,r0	CMAX
	comi,r0	$01
	bcta,eq	PRTE5
	lodi,r0	$2E
	bsta,un	SENDIT
PRTE2:
	bsta,un	C1GET
	bcfr,lt	PRTE5
	iori,r0	$30
	bsta,un	SENDIT
	bctr,un	PRTE2
*
PRTE5:
	lodi,r0	$45
	bsta,un	SENDIT
	loda,r0	CBUF1
	bctr,lt	PRTE6
	loda,r0	CBUF1+1
	subi,r0	$01
	dar,r0
	comi,r0	$99
	bcfr,eq	PRTE7
	lodi,r0	$F0
	stra,r0	CBUF1
PRTE6:
	loda,r0	CBUF1+1
	comi,r0	$99
	bctr,eq	L23D3
	addi,r0	$67
	dar,r0
PRTE7:
	stra,r0	CBUF1+1
	bctr,un	PRTE9
*
L23D3:
	bsta,un	PRTM1
	lodi,r0	$2A
	bsta,un	SENDIT
	lodi,r0	$2A
	bsta,un	SENDIT
	retc,un
*
PRTE9:
	loda,r0	CBUF1
	bsta,un	PRTSGN
	loda,r0	CBUF1+1
	strz	r2
	rrr,r0
	rrr,r0
	rrr,r0
	rrr,r0
	andi,r0	$0F
	bsta,un	SEND0
	lodz	r2
	andi,r0	$0F
	bsta,un	SEND0
	retc,un
*
PRTSGN:
	bctr,eq	L2402
PRTM1:
	lodi,r0	$2D
	bcta,un	SENDIT
*
L2402:
	lodi,r0	$20
	bcta,un	SENDIT
*
ATSTG:
	DS	1
*
PRNTAT:
	bsta,un	EVAL
	bsta,un	ENS1B
	comi,r1	$10
	bcta,gt	OVFER
	lodz	r1
	bcta,eq	OVFER
	subi,r1	$01
	stra,r1	ATSTG
	bsta,un	SKPCOM
	bsta,un	EVAL
	bsta,un	ENS1B
	comi,r1	$50
	bcta,gt	OVFER
	comi,r1	$00
	bcta,eq	OVFER
	subi,r1	$01
	bsta,un	L1796   ; SUPERVISOR +MODS IN LISTING
	rrl,r0
	rrl,r1
	rrl,r0
	rrl,r1
	rrl,r0
	rrl,r1
	rrl,r0
	cpsl	$08
	iori,r0	$10
	strz	r2
	iora,r1	ATSTG
	bsta,un	SETCUR
	bcta,un	PRINT2
*
PRNTAB:
	bsta,un	EVAL
	bsta,un	ENS1B
	lodz	r1
	strz	r2
	bsta,un	GETPOS
TAB1:
	comz	r2
	bcfr,lt	PRINTD
	strz	r3
	lodi,r0	$20
	bsta,un	SENDIT
	lodz	r3
	birr,r0	TAB1
PRINTD:
	bsta,un	SKPSP
	bsta,un	CHKCR
	bcta,eq	*RTNADR						;INFO: indirect jump
	comi,r0	$21
	bcta,eq	SKPLIN
	comi,r0	$3B
	bctr,eq	PRINTD4
	comi,r0	$2C
	bcfa,eq	SYNER
	bsta,un	GETPOS
	comi,r0	$40
	bctr,gt	PRINTD5
	strz	r1
	subi,r1	$01
PRINTD0:
	lodz	r1
	andi,r0	$0F
	bctr,eq	PRINTD4
	lodi,r0	$20
	bsta,un	SENDIT
	addi,r1	$01
	bctr,un	PRINTD0
*
PRINTD5:
	bsta,un	LFCR
PRINTD4:
	bsta,un	SKPDEC
	bsta,un	CHKCR
	bcfa,eq	PRINT2
PRINTD6:
	lodi,r0	$FF
	stra,r0	PCLFCR
	bcta,un	NXTLIN
*
GETPOS:
	loda,r0	PTYPE
	bctr,eq	GETDIS
	loda,r0	LPOS
	retc,un
*
GETDIS:
	loda,r1	CURSOR
	loda,r0	CURSOR+1
	ppsl	$08
	rrr,r1
	rrr,r0
	rrr,r1
	rrr,r0
	rrr,r1
	rrr,r0
	rrr,r1
	rrr,r0
	andi,r0	$7F
	cpsl	$08
	addi,r0	$01
	retc,un
*
SEND0:
	iori,r0	$30
SENDIT:
	ppsl	$10
	loda,r1	PTYPE
	cpsl	$10
	bctr,eq	SEND1
	bctr,gt	SEND3
	comi,r0	$0D
	bcfr,eq	SEND2
	lodi,r0	$01
	stra,r0	LPOS
	lodi,r0	$0D
	bcta,un	PRNT
*
SEND1:
	comi,r0	$0D
	bcta,eq	LFCR
	bcta,un	WRT
*
SEND2:
	bsta,un	PRNT
	loda,r0	LPOS
	addi,r0	$01
	stra,r0	LPOS
	retc,un
*
SEND3:
	ppsl	$10
	loda,r1	TYP3SP
	stra,r0	STRSS,r1,+
	stra,r1	TYP3SP
	cpsl	$10
	retc,un
*
PRINTCT:
	bsta,un	INCPT
	bsta,un	GETCHR
	comi,r0	$40
	bcta,lt	OVFER
	comi,r0	$5F
	bcta,gt	OVFER
	andi,r0	$1F
	bsta,un	SENDIT
	bcta,un	PRINTD
*
ERRTYP:
	DS	1
*
DATERR:
	loda,r0	ERWAIT
	bcta,eq	ERROR
	strr,r3	ERRTYP
	loda,r3	INPT+1
	bsta,un	DECSP
	loda,r3	INPT
	bsta,un	DECSP
	lodi,r3	$02
	bsta,un	DECSP
	loda,r0	ERPTN
	stra,r0	INPT
	loda,r0	ERPTN+1
	stra,r0	INPT+1
	bcta,un	*RTNADR						;INFO: indirect jump
*
RDNIF:
	lodi,r3	$02
	bctr,un	DATERR
*
RDTYPE:
	lodi,r3	$0A
	bctr,un	DATERR
*
ONSTG:
	DS	2
INON:
	DS	1
*
ON:
	bsta,un	EVAL
	bsta,un	ENS
	strr,r1	ONSTG
	iorz	r0
	bcfa,eq	SKPLIN
	lodz	r1
	bcta,eq	SKPLIN
	lodi,r0	HI(CNTTBL)	;POINTER ?
	lodi,r1	LO(CNTTBL)	;POINTER ?
	bsta,un	LOOKUP
	bcfa,eq	SYNER
	strr,r1	ONSTG+1
	lodr,r1	ONSTG
ON1:
	comi,r1	$01
	bctr,eq	ON2
ON1B:
	bsta,un	GETCHR
	bsta,un	CHKCR
	bcta,eq	*RTNADR						;INFO: indirect jump
	comi,r0	$2C
	bcfr,eq	ON1B
	bdrr,r1	ON1
ON2:
	lodi,r0	$FF
	strr,r0	INON
	lodr,r1	ONSTG+1
	loda,r0	ONPTR,r1
	stra,r0	DCDST
	loda,r0	ONPTR,r1,+
	stra,r0	DCDST
	bcta,un	*DCDST						;INFO: indirect jump
*
ONPTR:
	dw	GOT0
ONPTR1:
	dw	GOSUB
ONPTR2:
	dw	RESTOR
ONPTR3:
	dw	EXIT
ONPTR4:
	dw	ERRORC
ONPTR5:
	dw	RESUME1
*
IFF:
	bsta,un	EVAL
	bcfa,eq	NOSTR
	bsta,un	POPC1
	loda,r0	CBUF1+3
	bctr,eq	IFELSE
	lodi,r0	HI(CNTTBL)
	lodi,r1	LO(CNTTBL)
	bsta,un	LOOKUP
	bcfr,eq	IFTBEN
	lodz	r1
	bcfa,eq	SYNER
IFTBEN:
	bsta,un	FNDLIN
	bcta,un	*RTNADR						;INFO: indirect jump
*
IFELSE:
	bsta,un	GETCHR
	comi,r0	$3A
	bctr,eq	ELSEI2
	comi,r0	$0D
	bcfr,eq	IFELSE
	bsta,un	SKPDEC
	lodi,r0	HI(ELSETBL)
	lodi,r1	LO(ELSETBL)
	bsta,un	LOOKUP
	bcta,lt	*RTNADR						;INFO: indirect jump
	bctr,un	IFTBEN
*
ELSEI2:
	bsta,un	SKPDEC
	lodi,r0	HI(ELSETBL)
	lodi,r1	LO(ELSETBL)
	bsta,un	LOOKUP
	bcfr,eq	IFELSE
	bctr,un	IFTBEN
*
EXIT:
	loda,r3	*SP
	comi,r3	$03
	bcfa,eq	GOT0
	lodi,r2	$17
EXIT1:
	bsta,un	INCSP
	bdrr,r2	EXIT1
	bctr,un	EXIT
*
WAIT:
	bsta,un	EVAL
	bsta,un	ENS1B
	strr,r1	WAIT4+1   ; ARGUMENT FOR REDE (io) CODE
	bsta,un	SKPCOM
	bsta,un	EVAL
	bsta,un	ENS1B
	stra,r1	CTEMP
	bsta,un	SKPDEC
	comi,r0	$2C
	bcfr,eq	WAIT2
	bsta,un	INCPT
	bsta,un	EVAL
	bctr,gt	WAIT2
	bsta,un	ENS1B
	bctr,un	WAIT3
*
WAIT2:
	lodi,r1	$00
WAIT3:
	stra,r1	CTEMP+1
WAIT4:
	rede,r0	$00	;IO BYTEADRES MUST BE RAM
	eora,r0	CTEMP+1
	anda,r0	CTEMP
	bcfa,eq	NXTLIN
	bctr,un	WAIT4
*
ERPTN:
	DS	2
ERWAIT:
	DS	1
*
ERRORC:
ERRORC:
	bsta,un	FNDLIN
	bcta,lt	ENTER
	bctr,gt	ENF
	loda,r0	INPT
	strr,r0	ERPTN
	loda,r0	INPT+1
	strr,r0	ERPTN+1
	lodi,r0	$FF
	strr,r0	ERWAIT
	bsta,un	CRINPT
	bcta,un	CKNXTL
*
ENF:
	eorz	r0
	strr,r0	ERWAIT
	bcta,un	CKNXTL
*

DEFF:
	bsta,un	LOKVAR
	bcfa,gt	NDER
	bsta,un	GETNA
	comi,r1	$FF
	bcta,eq	SYNER
	comi,r0	$28
	bcfa,eq	SYNER
	lodi,r2	$02
	lodi,r3	$04
	bsta,un	GCSUB
	loda,r0	INPT
	bsta,un	PSHOP1
	loda,r0	INPT+1
	bsta,un	PSHOP1
	bsta,un	GSBEND
	bcta,un	SKPLIN
*
DIM:
	bsta,un	LOKVAR
	bcfa,gt	NDER
	lodi,r0	$FF
	stra,r0	GCDIMS
	bsta,un	GCV
	bcta,gt	ARGER
	bsta,un	SKPDEC
	comi,r0	$2C
	bcfa,eq	NXTLIN
	bsta,un	INCPT
	bctr,un	DIM
*
CMSTRS:
	DS	$100
INSTG:
	DS	2
*
INPUT:
	loda,r3	PCLFCR
	bsta,eq	LFCR
	eorz	r0
	stra,r0	PCLFCR
	bsta,un	SKPSP
	bsta,un	CHKCR
	bcfr,eq	INPUTA
	bsta,un	PAUSE
	comi,r0	$1B
	bcta,eq	OPTION
	bcta,un	*RTNADR						;INFO: indirect jump
*
INPUTA:
	comi,r0	$22
	bcfr,eq	INPUT1
INPUT0:
	loda,r0	*INPT
	bcta,lt	SYNER
	bsta,un	INCPT
	comi,r0	$0D
	bcta,eq	SYNER
	comi,r0	$0A
	bcta,eq	SYNER
	comi,r0	$22
	bcfr,eq	INPUT2
	bsta,un	SKPSP
	comi,r0	$3B
	bcfa,eq	SYNER
	bctr,un	INPUT3
*
INPUT2:
	bsta,un	WRT
	bctr,un	INPUT0
*
INPUT1:
	bsta,un	DECPT
	lodi,r0	$3F
	bsta,un	WRT
INPUT3:
	bsta,un	WRBL
	bsta,un	CSINT
INPUT3A:
	bsta,un	AROWCR
	bsta,un	SWITCH
INPNIT:
	bsta,un	GCVAR
	bctr,lt	INPSTR
	bctr,eq	INPFPT
	bcta,un	NXTLIN
*
INPFPT:
	bsta,un	STRCT
	bsta,un	SWITCH
	bsta,un	EVAL
	bcfa,eq	INPERR
	bsta,un	POPCT
	bctr,un	INPDEL
*
INPSTR:
	bsta,un	STRCT
	bsta,un	ZSTR
	bsta,un	SWITCH
	bsta,un	SKPDEC
	comi,r0	$22
	bctr,eq	INPST2
	lodi,r2	$FF
INPST0:
	loda,r0	*INPT
	comi,r0	$0D
	bctr,eq	INPST1
	comi,r0	$0A
	bctr,eq	INPST1
	comi,r0	$2C
	bctr,eq	INPST1
	stra,r0	CMSTRS,r2,+
	bsta,un	INCPT
	bctr,un	INPST0
*
INPST1:
	addi,r2	$01
	lodi,r0	HI(CMSTRS)
	lodi,r1	LO(CMSTRS)
	bsta,un	PUSHST
	bsta,un	STRINGT
	bctr,un	INPDEL
*
INPST2:
	bsta,un	EVAL
	bcfr,lt	INPERR
	bsta,un	STRINGT
INPDEL:
	bsta,un	SWITCH
	bsta,un	SKPDEC
	comi,r0	$2C
	bcfa,eq	NXTLIN
	bsta,un	INCPT
	bsta,un	SWITCH
	bsta,un	SKPSP
	comi,r0	$2C
	bcfr,eq	INPERR
	bsta,un	SWITCH
	bcta,un	INPNIT
*
INPERR:
	bsta,un	CRINPT
	lodi,r3	$04
	bsta,un	WRTMCR
	bcta,un	INPUT3A
*
SWITCH:
	loda,r0	BTEMP
	loda,r1	INPT
	stra,r0	INPT
	stra,r1	BTEMP
	loda,r0	BTEMP+1
	loda,r1	INPT+1
	stra,r0	INPT+1
	stra,r1	BTEMP+1
	retc,un
*
RBUFP:
	DW	RBUF
*
RANDOM:
	loda,r0	NEWSED
	stra,r0	*RBUFP
	bcta,un	NXTLIN
*
MIDSTG:
	DS	7
*
MIDS:
	bsta,un	GCVAR
	bcfa,lt	NOSTR
	bsta,un	STRCT
	lodi,r2	$03
	lodi,r3	$05
MID1:
	loda,r0	*CTEMP,r2,-
	stra,r0	MIDSTG,r3,-
	brnr,r2	MID1
	bsta,un	SKPCOM
	bsta,un	EVAL
	bsta,un	ENS1B
	lodz	r1
	bcta,eq	OVFER
	strr,r1	MIDSTG
	lodi,r1	$FF
	bsta,un	SKPSP
	comi,r0	$29
	bctr,eq	MID2
	comi,r0	$2C
	bcfa,eq	SYNER
	bsta,un	EVAL
	bsta,un	ENS1B
	bsta,un	SKPSP
	comi,r0	$29
	bcfa,eq	SYNER
MID2:
	bsta,un	SKPEC
	stra,r1	MIDSTG+1
	bsta,un	EVAL
	bcfa,lt	NOSTR
	bsta,un	INCSP
	bsta,un	INCSP
	loda,r1	MIDSTG+4
	bcta,eq	MID7
	lodi,r2	$FF
MID3:
	loda,r0	*MIDSTG+2,r2,+
	stra,r0	CMSTRS,r2
	bdrr,r1	MID3
	loda,r0	MIDSTG+4
	coma,r0	MIDSTG
	bcta,lt	MID7
	suba,r0	MIDSTG
	addi,r0	$01
	stra,r0	MIDSTG+5
	loda,r2	MIDSTG
	subi,r2	$01
	loda,r1	MIDSTG+1
	bcta,eq	MID7
	stra,r3	MIDSTG+6
MID4:
	comi,r3	$00
	bctr,eq	MID5
	loda,r0	*SP,r3,-
	stra,r0	CMSTRS,r2
	addi,r2	$01
	coma,r2	MIDSTG+4
	bctr,eq	MID5
	bdrr,r1	MID4
MID5:
	loda,r1	MIDSTG+4
	lodi,r2	$FF
MID6:
	loda,r0	CMSTRS,r2,+
	stra,r0	*MIDSTG+2,r2
	bdrr,r1	MID6
	loda,r3	MIDSTG+6
MID7:
	lodz	r3
	bsta,un	INCSP2
	bcta,un	NXTLIN
*
CCSFND:
	loda,r0	LTEMP
	loda,r1	LTEMP+1
	subi,r1	$02
	ppsl	$08
	subi,r0	$00
	cpsl	$08
	lodi,r3	$FF
	retc,un
*
FNAME:
	DS	4
GCSAV:
	DS	2
*
GCVAR:
	eorz	r0
	stra,r0	GCDIMS
	bsta,un	LOKVAR
	retc,eq
	bctr,lt	CCSFND
GCV:
	loda,r0	INPT
	strr,r0	GCSAV
	loda,r0	INPT+1
	strr,r0	GCSAV+1
	bsta,un	GETNA
GCV2:
	comi,r1	$FF
	bcta,eq	RETNGT
	comi,r0	$24
	bcta,eq	GCSTB
	comi,r0	$28
	bcta,eq	GCDIM
	bsta,un	DECPT
	lodi,r2	$08
	lodi,r3	$00
GCV3:
	bsta,un	GCSUB
GCV6:
	eorz	r0
	comi,r2	$07
	bctr,lt	GCNT
	bctr,eq	GCV7
	lodi,r0	$F0
	bctr,un	GCNT
*
GCV7:
	lodi,r0	$99
GCNT:
	bsta,un	PSHOP1
	bdrr,r2	GCV6
	bsta,un	GSBEND
	eorz	r0
	bsta,un	PSHOP1
	loda,r0	OP2
	loda,r1	OP2+1
	addi,r1	$05
	ppsl	$08
	addi,r0	$00
	cpsl	$08
	lodi,r2	$00
	comi,r3	$00
	retc,eq
	lodi,r3	$FF
	retc,un
*
GSBEND:
	loda,r0	OP1
	stra,r0	TABEND
	bsta,un	PSHOP2
	loda,r0	OP1+1
	stra,r0	TABEND+1
	bsta,un	PSHOP2
	retc,un
*
GETNA:
	loda,r0	TABEND
	loda,r1	TABEND+1
	bsta,un	STROP1
	bsta,un	STROP2
	lodi,r1	$04
	eorz	r0
GCV1:
	stra,r0	FNAME,r1,-
	brnr,r1	GCV1
	lodi,r1	$FF
GCV3:
	bsta,un	GETCHR
	bsta,un	CHKAN
	retc,lt
	retc,gt
	addi,r1	$01
	comi,r1	$03
	bcta,gt	ARGER
	stra,r0	FNAME,r1
	bctr,un	GCV3
*
GCSTB:
	bsta,un	GETCHR
	lodi,r3	$02
	comi,r0	$28
	bctr,eq	GCDSTR
	bsta,un	DECPT
	lodi,r2	$03
	lodi,r3	$01
	bcta,un	GCV3
*
GCSUB:
	eorz	r0
	bsta,un	PSHOP1
	bsta,un	PSHOP1
	lodz	r3
	bsta,un	PSHOP1
	lodi,r1	$FF
GCV5:
	loda,r0	FNAME,r1,+
	bsta,un	PSHOP1
	comi,r1	$03
	bcfr,eq	GCV5
	retc,un
*
GCLEN:
	DS	6
GCTYPE:
	DS	1
GCDIMS:
	DS	1
*
GCDIM:
	lodi,r3	$03
GCDSTR:
	stra,r3	GCTYPE
	bsta,un	GCSUB
	eorz	r0
	stra,r0	GCLEN
	stra,r0	GCLEN+2
	lodi,r0	$01
	stra,r0	GCLEN+1
	loda,r0	OP1
	stra,r0	GCLEN+3
	loda,r0	OP1+1
	stra,r0	GCLEN+4
	bsta,un	INCOP1
GCD4:
	bsta,un	EVAL
	bcta,gt	GCD2
	bsta,un	ENS1B
	lodz	r1
	bcta,eq	DIMER
	comi,r1	$0A
	bctr,gt	GCD3
	loda,r3	GCDIMS
	bctr,lt	GCD3
	lodi,r0	$0A
GCD3:
	strz	r3
	bsta,un	PSHOP1
	loda,r0	GCLEN+2
	addi,r0	$01
	stra,r0	GCLEN+2
	loda,r0	GCLEN
	loda,r1	GCLEN+1
GCD3B:
	adda,r1	GCLEN+1
	ppsl	$08
	adda,r0	GCLEN
	cpsl	$08
	tpsl	$01
	bcta,eq	DIMER
	bdrr,r3	GCD3B
	stra,r0	GCLEN
	stra,r1	GCLEN+1
	bsta,un	SKPSP
	comi,r0	$2C
	bcta,eq	GCD4
	bsta,un	DECPT
GCD2:
	loda,r0	GCLEN+2
	bcta,eq	DIMER
	stra,r0	*GCLEN+3
	bsta,un	GETCHR
	comi,r0	$29
	bcfa,eq	SYNER
	loda,r0	GCTYPE
	comi,r0	$02
	bctr,eq	GCD5
	lodi,r3	$08
	bctr,un	GCD6
*
GCD5:
	lodi,r3	$03
GCD6:
	stra,r3	GCTYPE
GCD7:
	loda,r3	GCTYPE
GCD8:
	eorz	r0
	comi,r3	$07
	bctr,lt	GCDNT
	bctr,eq	GCEQ7
	lodi,r0	$F0
	bctr,un	GCDNT
*
GCEQ7:
	lodi,r0	$99
GCDNT:
	bsta,un	PSHOP1
	bdrr,r3	GCD8
	loda,r0	GCLEN
	loda,r1	GCLEN+1
	subi,r1	$01
	ppsl	$08
	subi,r0	$00
	cpsl	$08
	stra,r0	GCLEN
	stra,r1	GCLEN+1
	iorz	r0
	bcfr,eq	GCD7
	lodz	r1
	bcfr,eq	GCD7
	loda,r0	OP1
	stra,r0	TABEND
	bsta,un	PSHOP2
	loda,r0	OP1+1
	stra,r0	TABEND+1
	bsta,un	PSHOP2
	eorz	r0
	bsta,un	PSHOP1
	loda,r0	GCSAV
	stra,r0	INPT
	loda,r0	GCSAV+1
	stra,r0	INPT+1
	bcta,un	LOKVAR
*
CTOS:
	loda,r0	CTEMP
	strr,r0	STMP+4
	loda,r0	CTEMP+1
	strr,r0	STMP+5
	retc,un
*
STMP:
	DS	6
	
STRINGT:
	bstr,un	CTOS
STRG:
	bsta,un	INCSP
	bsta,un	INCSP
	lodz	r3
	strz	r2
	strz	r1
	loda,r0	INSBUFF
	strr,r0	STMP+2
	eorz	r0
	strr,r0	STMP+3
	strz	r3
	comz	r2
	bcta,eq	STR8
STR1:
	lodr,r0	STMP+2
	strr,r0	STMP
	strr,r3	STMP+1
STR2:
	loda,r0	*STMP+2,r3
	addi,r3	$01
	bcfr,eq	STR6
	lodr,r0	STMP+2
	addi,r0	$01
	strr,r0	STMP+2
	coma,r0	VARSTART
	bctr,lt	STR6
	lodi,r3	$0E
	bcta,un	ERROR
*
STR6:
	iorz	r0
	bcfr,eq	STR3
	bdrr,r2	STR2
STR4:
	lodi,r3	$00
	loda,r0	STMP
	stra,r0	*STMP+4
	loda,r0	STMP+1
	stra,r0	*STMP+4,r3,+
	lodz	r1
	stra,r0	*STMP+4,r3,+
	lodz	r1
	retc,eq
STRC5:
	bsta,un	INCSP
	lodz	r3
	stra,r0	*STMP,r1,-
	brnr,r1	STRC5
	retc,un
*
STR3:
	lodz	r1
	strz	r2
	bcta,un	STR1
*
STR8:
	lodi,r2	$03
STR8A:
	stra,r0	*STMP+4,r2,-
	brnr,r2	STR8A
	retc,un
*
ENS1B:
	bstr,un	ENS
	iorz	r0
	bcfa,eq	OVFER
	retc,un
*
ENS:
	bcfa,eq	NOSTR
ENS2:
	bsta,un	POPC1
DTOB:
	eorz	r0
	strz	r1
	loda,r3	CBUF1
	retc,lt
	loda,r3	CBUF1+2
	retc,lt
	loda,r3	CBUF1+3
	retc,eq
	loda,r0	CBUF1+1
	stra,r0	CMAX
	eorz	r0
	stra,r0	CPTR
	strz	r1
DTOB1:
	strz	r3
	bsta,un	C1GET
	retc,gt
	retc,eq
	strz	r2
	lodz	r3
	bsta,un	X10
	strz	r3
	lodz	r1
	addz	r2
	strz	r1
	ppsl	$08
	eorz	r0
	addz	r3
	cpsl	$08
	tpsl	$01
	bcta,eq	OVFER
	bctr,un	DTOB1
*
C1LEN:
	lodi,r2	$08
	lodi,r3	$00
	strr,r3	CPTR
C1LEN1:
	loda,r0	CBUF1,r2,-
	bctr,eq	C1LEN2
	andi,r0	$0F
	bcfr,eq	C1LEN3
	addi,r3	$01
	bctr,un	C1LEN3
*
C1LEN2:
	addi,r3	$02
	comi,r3	$0A
	bcfr,eq	C1LEN1
C1LEN3:
	lodi,r0	$0A
	subz	r3
	strr,r0	CMAX
	loda,r2	CBUF1
	retc,lt
	comi,r0	$0A
	retc,eq
	coma,r0	CBUF1+1
	retc,gt
	retc,eq
	loda,r0	CBUF1+1
	comi,r0	$0B
	bctr,lt	C1LEN4
	lodi,r0	$0A
C1LEN4:
	strr,r0	CMAX
	retc,un
*
CMAX:
	DS	1
CPTR:
	DS	1
*
C1GET:
	lodr,r2	CPTR
	comr,r2	CMAX
	retc,gt
	retc,eq
	lodz	r2
	rrr,r0
	andi,r0	$7F
	addi,r0	$03
	loda,r0	CBUF1,r0
	tmi,r2	$01
	bctr,eq	C1GET2
	rrr,r0
	rrr,r0
	rrr,r0
	rrr,r0
C1GET2:
	andi,r0	$0F
	addi,r2	$01
	strr,r2	CPTR
	lodi,r2	$FF
	retc,un
*
GETDAT:
	bsta,un	CSINT
	loda,r0	DATPNT
	stra,r0	INPT
	loda,r0	DATPNT+1
	stra,r0	INPT+1
	loda,r0	PDATA
	bctr,eq	GETD2
	bsta,un	SKPSP
	comi,r0	$2C
	bctr,eq	GETD3
	bsta,un	DECPT
	bctr,un	GETD4
*
GETD3:
	bsta,un	EVAL
	spsl
	strz	r3
	lodi,r0	$FF
	stra,r0	PDATA
	loda,r0	INPT
	stra,r0	DATPNT
	loda,r0	INPT+1
	stra,r0	DATPNT+1
	bsta,un	CRINPT
	lodz	r3
	lpsl
	retc,un
*
GETD2:
	bsta,un	GETLIN
	lodi,r0	HI(DATTBL)
	lodi,r1	LO(DATTBL)
	bsta,un	LOOKUP
	bcfr,eq	GETD4
	comz	r1
	bctr,eq	GETD3
	comi,r1	$03
	bcfr,eq	GETD4
GETD5:
	bsta,un	CRINPT
	lodi,r0	$01
	retc,un
*
GETD4:
	bsta,un	SKPCR
	loda,r0	*INPT
	bcfr,lt	GETD2
	bctr,un	GETD5
*
PDGET:
	loda,r1	PUSP
	loda,r0	CMSTRS,r1,+
	stra,r1	PUSP
	retc,un
*
ZERCMS:
	eorz	r0
	strz	r2
L2C9C:
ZERCCM2:
	stra,r0	CMSTRS,r2,-
	brnr,r2	L2C9C
	retc,un
*
FSTG:
	DS	5
	
*
PRNTPU:
	strr,r0	FSTG
	strr,r1	FSTG+1
	strr,r2	FSTG+2
	strr,r3	FSTG+3
	comi,r0	$0A
	bcta,gt	SYNER
	comi,r1	$0A
	bcta,gt	SYNER
	bsta,un	POPC1
	loda,r0	CBUF1+3
	bcfr,eq	PFU1
PFU90:
	loda,r2	FSTG
	bctr,eq	PFU0
PFU00:
	lodi,r0	$20
	bsta,un	SENDIT
	bdrr,r2	PFU00
PFU0:
	bsta,un	SEND00
	bcta,un	PFU8
*
PFU1:
	bsta,un	PUSHC1
	eorz	r0
	lodi,r2	$04
PFU2:
	stra,r0	CBUF1+4,r2,-
	brnr,r2	PFU2
	lodi,r0	$F0
	stra,r0	CBUF1
	loda,r0	FSTG+1
	stra,r0	CBUF1+1
	lodi,r0	$50
	stra,r0	CBUF1+3
	bsta,un	PUSHC1
	bsta,un	FPADD
	bsta,un	POPC1
	loda,r0	FSTG+1
	bcfr,eq	PFU99
	bsta,un	PUSHC1
	bsta,un	FPFIX
	bsta,un	POPC1
	loda,r0	CBUF1+3
	bcta,eq	PFU90
PFU99:
	loda,r0	CBUF1+2
	bctr,eq	PFU3A
	bsta,un	PRTM1
	bctr,un	PFU3B
*
PFU3A:
	loda,r0	FSTG
	addi,r0	$01
	stra,r0	FSTG
PFU3B:
	lodi,r1	$00
	loda,r0	CBUF1
	bctr,lt	PFU4
	loda,r1	CBUF1+1
PFU4:
	stra,r1	FSTG+4
	loda,r0	FSTG+2
	bctr,gt	PFU5
	lodz	r1
	strz	r3
PFU4A:
	comi,r3	$03
	bcfr,gt	PFU5
	addi,r1	$01
	subi,r3	$03
	bctr,un	PFU4A
*
PFU5:
	loda,r0	FSTG
	subz	r1
	bcta,lt	FCVF
	strz	r1
	bctr,eq	PFU7
PFU6:
	lodi,r0	$20
	bsta,un	SENDIT
	bdrr,r1	PFU6
PFU7:
	bsta,un	C1LEN
PFU7B:
	loda,r1	FSTG+4
	bctr,eq	PFU8
	subi,r1	$01
	stra,r1	FSTG+4
	bsta,un	C1GET
	bsta,un	SEND0
	loda,r0	FSTG+2
	bctr,gt	PFU7B
	loda,r1	FSTG+4
PFU7C:
	comi,r1	$03
	bctr,eq	PFU7A
	bctr,lt	PFU7B
	subi,r1	$03
	bctr,un	PFU7C
*
PFU7A:
	lodi,r0	$2C
	bsta,un	SENDIT
	bctr,un	PFU7B
*
PFU8:
	loda,r0	FSTG+3
	retc,gt
	lodi,r0	$2E
	bsta,un	SENDIT
	loda,r0	FSTG+1
	retc,eq
	loda,r1	CBUF1
	bcfr,lt	PFU9A
	loda,r1	CBUF1+1
	comz	r1
	bctr,gt	PFU9B
	strz	r1
PFU9B:
	subz	r1
	stra,r0	FSTG+1
PFU9C:
	bsta,un	SEND00
	bdrr,r1	PFU9C
PFU9:
	loda,r0	FSTG+1
	retc,eq
PFU9A:
	subi,r0	$01
	stra,r0	FSTG+1
	bsta,un	C1GET
	bctr,lt	PFU1B
	bsta,un	SEND00
	bctr,un	PFU9
*
PFU1B:
	bsta,un	SEND0
	bctr,un	PFU9
*
FCVF:
	loda,r1	FSTG
	bctr,eq	FOVF2
FCOVF1:
	lodi,r0	$2A
	bsta,un	SENDIT
	bdrr,r1	FCOVF1
FOVF2:
	loda,r1	FSTG+3
	retc,gt
	lodi,r0	$2E
	bsta,un	SENDIT
	loda,r1	FSTG+1
	retc,eq
FOVF3:
	lodi,r0	$2A
	bsta,un	SENDIT
	bdrr,r1	FOVF3
	retc,un
*
SEND00:
	eorz	r0
	bcta,un	SEND0
*
GETKB:
	bstr,un	PAUSE
	bsta,un	WRT
	lodr,r0	KBBUF
	retc,un
*
KBBUF:
	DS	1
NEWSED:
	DS	1
PAUSES:
	DS	1
*
PAUSE:
	strr,r2	PAUSES
PAUSE1:
	redd,r0
	bcfr,lt	PAUSE2
	addi,r2	$01
	bctr,un	PAUSE1
*
PAUSE2:
	strr,r2	NEWSED
	lodr,r2	PAUSES
	strr,r0	KBBUF
PL:
	redd,r0
	bcfr,lt	PL
	lodr,r0	KBBUF
	retc,un
*
SETCUR:
	bstr,un	EROLD
	stra,r2	CURSOR
	stra,r1	CURSOR+1
	lodi,r0	$1C
	stra,r0	*CURSOR
	retc,un
*
ERAS1:
	loda,r0	CURSOR
	comi,r0	$10
	bcfr,eq	EROLD
	loda,r0	CURSOR+1
	comi,r0	$10
	retc,lt
EROLD:
	lodi,r0	$20
	stra,r0	*CURSOR
	retc,un
*
POPCT:
	loda,r0	CTEMP
	loda,r1	CTEMP+1
	bcta,un	POPFP
*
WRBL:
	lodi,r0	$20
WRT:
	bsta,un	L178B	;SUPERVISOR
	eori,r1	$FF
	tmi,r1	$60
	bctr,eq	WRTRTN
	tmi,r0	$60
	bctr,eq	WRTLC
	andi,r0	$3F
WRTLC:
	stra,r0	*CURSOR
	lodi,r1	$10
	adda,r1	CURSOR+1
	stra,r1	CURSOR+1
	ppsl	$08
	lodi,r1	$00
	adda,r1	CURSOR
	stra,r1	CURSOR
	cpsl	$08
	tmi,r1	$05
	bctr,eq	LFCR2
	lodi,r1	$1C
	stra,r1	*CURSOR
WRTRTN:
	cpsl	$10
	retc,un
*
LFCR:
	ppsl	$10
	bsta,un	EROLD
LFCR2:
	loda,r1	CURSOR+1
	tmi,r1	$0F
	bctr,eq	SCROLL
	addi,r1	$01
	andi,r1	$0F
	stra,r1	CURSOR+1
CLRLIN:
	lodi,r3	$10
	stra,r3	CURSOR
	lodi,r0	$20
	lodi,r2	$00
ELL1:
	stra,r0	*CURSOR,r2
	addi,r2	$10
	bcfr,eq	ELL1
	addi,r3	$01
	stra,r3	CURSOR
	comi,r3	$15
	bcfr,eq	ELL1
	lodi,r3	$10
	stra,r3	CURSOR
	lodi,r1	$1C
	stra,r1	*CURSOR
	cpsl	$10
	retc,un
*
SCROLL:
	lodi,r0	$14
	stra,r0	CURSOR
	eorz	r0
	stra,r0	CURSOR+1
SCROL2:
	lodi,r2	$00
	lodi,r3	$FF
SCROL1:
	loda,r0	*CURSOR,r2,+
	eori,r2	$FF
	tmi,r2	$0F
	bctr,eq	SCROL4
	stra,r0	*CURSOR,r3,+
SCROL5:
	eori,r2	$FF
	comi,r2	$FF
	bcfr,eq	SCROL1
	loda,r0	CURSOR
	subi,r0	$01
	comi,r0	$0F
	bctr,eq	SCROL3
	stra,r0	CURSOR
	bctr,un	SCROL2
*
SCROL3:
	lodi,r0	$0F
	stra,r0	CURSOR+1
	bcta,un	CLRLIN
*
SCROL4:
	addi,r3	$01
	bctr,un	SCROL5
*
CURSOR:
	DS	2
TMPA:
	DS	2
*
ARROW:
	strr,r0	TMPA
	strr,r1	TMPA+1
	lodi,r1	$FF
INLOCB:
	bsta,un	GETKB
	comi,r0	$1B
	bcta,eq	ARROW2
	comi,r0	$08
	bcfr,eq	NOBS
	comi,r1	$FF
	bctr,eq	INLOCB
	bsta,un	BACKSP
	bctr,lt	INLOCB
	subi,r1	$01
	addi,r2	$01
	bctr,un	INLOCB
*
NOBS:
	comi,r0	$15
	bcfr,eq	STRIN
	comi,r1	$FF
	bcfr,eq	INLOCB
NOBS2:
	loda,r0	*TMPA,r1,+
	bctr,eq	STRIN2
	comi,r0	$0D
	bctr,eq	STRIN2
	bsta,un	WRT
	bdrr,r2	NOBS2
	bctr,un	CRWAIT
*
STRIN2:
	subi,r1	$01
	bctr,un	INLOCB
*
STRIN:
	stra,r0	*TMPA,r1,+
	comi,r0	$0D
	bctr,eq	CLRLAS
	bdra,r2	INLOCB
CRWAIT:
	redd,r0
	comi,r0	$08
	bcta,eq	INLOCB
	comi,r0	$0D
	bcfr,eq	CRWAIT
	bsta,un	PL
	eorz	r0
	retc,un
*
CLRLAS:
	eorz	r0
CL:
	stra,r0	*TMPA,r1
	addi,r1	$01
	bdrr,r2	CL
	eorz	r0
	retc,un
*
ARROW2:
	lodi,r0	$FF
	retc,un
*
BACKSP:
	bsta,un	ERAS1
	retc,lt
	loda,r3	CURSOR+1
	loda,r0	CURSOR
BACKS1:
	subi,r3	$10
	ppsl	$08
	subi,r0	$00
	cpsl	$08
	stra,r3	CURSOR+1
	stra,r0	CURSOR
	lodi,r0	$1C
	stra,r0	*CURSOR
	retc,un
*
ERROR2:
	lodi,r2	$13
	lodi,r1	$C0
	bsta,un	SETCUR
	bsta,un	PRING
	lodi,r0	$20
	stra,r0	*CURSOR
	bsta,un	PAUSE
	bcta,un	RFFDW
*
BACK1:
	bsta,un	ERAS1
	retc,lt
	loda,r0	CURSOR+1
	subi,r0	$10
	stra,r0	CURSOR+1
	ppsl	$08
	loda,r0	CURSOR
	subi,r0	$00
	stra,r0	CURSOR
	cpsl	$08
	lodi,r0	$1C
	stra,r0	*CURSOR
	subi,r1	$01
	comi,r1	$FF
	bcfr,eq	NOSUB1
	lodr,r0	*TMM
	subi,r0	$01
	strr,r0	*TMM
NOSUB1:
	eorz	r0
	retc,un
*
TMM:
	dw	TMPA
*
OLFCR:
	lodi,r3	$20
	stra,r3	*CURSOR
OLFCR2:
	loda,r3	CURSOR+1
	andi,r3	$0F
	addi,r3	$01
	andi,r3	$0F
	stra,r3	CURSOR+1
	lodi,r3	$10
	stra,r3	CURSOR
	lodi,r0	$20
L2:
	stra,r0	*CURSOR
	lodi,r3	$10
	adda,r3	CURSOR+1
	stra,r3	CURSOR+1
	ppsl	$08
	lodi,r3	$00
	adda,r3	CURSOR
	stra,r3	CURSOR
	cpsl	$08
	tmi,r3	$05
	bcfr,eq	L2
	loda,r3	CURSOR+1
	stra,r3	CURSOR+1
	lodi,r3	$10
	stra,r3	CURSOR
	lodi,r0	$1C
	stra,r0	*CURSOR
	retc,un
*
WRTBL:
	lodi,r0	$20
	bcta,un	WRT
*
TMESS:
	dw	MSGC
*
PSTRNG:
	bsta,un	LFCR
PRING:
	loda,r0	*TMESS,r3
	retc,lt
	bsta,un	WRT
	birr,r3	PRING
*
ZSTRS:
	DS	2
*
ZSTR:
	bsta,un	CTOS
ZER:
	lodi,r2	$FF
	loda,r0	*STMP+4,r2,+
	strr,r0	ZSTRS
	loda,r0	*STMP+4,r2,+
	strr,r0	ZSTRS+1
	loda,r0	*STMP+4,r2,+
	retc,eq
	strz	r2
	eorz	r0
ZSTR2:
	stra,r0	*ZSTRS,r2,-
	brnr,r2	ZSTR2
	retc,un
*
COMNUM:
	loda,r0	CBUF2+2
	coma,r0	CBUF1+2
	bcfa,eq	COMN3
	lodi,r1	$FF
COMN0:
	loda,r0	CBUF1+3,r1,+
	coma,r0	CBUF2+3,r1
	bcfr,eq	COMN1
	comi,r1	$04
	bcfr,eq	COMN0
	loda,r0	CBUF2
	coma,r0	CBUF1
	bctr,eq	CCMN2
COMIN2:
	bsta,un	COMN3
COMIN3:
	loda,r0	CBUF1+2
	retc,eq
INVRT:
	comi,r3	$02
	bctr,eq	INV2
	lodi,r3	$02
	retc,un
*
INV2:
	lodi,r3	$01
	retc,un
*
CCMN2:
	lodi,r3	$00
	loda,r0	CBUF1+1
	coma,r0	CBUF2+1
	retc,eq
	bstr,un	COMN3
	loda,r0	CBUF1
	bctr,eq	COMIN3
	bsta,un	INVRT
	bctr,un	COMIN3
*
COMN1:
	bstr,un	COMN3
	loda,r0	CBUF2
	coma,r0	CBUF1
	bcfr,eq	COMIN2
	iorz	r0
	bctr,lt	COMN4
	loda,r0	CBUF1+1
	coma,r0	CBUF2+1
COMN5:
	bctr,eq	COMIN3
	bctr,un	COMIN2
*
COMN4:
	loda,r0	CBUF2+1
	coma,r0	CBUF1+1
	bctr,un	COMN5
*
COMN3:
	bctr,gt	COMN3A
	lodi,r3	$02
	retc,un
*
COMN3A:
	lodi,r3	$01
	retc,un
*
STRCT:
	stra,r0	CTEMP
	stra,r1	CTEMP+1
	retc,un
*
STROP1:
	strr,r0	OP1
	strr,r1	OP1+1
	retc,un
*
OP1:
	DS	2
*
INCOP1:
	lodr,r0	OP1+1
	addi,r0	$01
	strr,r0	OP1+1
	retc,lt
	retc,gt
	lodr,r0	OP1
	addi,r0	$01
	strr,r0	OP1
	coma,r0	SP
	bcfa,lt	SOER
	retc,un
*
STROP2:
STPOP2:
	strr,r0	OP2
	strr,r1	OP2+1
	retc,un
*
OP2:
	DS	2
*
INCOP2:
	lodr,r0	OP2+1
	addi,r0	$01
	strr,r0	OP2+1
	retc,lt
	retc,gt
	lodr,r0	OP2
	addi,r0	$01
	strr,r0	OP2
	retc,un
*
PSHOP1:
	strr,r0	*OP1
	bcta,un	INCOP1
*
PSHOP2:
	strr,r0	*OP2
	bcta,un	INCOP2
*
INCSP:
	lodr,r3	*SP
	lodi,r0	$01
INCSP2:
	addr,r0	SP+1
	strr,r0	SP+1
	ppsl	$08
	lodr,r0	SP
	addi,r0	$00
	strr,r0	SP
	cpsl	$08
	coma,r0	ENDRAM
	retc,lt
SOER:
	loda,r0	ENDRAM
	subi,r0	$01
	strr,r0	SP
	lodi,r0	$FF
	strr,r0	SP+1
	lodi,r3	$0D
	bcta,un	ERROR
*
SP:
	DS	2
*
DECSP:
	lodr,r0	SP+1
	subi,r0	$01
DECSP2:
	strr,r0	SP+1
	ppsl	$08
	lodr,r0	SP
	subi,r0	$00
	strr,r0	SP
	cpsl	$08
	coma,r0	TABEND
	bcfa,gt	SOER
	strr,r3	*SP
	retc,un
*
PUSHST:
	stra,r0	UTEMP
	stra,r1	UTEMP+1
	lodz	r2
	strz	r3
	bctr,eq	PUSH3
	lodr,r0	SP+1
	subz	r2
	bstr,un	DECSP2
	lodi,r1	$FF
PUSH7:
	loda,r0	*UTEMP,r1,+
	stra,r0	*SP,r2,-
	brnr,r2	PUSH7
PUSH3:
	bstr,un	DECSP
	lodi,r3	$01
	bctr,un	DECSP
*
POPST:
	strr,r0	UTEMP
	strr,r1	UTEMP+1
	lodi,r3	$01
	loda,r0	*SP
	comz	r3
	bcfa,eq	TTFER
	loda,r0	*SP,r3
	strz	r2
	strz	r1
	bctr,eq	POPST3
POPST2:
	loda,r0	*SP,r3,+
	stra,r0	*UTEMP,r1,-
	brnr,r1	POPST2
	lodz	r2
	bsta,un	INCSP2
POPST3:
	lodi,r0	$02
	bcta,un	INCSP2
*
UTEMP:
	DS	2
*
PUSHFP:
	strr,r0	UTEMP
	strr,r1	UTEMP+1
	loda,r0	SP+1
	subi,r0	$09
	lodi,r3	$00
	bsta,un	DECSP2
	lodi,r2	$08
	lodi,r1	$FF
	lodi,r3	$09
PUSHF2:
	loda,r0	*UTEMP,r1,+
	stra,r0	*SP,r3,-
	bdrr,r2	PUSHF2
	retc,un
*
POPFP:
	strr,r0	UTEMP
	strr,r1	UTEMP+1
	lodi,r2	$08
	lodi,r3	$00
	loda,r0	*SP
	bcfa,eq	TTFER
POPFP2:
	loda,r0	*SP,r3,+
	stra,r0	*UTEMP,r2,-
	brnr,r2	POPFP2
	lodi,r0	$09
	bcta,un	INCSP2
*
SINPT:
	lodr,r0	INPT
	strr,r0	STEMP
	lodr,r0	INPT+1
	strr,r0	STEMP+1
	retc,un
*
STEMP:
	DS	2
*
PINPT:
	lodr,r0	STEMP
	strr,r0	INPT
	lodr,r0	STEMP+1
	strr,r0	INPT+1
	retc,un
*
INPT:
	DS	2
*
CSINT:
	lodr,r0	INPT
	strr,r0	CINFT
	lodr,r0	INPT+1
	strr,r0	CINFT+1
	retc,un
*
CINFT:
	DS	2
*
CRINPT:
	lodr,r0	CINFT
	strr,r0	INPT
	lodr,r0	CINFT+1
	strr,r0	INPT+1
	retc,un
*
FPSIN:
	loda,r0	BUFFSTART
	strr,r0	INPT
	eorz	r0
	strr,r0	INPT+1
	retc,un
*
NXTLIN:
	bsta,un	SKPSP
	bsta,un	CHKCR
	bcta,eq	*RTNADR						;INFO: indirect jump
	comi,r0	$21
	bcta,eq	SKPLIN
SYNER:
	lodi,r3	$05
	bcta,un	ERROR
*
CHKCR:
	comi,r0	$0D
	retc,eq
	comi,r0	$3A
	retc,un
*
RETCLT:
	cpsl	$C0
	ppsl	$80
	retc,un
*
RETCGT:
	cpsl	$C0
	ppsl	$40
	retc,un
*
CKNXTL:
	loda,r0	INON
	lodi,r2	$00
	stra,r2	INON
	iorz	r0
	bcta,eq	NXTLIN
	bcta,un	SKPLIN
*
LINNUM:
	DS	4
	
*
GETLIN:
	eorz	r0
	lodi,r1	$04
GETLN2:
	stra,r0	LINNUM,r1,-
	brnr,r1	GETLN2
	lodi,r1	$FF
GETLN3:
	bsta,un	SKPSP
	comi,r0	$30
	bctr,eq	GETLN3
GETLN4:
	bsta,un	CHINUM
	bcfa,eq	DECPT
	comi,r1	$04
	bcta,eq	OVFER
	stra,r0	LINNUM,r1,+
	bsta,un	GETCHR
	bctr,un	GETLN4
*
INCPT:
	loda,r3	INPT+1
	addi,r3	$01
	stra,r3	INPT+1
	retc,lt
	retc,gt
	loda,r3	INPT
	addi,r3	$01
	stra,r3	INPT
	retc,un
*
SKPDEC:
	bsta,un	SKPSP
DECPT:
	loda,r3	INPT+1
	subi,r3	$01
	stra,r3	INPT+1
	ppsl	$08
	loda,r3	INPT
	subi,r3	$00
	stra,r3	INPT
	cpsl	$08
	retc,un
*
GETCHR:
	loda,r0	*INPT
	bsta,un	LTOU
	iorz	r0
	bcfr,lt	INCPT
	bcta,un	SYNER
*
INBUF:
	DS	$41
	
*
AROWCR:
	lodi,r0	$32
	lodi,r1	$34
	lodi,r2	$40
	bsta,un	ARROW
	bcfa,eq	FBEGN
	lodi,r1	$40
AROWC2:
	loda,r0	INBUF,r1,-
	brnr,r0	AROWC3
	brnr,r1	AROWC2
	subi,r1	$01
AROWC3:
	lodi,r0	$0D
	stra,r0	INBUF,r1,+
	loda,r0	INPT
	strr,r0	BTEMP
	loda,r0	INPT+1
	strr,r0	BTEMP+1
	lodi,r0	$32
	stra,r0	INPT
	lodi,r0	$34
	stra,r0	INPT+1
	retc,un
*
BTEMP:
	DS	2
*
RECBT:
	lodr,r0	BTEMP
	stra,r0	INPT
	lodr,r0	BTEMP+1
	stra,r0	INPT+1
	retc,un
*
FNDLIN:
	bsta,un	ECONST
	bcfa,eq	RETNGT
	bsta,un	CSINT
	bsta,un	FPSIN
FNDL2:
	bsta,un	SINPT
	bsta,un	GETLIN
	addi,r1	$01
	coma,r1	CBUF1+1
	bcfr,eq	FNDL5
	lodi,r1	$FF
FNDL4GG:
	lodi,r3	$00
FNDL1:
	loda,r0	LINNUM,r1,+
	andi,r0	$0F
	tmi,r1	$01
	bctr,eq	FNDL3
	rrl,r0
	rrl,r0
	rrl,r0
	rrl,r0
FNDL3:
	iorz	r3
	strz	r3
	comi,r1	$03
	bctr,eq	FNDL4
	comi,r1	$01
	bcfr,eq	FNDL1
	strz	r2
	bctr,un	FNDL4GG
*
FNDL4:
	coma,r2	CBUF1+3
	bcfr,eq	FNDL5
	coma,r3	CBUF1+4
	bcfr,eq	FNDL5
	bsta,un	PINPT
	eorz	r0
	retc,un
*
FNDL5:
	bsta,un	SKPCR
	comi,r0	$0D
	bcfr,eq	FNDL5
	loda,r0	*INPT
	bcfa,lt	FNDL2
	bsta,un	CRINPT
	lodi,r0	$FF
	retc,un
*
SKPCR:
	loda,r3	INPT+1
	eorz	r0
	stra,r0	INPT+1
SKPCR2:
	loda,r0	*INPT,r3
	addi,r3	$01
	bcfr,eq	SKIPCR3
	loda,r3	INPT
	addi,r3	$01
	stra,r3	INPT
	lodi,r3	$00
SKIPCR3:
	bsta,un	CHKCR
	bcfr,eq	SKPCR2
	stra,r3	INPT+1
	retc,un
*
ETEMP:
	DS	1
*
ERROR:
	lodi,r0	$02
	lpsl
	strr,r3	ETEMP
	lodi,r3	$10
	bsta,un	WRTMCR
	lodr,r3	ETEMP
	bsta,un	WRTM
	lodi,r3	$11
	bsta,un	WRTM
	loda,r2	INPT+1
	suba,r2	SBPNT+1
	bsta,un	SBLIN
	bcta,un	FBEGN
*
CTEMP:
	DS	2
	
CBUF1:
	DS	8
	
CBUF2:
	DS	8
	
*
PUSHOP:
	lodr,r1	OPSP
	stra,r0	OPSTK,r1
	addi,r1	$01
	strr,r1	OPSP
	comi,r1	$20
	retc,lt
CSOER:
	lodi,r3	$12
	bcta,un	ERROR
*
OPSP:
	DS	1
OPSTK:
	DS	$20
	
FVALC:
	DS	1
*
POPOF:
	lodr,r1	OPSP
	subi,r1	$01
	bctr,lt	CSOER
	strr,r1	OPSP
	loda,r0	OPSTK,r1
	retc,un
*
EVAL:
	eorz	r0
	strr,r0	OPSP
	strr,r0	FVALC
	stra,r0	PARNST
	lodi,r0	$07
	bsta,un	PUSHOP
	bsta,un	ChNEG
EVAL0:
	bsta,un	LOKVAR
	bcfr,gt	EVAL1
	bsta,un	ECONST
	bcfr,gt	EVAL1
	bsta,un	GETCHR
	comi,r0	$28
	bcta,eq	ELPAR
	bsta,un	DECPT
	lodi,r0	HI(FNCTAB)
	lodi,r1	LO(FNCTAB)
	bsta,un	LOOKUP
	bcta,eq	FFCN
	bctr,un	ENDEVL
*
EVAL1:
	bctr,eq	EVAL2
	bsta,un	PUSHST
	bctr,un	EVAL3
*
EVAL2:
	bsta,un	PUSHFP
EVAL3:
	lodi,r0	$FF
	stra,r0	FVALC
	bsta,un	SKPSP
	comi,r0	$2C
	bcta,eq	FPCOM
	comi,r0	$29
	bcta,eq	ERPAR
	comi,r0	$02
	bcta,eq	RTNVAL
	lodi,r1	$08
EVAL4:
	coma,r0	CPTBL,r1,-
	bcta,eq	EOP
	brnr,r1	EVAL4
	bsta,un	DECPT
ENDEVL:
	bsta,un	POPOF
	strz	r3
	comi,r0	$07
	bctr,eq	ENDE2
	andi,r0	$07
	comi,r0	$03
	bcta,gt	SYNER
	bsta,un	DOCP
	bctr,un	ENDEVL
*
ENDE2:
	loda,r0	FVALC
	bcta,eq	RETCGT
	bsta,un	INCSP
	bsta,un	DECSP
	lodz	r3
	retc,eq
	lodi,r0	$FF
	retc,un
*
EOP:
	comi,r1	$04
	bctr,gt	EOP4
	loda,r0	OPCOD,r1
	rrl,r1
	rrl,r1
	rrl,r1
	iorz	r1
	strr,r0	TEMPOP
EOP2:
	bsta,un	POPOF
	strz	r1
	andi,r0	$07
	lodr,r3	TEMPOP
	andi,r3	$07
	comz	r3
	bcfr,gt	EOP3
	lodz	r1
	bsta,un	PUSHOP
	lodr,r0	TEMPOP
	bsta,un	PUSHOP
	bcta,un	EVAL0
*
EOP3:
	lodz	r1
	strz	r3
	bsta,un	DOCP
	bctr,un	EOP2
*
TEMPOP:
	DS	1
*
EOP4:
	bstr,un	CONVGT
	lodz	r1
	strz	r2
	loda,r0	*INPT
	lodi,r1	$08
EOP4A:
	coma,r0	CPTBL,r1,-
	bctr,eq	EOP5
	comi,r1	$05
	bcfr,eq	EOP4A
	bctr,un	EOP5A
*
EOP5:
	bsta,un	INCPT
	bstr,un	CONVGT
	lodz	r1
	iorz	r2
	strz	r2
EOP5A:
	rrl,r2
	rrl,r2
	rrl,r2
	iori,r2	$03
	lodz	r2
	stra,r0	TEMPOP
	bcta,un	EOP2
*
CONVGT:
	subi,r1	$04
	comi,r1	$03
	retc,lt
	lodi,r1	$04
	retc,un
*
ELPAR:
	lodr,r0	PARNST
	addi,r0	$01
	strr,r0	PARNST
	lodi,r0	$05
	bsta,un	PUSHOP
	bsta,un	ChNEG
	bcta,un	EVAL0
*
PARNST:
	DS	1
*
ERPAR:
	lodr,r0	PARNST
	bcfr,eq	ERPAR2
ERPAR1:
	bsta,un	DECPT
	bcta,un	ENDEVL
*
ERPAR2:
	subi,r0	$01
	strr,r0	PARNST
ERPAR3:
	bsta,un	POPOF
	strz	r3
	andi,r0	$07
	comi,r0	$07
	bcta,eq	SYNER
	comi,r0	$05
	bcta,eq	EVAL3
	comi,r0	$06
	bctr,eq	EFCNEY
	bstr,un	DOCP
	bctr,un	ERPAR3
*
DOCP:
	lodz	r3
	andi,r0	$07
	comi,r0	$03
	bcta,eq	FPCOMP
	rrr,r3
	rrr,r3
	andi,r3	$0E
	loda,r0	FCNJMP,r3
	stra,r0	DCDST
	loda,r0	FCNJMP,r3,+
	stra,r0	DCDST
	bcta,un	*DCDST						;INFO: indirect jump
*
DCDST:
	DS	2
	
*
EFCNEY:
	rrr,r3
	rrr,r3
	andi,r3	$3E
	loda,r0	FCNJMP,r3
	strr,r0	DCDST
	loda,r0	FCNJMP,r3,+
	strr,r0	DCDST
	bsta,un	*DCDST						;INFO: indirect jump
	bcta,un	EVAL3
*
FFCN:
	bsta,un	SKPSP
	comi,r0	$28
	bcfa,eq	SYNER
	loda,r0	PARNST
	addi,r0	$01
	stra,r0	PARNST
	rrl,r1
	rrl,r1
	rrl,r1
	iori,r1	$06
	lodz	r1
	bsta,un	PUSHOP
	bsta,un	ChNEG
	bcta,un	EVAL0
*
FCNJMP:
	dw	FFABS
	dw	FPSGN
	dw	FPFIX
	dw	FPPEEK
	dw	FPCHR
	dw	FPIN
	dw	FPLEN
	dw	FPLPCS
	dw	FPASC
	dw	FPINT
	dw	FPERR
	dw	FPPOS
	dw	FPCALL
	dw	FPRIGHT
	dw	FPLEFT
	dw	FPMID
	dw	FPSTRG
	dw	FPRND
	dw	FFVAPF
	dw	FPINST
	dw	FPFRC
	dw	FPSTR
	dw	FPVAL
	dw	FPSIN
	dw	FPCOS
	dw	FPTAN
	dw	FPATN
	dw	FPIN
	dw	FPLOG
	dw	FPEXP2
	dw	FPSCR
	dw	FPUSR
CPTBL:
	db	"^*/+-<:="
OPCOD:
	db	$00,$01,$01,$02,$02
FCNJMP:
	dw	FPEXP
	dw	FPMULT
	dw	FPDIV
	dw	FPADD
	dw	FPSUB
*
PCPLT:
	lodr,r0	LTEMP+1
	addi,r0	$01
	strr,r0	LTEMP+1
	bcfr,eq	POPLT2
	lodr,r0	LTEMP
	addi,r0	$01
	strr,r0	LTEMP
POPLT2:
	loda,r0	*LTEMP
	retc,un
*
LTEMP:
	DS	5
*
LOKVAR:
	bsta,un	SKPDEC
	bsta,un	SINPT
	loda,r0	VARSTART
	subi,r0	$01
	strr,r0	LTEMP
	lodi,r0	$FF
	strr,r0	LTEMP+1
LOKV1:
	bstr,un	PCPLT
	bcta,eq	FCPEIN
	strr,r0	LTEMP+2
	bstr,un	PCPLT
	strr,r0	LTEMP+3
	bstr,un	PCPLT
	strr,r0	LTEMP+4
	lodi,r2	$04
LOKV2:
	bstr,un	PCPLT
	bctr,eq	LOKV2A
	bsta,un	GETCHR
	comr,r0	*LTEMP
	bcfr,eq	LOKV7
	bdrr,r2	LOKV2
LOKV2A:
	loda,r0	*INPT
	bsta,un	LTOU
	bsta,un	CHKAN
	bctr,eq	LOKV7
	subi,r2	$01
	bcfr,gt	LOKV5
LOKV4:
	bsta,un	PCPLT
	bdrr,r2	LOKV4
LOKV5:
	loda,r0	LTEMP+4
	comi,r0	$01
	bcta,gt	LOKDIM
	bctr,eq	LOKSTR
LOKV6:
	bsta,un	PCPLT
	loda,r0	LTEMP
	loda,r1	LTEMP+1
	lodi,r3	$00
	retc,un
*
LOKV7:
	bsta,un	PINPT
	loda,r0	LTEMP+2
	loda,r1	LTEMP+3
	subi,r1	$01
	ppsl	$08
	subi,r0	$00
	cpsl	$08
	stra,r0	LTEMP
	stra,r1	LTEMP+1
	bcta,un	LOKV1
*
LOKSTR:
	bsta,un	GETCHR
	comi,r0	$24
	bcfa,eq	FCPEIN
LOKST2:
	bsta,un	PCPLT
	strz	r3
	bsta,un	PCPLT
	strz	r1
	bsta,un	PCPLT
	strz	r2
	lodz	r3
	lodi,r3	$FF
	retc,un
*
LDIMS:
	DS	$0A

DIMSTK:
	DS	$08
	
*
LOKDIM:
	strr,r0	LDIMS
	comi,r0	$04
	bcta,eq	FNEVAL
	comi,r0	$02
	bcfr,eq	LOKDNS
	bsta,un	GETCHR
	comi,r0	$24
	bcfa,eq	RETNGT
LOKDNS:
	bsta,un	PCPLT
	strr,r0	LDIMS+1
	lodi,r2	$00
	lodi,r3	$01
	stra,r2	LDIMS+8
	stra,r3	LDIMS+9
LOKD2:
	loda,r2	LDIMS+8
	loda,r3	LDIMS+9
	strr,r0	LDIMS+5
	bsta,un	PCPLT
	strz	r1
	stra,r0	LDIMS+2
LOKD3:
	adda,r3	LDIMS+9
	ppsl	$08
	adda,r2	LDIMS+8
	cpsl	$08
	bdrr,r1	LOKD3
	stra,r2	LDIMS+8
	stra,r3	LDIMS+9
	bsta,un	DECSP
	lodz	r2
	strz	r3
	bsta,un	DECSP
	loda,r3	LDIMS+2
	bsta,un	DECSP
	loda,r0	LDIMS+5
	bdra,r0	LOKD2
	loda,r0	LTEMP
	stra,r0	LDIMS+3
	loda,r0	LTEMP+1
	stra,r0	LDIMS+4
	bsta,un	SKPSP
	comi,r0	$28
	bcfa,eq	SYNER
	lodi,r1	$08
LOKD0:
	stra,r1	LDIMS+2
	bsta,un	SKPDEC
	bsta,un	CHINUM
	bcfa,eq	LOKD6
	bsta,un	INCPT
	andi,r0	$0F
	strz	r2
LOKD9:
	loda,r0	*INPT
	bsta,un	CHINUM
	bcfr,eq	LOKD7
	strz	r1
	andi,r1	$0F
	bsta,un	INCPT
	lodi,r3	$09
	lodz	r2
LOKD8:
	addz	r2
	bdrr,r3	LOKD8
	addz	r1
	strz	r2
	bctr,un	LOKD9
*
LOKD6:
	bsta,un	LOKVAR
	bcfa,eq	RETNGT
	bsta,un	PUSHFP
	bsta,un	ENS2
	iorz	r0
	bcfa,eq	RETNGT
	lodz	r1
	strz	r2
LOKD7:
	loda,r1	LDIMS+2
	lodz	r2
	stra,r0	DIMSTK,r1,-
	lodz	r1
	bcta,eq	RETNGT
	bsta,un	SKPSP
	comi,r0	$2C
	bcta,eq	LOKD0
	comi,r0	$29
	bcfa,eq	RETNGT
	adda,r1	LDIMS+1
	comi,r1	$08
	bcfa,eq	RETNGT
	eorz	r0
	stra,r0	LDIMS+6
	stra,r0	LDIMS+7
	loda,r1	LDIMS+2
	subi,r1	$02
LOKDC:
	comi,r1	$06
	bcta,eq	LOKDF
	loda,r0	DIMSTK,r1,+
	stra,r1	LDIMS+2
	strz	r2
	bsta,un	INCSP
	lodz	r2
	comz	r3
	retc,gt
	bsta,un	INCSP
	bsta,un	INCSP
	lodi,r3	$01
	loda,r0	*SP,r3
	stra,r0	LDIMS+8
	loda,r0	*SP,r3,+
	stra,r0	LDIMS+9
	eorz	r0
	strz	r1
	strz	r3
	comi,r2	$00
	bctr,eq	LOKD5
LOKD4:
	adda,r1	LDIMS+9
	ppsl	$08
	adda,r3	LDIMS+8
	cpsl	$08
	bdrr,r2	LOKD4
LOKD5:
	adda,r1	LDIMS+7
	stra,r1	LDIMS+7
	ppsl	$08
	adda,r3	LDIMS+6
	stra,r3	LDIMS+6
	cpsl	$08
	loda,r1	LDIMS+2
	bcta,un	LOKDC
*
LOKDF:
	bsta,un	INCSP
	coma,r3	DIMSTK+7
	bcta,lt	RETNGT
	bsta,un	INCSP
	bsta,un	INCSP
	loda,r0	DIMSTK,r1,+
	adda,r0	LDIMS+7
	stra,r0	LDIMS+7
	ppsl	$08
	eorz	r0
	adda,r0	LDIMS+6
	stra,r0	LDIMS+6
	cpsl	$08
	loda,r2	LDIMS
	comi,r2	$02
	bctr,eq	LOKDD
	lodi,r2	$07
LOKDD:
	loda,r3	LDIMS+6
	loda,r1	LDIMS+7
LOKDF:
	adda,r1	LDIMS+7
	ppsl	$08
	adda,r3	LDIMS+6
	cpsl	$08
	bdrr,r2	LOKDF
	adda,r1	LDIMS+4
	ppsl	$08
	adda,r3	LDIMS+3
	cpsl	$08
	stra,r3	LTEMP
	stra,r1	LTEMP+1
	loda,r0	LDIMS
	comi,r0	$02
	bcta,eq	LOKST2
	bcta,un	LOKV6
*
FNEVAL:
	bsta,un	SKPSP
	comi,r0	$28
	bcfr,eq	ENRGT
	loda,r0	PARNST
	addi,r0	$01
	stra,r0	PARNST
	bsta,un	PCPLT
	strr,r0	FNS
	bsta,un	PCPLT
	strr,r0	FNS+1
	lodi,r0	$FE
	bsta,un	PUSHOP
	bcta,un	VAL2
*
ENRGT:
	loda,r0	VALS
	stra,r0	INPT
	loda,r0	VALS+1
	stra,r0	INPT+1
	lodi,r0	$01
	retc,un
*
FNS:
	DS	5
*
FPUSR:
	loda,r0	INPT
	stra,r0	VALS
	loda,r0	INPT+1
	stra,r0	VALS+1
	lodr,r0	FNS
	stra,r0	INPT
	lodr,r0	FNS+1
	stra,r0	INPT+1
FN2:
	bsta,un	GETCHR
	bsta,un	CHKCR
	bcta,eq	UFER
	comi,r0	$29
	bcfr,eq	FN2
	bsta,un	SKPSP
	comi,r0	$3D
	bcfa,eq	UFER
	loda,r0	INPT
	strr,r0	FNS+2
	loda,r0	INPT+1
	strr,r0	FNS+3
	bsta,un	SINPT
	lodi,r2	$FF
FN5:
	bsta,un	GETCHR
	stra,r0	FNSTG,r2,+
	comi,r2	$40
	bcta,eq	UFER
	comi,r0	$0D
	bcfr,eq	FN5
	lodi,r0	$02
	stra,r0	FNSTG,r2
	bsta,un	PINPT
	lodi,r0	$03
FN3:
	bsta,un	DECPT
	bdrr,r0	FN3
FN3A:
	bsta,un	DECPT
	loda,r0	*INPT
	comi,r0	$2C
	bctr,eq	FN4
	comi,r0	$28
	bctr,eq	FNEND
	bctr,un	FN3A
*
FN4:
	eorz	r0
	bctr,un	FN5
*
FNEND:
	lodi,r0	$FF
FN5:
	stra,r0	FNS+4
	bsta,un	INCPT
	bsta,un	GCVAR
	bcta,gt	UFER
	bctr,lt	FNSTR
	bsta,un	POPFP
FND:
	loda,r0	*SP
	comi,r0	$05
	bcfr,eq	FNONE
	loda,r0	FNS+4
	bcfa,eq	UFER
	bsta,un	INCSP
FND2:
	bsta,un	DECPT
	loda,r0	*INPT
	comi,r0	$2C
	bcfr,eq	FND2
	bcta,un	FN3A
*
FNONE:
	loda,r0	FNS+4
	bctr,eq	UFER
	lodi,r0	$38
	stra,r0	INPT
	lodi,r0	$8F
	stra,r0	INPT+1
	bcta,un	VAL2
*
FNSTR:
	stra,r0	STMP+4
	stra,r1	STMP+5
	bsta,un	ZER
	loda,r0	*SP
	comi,r0	$01
	bcfa,eq	TTFER
	bsta,un	STRG
	bcta,un	FND
*
UFER:
	lodi,r3	$03
	bcta,un	ERROR
*
FNSTG:
	DS	$29; MAX 40 BYTE
	
DPEND:
	DS	1
ECSTG:
	DS	2
*
ECONST:
	eorz	r0
	strr,r0	DPEND
	strr,r0	ECSTG+1
	lodi,r2	$08
ECON1:
	stra,r0	CBUF1,r2,-
	brnr,r2	ECON1
	bsta,un	SKPDEC
	bsta,un	SINPT
	bsta,un	GETCHR
	comi,r0	$22
	bcta,eq	ESTR
	bsta,un	DECPT
	lodi,r2	$00
	lodi,r1	$00
ECON8:
	bsta,un	GETCHR
	comi,r0	$2E
	bcfr,eq	ECON4
	lodr,r0	DPEND
	bcta,lt	FCPEIN
	stra,r2	CBUF1+1
	lodi,r0	$FF
	strr,r0	DPEND
	brnr,r2	ECON8
FCON6B:
	bsta,un	GETCHR
	comi,r0	$30
	bcfr,eq	FCON6A
	addi,r2	$67
	dar,r2
	bctr,un	FCON6B
*
FCON6A:
	lodz	r2
	bctr,eq	FCON6C
	lodi,r0	$F0
	stra,r0	CBUF1
	stra,r2	CBUF1+1
	lodi,r2	$00
FCON6C:
	bsta,un	DECPT
	bctr,un	ECON8
*
ECON4:
	bsta,un	CHINUM
	bcfr,eq	ECON5
	comi,r0	$30
	bcfr,eq	ECON4A
	loda,r3	DPEND
	bctr,lt	ECON4A
	brnr,r2	ECON4A
	lodi,r0	$FF
	stra,r0	ECSTG+1
	bcta,un	ECON8
*
ECON4A:
	andi,r0	$0F
	tmi,r2	$01
	bctr,eq	ECON6
	comi,r1	$05
	bctr,eq	ECON6
	rrl,r0
	rrl,r0
	rrl,r0
	rrl,r0
ECON6:
	iora,r0	CBUF1+3,r1
	addi,r2	$67
X393A:
	dar,r2
	comi,r1	$05
	bcta,eq	ECON8
	stra,r0	CBUF1+3,r1
X3943:
	tmi,r2	$01
	bcta,eq	ECON8
	bira,r1	ECON8
ECON5:
	comi,r2	$00
	bcfr,eq	ECON5B
	loda,r0	ECSTG+1
	bcta,eq	FCPEIN
	lodi,r0	$F0
	stra,r0	CBUF1
	lodi,r0	$99
	stra,r0	CBUF1+1
	bctr,un	ECOK
*
ECON5B:
	loda,r0	DPEND
	bctr,lt	ECON5A
	stra,r2	CBUF1+1
ECON5A:
	bsta,un	DECPT
	bsta,un	SKPSP
	comi,r0	$45
	bctr,eq	ECON9
ECOK:
	bsta,un	DECPT
	lodi,r0	HI(CBUF1)
	lodi,r1	LO(CBUF1)
	lodi,r3	$00
	retc,un
*
ECON9:
	eorz	r0
	stra,r0	ECSTG
	bsta,un	SKPSP
	comi,r0	$2B
	bctr,eq	ECONB
	comi,r0	$2D
	bcfr,eq	ECONA
	lodi,r0	$F0
	stra,r0	ECSTG
	bctr,un	ECONB
*
ECONA:
	bsta,un	DECPT
ECONB:
	loda,r0	*INPT
	bsta,un	CHINUM
	bcfr,eq	ECOK
	bsta,un	INCPT
	andi,r0	$0F
	strz	r2
	loda,r0	*INPT
	bsta,un	CHINUM
	bcfr,eq	ECONC
	bsta,un	INCPT
	rrl,r2
	rrl,r2
	rrl,r2
	rrl,r2
	andi,r0	$0F
	iorz	r2
	strz	r2
ECONC:
	loda,r0	ECSTG
	coma,r0	CBUF1
	bcfr,eq	ECONC1
	addi,r2	$66
	adda,r2	CBUF1+1
	dar,r2
	tpsl	$01
	bcta,eq	OVFER
	stra,r2	CBUF1+1
	bctr,un	ECONE
*
ECONC1:
	coma,r2	CBUF1+1
	bctr,gt	ECOND
	bctr,lt	ECONC2
	eorz	r0
	stra,r0	CBUF1
	stra,r0	CBUF1+1
	bctr,un	ECONE
*
ECONC2:
	loda,r0	CBUF1+1
	subz	r2
	dar,r0
	stra,r0	CBUF1+1
	bctr,un	ECONE
*
ECOND:
	suba,r2	CBUF1+1
	dar,r2
	stra,r2	CBUF1+1
	loda,r0	ECSTG
	stra,r0	CBUF1
ECONE:
	bsta,un	GETCHR
	bsta,un	CHINUM
	bctr,eq	FCPEIN
	bcta,un	ECOK
*
ESTR:
	lodi,r2	$00
ESTR1:
	loda,r0	*INPT
	bcta,lt	SYNER
	bsta,un	INCPT
	comi,r0	$0D
	bctr,eq	FCPEIN
	comi,r0	$22
	bctr,eq	FSTR2
	birr,r2	ESTR1
FCPEIN:
	bsta,un	PINPT
	bcta,un	RETNGT
*
FSTR2:
	loda,r0	STEMP
	loda,r1	STEMP+1
	addi,r1	$01
	ppsl	$08
	addi,r0	$00
	cpsl	$08
	lodi,r3	$FF
	retc,un
*
LEN	EQU	5
ROUN:
	db	$B6
PTR:
	DS	2
CNTR:
	DS	1
CPA:
	DS	1
EXPA:
	DS	1
X3A33:
	DS	1
MANA:
	DS	LEN+1
OPB:
	DS	1
EXPB:
	DS	1
SMAB:
	DS	1
MANB:
	DS	LEN+1
	
EXT:
	DS	LEN+1
EEXP:
	DS	1
*
TRAN:
	lodi,r0	HI(CPA)
	lodi,r1	LO(CPA)
	bsta,un	POPFP
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	bsta,un	POPFP
	eorz	r0
	stra,r0	MANA+5
	lodi,r1	$08
TRAN2:
	stra,r0	MANB+5,r1,-
	brnr,r1	TRAN2
	retc,un
*
FPSUB:
	bstr,un	TRAN
	loda,r3	X3A33
	eori,r3	$F0
	stra,r3	X3A33
	bctr,un	DA2
*
FPADD:
	loda,r0	*SP
	comi,r0	$01
	bcta,eq	ADDSTR
	bsta,un	TRAN
	loda,r3	X3A33
DA2:
	ppsl	$08
	cpsl	$01
	loda,r1	OPB
	coma,r1	CPA
	bctr,eq	DA6
DA3:
	brnr,r1	DA5
DA7:
	lodi,r0	HI(CPA)
	lodi,r1	LO(CPA)
DA4:
	lodi,r2	$08
	bsta,un	SHFR
	bsta,un	INCR
	bctr,un	DA2
*
DA5:
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	bctr,un	DA4
*
DA6:
	loda,r0	EXPB
	coma,r0	EXPA
	bctr,gt	DA3
	bctr,eq	DAD0
	brnr,r1	DA7
	bctr,un	DA5
*
DAD0:
	loda,r0	X3A33
	coma,r3	SMAB
	bcfr,eq	DAD1
	bstr,un	ADD
	lodi,r2	$09
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	bsta,un	SHFR
	bsta,un	INCR
	bcta,un	RDY
*
DAD1:
	ppsl	$01
	bstr,un	COMP
	bctr,lt	DAD2
	bstr,un	SUB
	bcta,un	RDY
*
DAD2:
	stra,r3	SMAB
	lodi,r2	$06
DAD3:
	loda,r0	MANA,r2,-
	suba,r0	MANB,r2
	dar,r0
	stra,r0	MANB,r2
	brnr,r2	DAD3
	bcta,un	RDY
*
ADD:
	cpsl	$01
	lodi,r1	$00
	lodi,r2	$06
ADD1:
	rrr,r1
	loda,r0	MANB,r2,-
	addi,r0	$66
	rrl,r1
	adda,r0	MANA,r2
	dar,r0
	stra,r0	MANB,r2
	brnr,r2	ADD1
	retc,un
*
COMP:
	lodi,r2	$FA
COM1:
	loda,r0	X3943,r2
	coma,r0	X393A,r2
	bcfr,eq	COM2
	birr,r2	COM1
COM2:
	retc,un
*
SUB:
	ppsl	$01
	lodi,r2	$06
SUB1:
	loda,r0	MANB,r2,-
	suba,r0	MANA,r2
	dar,r0
	stra,r0	MANB,r2
	brnr,r2	SUB1
	retc,un
*
DIV:
	lodi,r3	$0B
DIV1:
	lodi,r1	$00
DIV2:
	bstr,un	COMP
	bctr,lt	DIV3
	bstr,un	SUB
	addi,r1	$66
	dar,r1
	bctr,un	DIV2
*
DIV3:
	adda,r1	EXT+5
	stra,r1	EXT+5
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	lodi,r2	$0F
	bsta,un	SHFL
	bdrr,r3	DIV1
	bsta,un	INCR
	lodi,r3	$0B
DIV4:
	bsta,un	SFL
	bdrr,r3	DIV4
RDY:
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	lodi,r2	$0A
	bstr,un	NORM
	bsta,un	RND
	loda,r0	EEXP
	bcfa,eq	OVFER
	lodi,r0	$02
	lpsl
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	bcta,un	PUSHFP
*
NORM:
	stra,r2	CNTR
	stra,r0	PTR
	stra,r1	PTR+1
	lodi,r3	$00
	lodi,r1	$02
	cpsl	$01
NRM1:
	loda,r0	*PTR,r1,+
	bcfr,eq	NRM2
	addi,r3	$02
	comi,r1	$08
	bcfr,eq	NRM1
	strz	r1
	lodi,r0	$F0
	stra,r0	*PTR
	lodi,r0	$99
	stra,r0	*PTR,r1,+
	eorz	r0
	stra,r0	*PTR,r1,+
	stra,r0	EEXP
	retc,un
*
NRM2:
	andi,r0	$F0
	bcfr,eq	NRM3
	addi,r3	$01
NRM3:
	lodz	r3
	retc,eq
NRM4:
	bstr,un	SFL
	bstr,un	DECR
	bdrr,r3	NRM4
	retc,un
*
SHFL:
	stra,r2	CNTR
	stra,r0	PTR
	stra,r1	PTR+1
SFL:
	lodi,r1	$04
SFL1:
	loda,r2	CNTR
	cpsl	$01
SFL2:
	loda,r0	*PTR,r2,-
	rrl,r0
	stra,r0	*PTR,r2
	comi,r2	$03
	bcfr,eq	SFL2
	bdrr,r1	SFL1
	retc,un
*
DECR:
	loda,r0	*PTR,r1,+
	loda,r2	*PTR
	bctr,eq	DEC3
DEC1:
	addi,r0	$67
	dar,r0
	bcta,eq	OVFER
DEC2:
	stra,r0	*PTR,r1
	retc,un
*
DEC3:
	brnr,r0	DEC5
	coma,r0	EEXP
	bcfr,eq	DEC4
	lodi,r2	$F0
	stra,r2	*PTR
	bctr,un	DEC1
*
DEC4:
	stra,r0	EEXP
DEC5:
	subi,r0	$00
	dar,r0
	bctr,un	DEC2
*
FPDIV:
	bsta,un	TRAN
	loda,r2	CPA
	eori,r2	$F0
	stra,r2	CPA
	lodi,r3	$88
	bctr,un	DM1
*
FPMULT:
	bsta,un	TRAN
	loda,r2	CPA
	lodi,r3	$00
DM1:
	ppsl	$09
	lodz	r3
	bctr,eq	DM2
	loda,r0	MANA
	bcta,eq	OVFER
DM2:
	loda,r0	SMAB
	coma,r0	X3A33
	bctr,eq	DM3
	lodi,r0	$F0
	bctr,un	DM4
*
DM3:
	eorz	r0
DM4:
	stra,r0	SMAB
	coma,r2	OPB
	bcfr,eq	DMU
	loda,r0	EXPA
	addi,r0	$65
	adda,r0	EXPB
	dar,r0
	rrl,r1
	bctr,un	DMU4
*
DMU:
	loda,r0	EXPB
	coma,r0	EXPA
	bctr,gt	DMU2
	bcfr,eq	DMU1
	lodi,r2	$00
DMU1:
	loda,r0	EXPA
	suba,r0	EXPB
	bctr,un	DMU3
*
DMU2:
	loda,r2	OPB
	suba,r0	EXPA
DMU3:
	dar,r0
	stra,r2	OPB
DMU4:
	stra,r0	EXPB
	stra,r1	EEXP
	cpsl	$01
	lodi,r0	HI(CPA)
	lodi,r1	LO(CPA)
	lodi,r2	$08
	bstr,un	SHFR
	brna,r3	DIV
MUL:
	lodi,r3	$0C
MUL1:
	lodi,r0	HI(OPB)
	lodi,r1	LO(OPB)
	lodi,r2	$0E
	bstr,un	SHFR
	bdrr,r3	MUL1
	lodi,r3	$0A
MUL2:
	bstr,un	SHF
MUL3:
	loda,r0	EXT+5
	bctr,eq	MUL4
	subi,r0	$0F
	stra,r0	EXT+5
	bsta,un	ADD
	bctr,un	MUL3
*
MUL4:
	bdrr,r3	MUL2
	bcta,un	RDY
*
RND:
	loda,r0	ROUN
	lodi,r1	$06
RND1:
	adda,r0	MANB,r1,-
	dar,r0
	stra,r0	MANB,r1
	lodi,r0	$66
	brnr,r1	RND1
	tpsl	$01
	retc,lt
	bstr,un	SHF
	bstr,un	INCR
	retc,un
*
SHFR:
	stra,r2	CNTR
	stra,r0	PTR
	stra,r1	PTR+1
SHF:
	lodi,r1	$04
SHF1:
	lodi,r2	$02
SHF2:
	loda,r0	*PTR,r2,+
	rrr,r0
	stra,r0	*PTR,r2
	coma,r2	CNTR
	bcfr,eq	SHF2
	cpsl	$01
	bdrr,r1	SHF1
	retc,un
*
INCR:
	loda,r0	*PTR,r1,+
	loda,r2	*PTR
	bcfr,eq	INC2
	addi,r0	$67
	dar,r0
	bcfr,eq	INC1
	lodi,r1	$01
	stra,r1	EEXP
INC1:
	stra,r0	*PTR,r1
	retc,un
*
INC2:
	brnr,r0	INC3
	stra,r0	EEXP
INC3:
	subi,r0	$00
	dar,r0
	brnr,r0	INC1
	stra,r0	*PTR
	bctr,un	INC1
*
ADDSTS:
	DS	1
*
ADDSTR:
	bsta,un	PPSTRS
	bsta,un	INCSP
	comi,r3	$01
	bcfa,eq	TTFER
	bsta,un	INCSP
	lodz	r2
	addz	r3
	tpsl	$01
	bcfr,eq	ADDST2
	lodi,r0	$FF
	subz	r3
	strz	r2
	lodi,r0	$FF
ADDST2:
	stra,r0	ADDSTS
	bsta,un	PHSTRS
	bsta,un	INCSP
	bsta,un	INCSP
	loda,r3	ADDSTS
	bsta,un	DECSP
	lodi,r3	$01
	bcta,un	DECSP
*
STCOMP:
	bsta,un	COMSTP
	bctr,un	FPCM2
*
FPCOMP:
	strr,r3	COMPS
	loda,r0	*SP
	bcfr,eq	STCOMP
	bsta,un	POPC2
	bsta,un	POPC1
	bsta,un	COMNUM
FPCM2:
	loda,r0	COMPTP,r3
	andr,r0	COMPS
	bcfa,eq	PUSHM1
	bcta,un	PUSH0
*
COMPS:
	DS	1
COMPTP:
	db	$20,$10,$08
*
FPCOM:
	loda,r0	PARNST
	bcta,eq	ERPAR1
*
FPCOM1:
		
	BSTA,UN	POPOF
	COMI,R0	2
	BCTR,GT	FPCOM2
	BSTA,UN	DOCP
	BCTR,UN	FPCOM1
		
*
FPCOM2:
	bsta,un	PUSHOP
	lodi,r3	$05
	bsta,un	DECSP
	bcta,un	EVAL0
*
FPSGN:
	bsta,un	POPC1
	loda,r0	CBUF1+3
	bcta,eq	PUSH0
	loda,r0	CBUF1+2
	bcta,lt	PUSHM1
	bcta,un	PUSH1
*
FFABS:
	bsta,un	POPC1
	eorz	r0
	stra,r0	CBUF1+2
	bcta,un	PUSHC1
*
FPPOS:
	bsta,un	POPC1
	bsta,un	GETDIS
	strz	r1
	eorz	r0
	bcta,un	BTDO
*
FPFIX:
	bsta,un	POPC1
FIX0:
	loda,r0	CBUF1
	bcta,lt	PUSH0
	loda,r1	CBUF1+1
	bcta,un	L1780	;SUPERVISOR
*
L3D7E:
FIX3:
	andi,r1	$E0
FIX4:
	lodi,r2	$08
	lodi,r0	$10
	subz	r1
	dar,r0
	strz	r1
FIX1:
	comi,r1	$01
	bctr,gt	FIX2
	bcta,lt	PUSHC1
	lodi,r0	$F0
	anda,r0	CBUF1,r2,-
	stra,r0	CBUF1,r2
	bcta,un	PUSHC1
*
FIX2:
	subi,r1	$02
	eorz	r0
	stra,r0	CBUF1,r2,-
	bctr,un	FIX1
*
FPLPCS:
	bsta,un	POPC1
	loda,r1	LPOS
	eorz	r0
	bcta,un	BTDO
*
FPINT:
	bsta,un	POPC1
	loda,r0	CBUF1+2
	bcta,eq	FIX0
	lodi,r2	$0A
	loda,r0	CBUF1
	bctr,lt	FPINT2
	loda,r3	CBUF1+1
	bctr,eq	FPINT2
	comi,r3	$09
	bcta,gt	PUSHC1
	lodi,r0	$0A
	subz	r3
	strz	r2
FPINT2:
	lodi,r3	$08
FPINT4:
	loda,r0	CBUF1,r3,-
	comi,r2	$01
	bcta,lt	PUSHC1
	bctr,gt	FPINT3
	andi,r0	$0F
	bcfr,eq	FPINT6
	bcta,un	PUSHC1
*
FPINT3:
	subi,r2	$02
	iorz	r0
	bctr,eq	FPINT4
FPINT6:
	bsta,un	PUSHC1
	bsta,un	PUSH1
*
FPIGG:
	BSTA,UN 	FPSUB
	BCTA,UN	FPFIX
	
*
FPERR:
	bsta,un	POPC1
	loda,r1	ERRTYP
	eorz	r0
	bcta,un	BTDO
*
BTODS:
	DS	3
*
BTDO:
	strz	r2
	lodz	r1
	strz	r3
	eorz	r0
	strr,r0	BTODS
	strr,r0	BTDO+1
	strr,r0	BTDO+2
	lodi,r1	$10
BTOD2:
	lodi,r0	$66		; CODE GEWIJZIGD
	addr,r0	BTDO+2
	strr,r0	UNKNGG+2
	lodi,r0	$66
	addr,r0	BTDO+1
	strr,r0	UNKNGG+1
	lodi,r0	$66
	addr,r0	BTODS
	strr,r0	UNKNGG
	ppsl	$08
	rrl,r3
	rrl,r2
	lodr,r0	UNKNGG+2
	addr,r0	BTDO+2
	dar,r0
	strr,r0	BTDO+2
	lodr,r0	UNKNGG+1
	addr,r0	BTDO+1
	dar,r0
	strr,r0	BTDO+1
	lodr,r0	UNKNGG
	addr,r0	BTODS
	dar,r0
	stra,r0	BTODS
	bctr,un	L3E47
*
UNKNGG:
	db	$00
	db	$00
	db	$00
*
L3E37:
	stra,r0	CTEMP+1
	bsta,un	ERASE
	bcta,un	L204C
*
L3E40:
	stra,r0	*TABEND
	bcta,un	BASIC0
*
	db	$D2
*
L3E47:
	cpsl	$08
	bdra,r1	BTOD2
	eorz	r0
	lodi,r1	$08
L3E4F:
	stra,r0	CBUF1,r1,-
	brnr,r1	L3E4F
	loda,r0	BTODS
	stra,r0	CBUF1+3
	loda,r0	BTDO+1
	stra,r0	CBUF1+4
	loda,r0	BTDO+2
	stra,r0	CBUF1+5
	lodi,r0	$06
	stra,r0	CBUF1+1
	lodi,r0	HI(CBUF1)
	lodi,r1	LO(CBUF1)
	lodi,r2	$08
	ppsl	$08
	bsta,un	NORM
	cpsl	$08
	lodi,r0	HI(CBUF1)
	lodi,r1	LO(CBUF1)
	bcta,un	PUSHFP
ENSX:
	bcta,un	ENS2
*
CALLS:
	DS	2
*
FPCALL:
	bsta,un	ENSX
	strr,r0	CALLS
	strr,r1	CALLS+1
	loda,r0	*SP
	comi,r0	$05
	bcfr,eq	L3E98
	bsta,un	INCSP
	bsta,un	ENSX
L3E98:
	bsta,un	*CALLS						;INFO: indirect jump
	bcta,un	BTDO
*
TYP3SP:
	DS	1
STRSS:
	DS	$11
	
*
FPSTR:
	lodi,r0	$01
	stra,r0	PTYPE
	lodi,r0	$FF
	strr,r0	TYP3SP
	lodi,r2	$11
	eorz	r0
STZ2:
	stra,r0	STRSS,r2,-
	brnr,r2	STZ2
	bsta,un	PRINTF
	lodi,r2	$11
STZ3:
	loda,r0	STRSS,r2,-
	bcfr,eq	STZ4
	brnr,r2	STZ3
	subi,r2	$01
STZ4:
	addi,r2	$01
	lodi,r0	HI(STRSS)
	lodi,r1	LO(STRSS)
	bcta,un	PUSHST
*
VALS:
	DS	2

	
*
FPVAL:
	bsta,un	PPSTRS
	lodi,r0	$02
	bsta,un	VALSUP
	loda,r0	INPT
	strr,r0	VALS
	loda,r0	INPT+1
	strr,r0	VALS+1
	lodi,r0	$40
	stra,r0	INPT
	lodi,r0	$EB
	stra,r0	INPT+1
VAL2:
	spsu
	strz	r1
	subi,r0	$01
	andi,r0	$07
	andi,r1	$F8
	iorz	r1
	lpsu
	bcta,un	EVAL0
*
RTNVAL:
	lodr,r0	VALS
	stra,r0	INPT
	lodr,r0	VALS+1
	stra,r0	INPT+1
	bcta,un	EVAL3
*
FFVAPF:
	loda,r0	*SP
	bctr,gt	VARP2
	bsta,un	POPC1
	bctr,un	VARP3
*
VARP2:
	bsta,un	PPSTRS
VARP3:
	loda,r0	LTEMP
	loda,r1	LTEMP+1
	bcta,un	BTDO
*
FPFRC:
	bsta,un	POPC1
	bsta,un	PUSHC1
	bsta,un	FIX0
	bcta,un	FPSUB
*
PEEKS:
	DS	2
*
FPPEEK:
	eorz	r0
	bsta,un	ENSX
	strr,r0	PEEKS
	strr,r1	PEEKS+1
	lodr,r1	*PEEKS
	eorz	r0
	bcta,un	BTDO
*
FPCHR:
	bsta,un	ENSX10
	lodz	r1
	bcta,lt	OVFER
	comi,r1	$20
	bcta,lt	OVFER
	strz	r3
	bsta,un	DECSP
	lodi,r3	$01
	bsta,un	DECSP
	bcta,un	DECSP
*
ENSX10:
	bsta,un	ENS2
	iorz	r0
	bcfa,eq	OVFER
	retc,un
*
FPIN:
	bstr,un	ENSX10
	strr,r1	FPREDE+1   ; INPUT BYTE
FPREDE	rede,r1	$00
	eorz	r0
	bcta,un	BTDO
*
FPLEN:
	bsta,un	INCSP
	comi,r3	$01
	bcfa,eq	TTFER
	bsta,un	INCSP
	lodz	r3
	strz	r1
	strz	r2
LEN1:
	brnr,r2	LEN2
	eorz	r0
	bcta,un	BTDO
*
LEN2:
	bsta,un	INCSP
	subi,r2	$01
	bctr,un	LEN1
*
FPASC:
	bsta,un	INCSP
	comi,r3	$01
	bcfa,eq	TTFER
	bsta,un	INCSP
	lodz	r3
	strz	r1
	bcta,eq	ARGER
ASC1:
	bsta,un	INCSP
	bdrr,r1	ASC1
	lodz	r3
	strz	r1
	eorz	r0
	bcta,un	BTDO
*
RBUF:
	ds	1
*
FPRND:
	lodr,r0	RBUF
	iori,r0	$01
	strz	r2
	strz	r3
	eorz	r0
	cpsl	$01
	ppsl	$08
	subz	r3
	subi,r2	$00
	subz	r3
	subi,r2	$00
	rrr,r2
	rrr,r0
	rrr,r2
	rrr,r0
	cpsl	$08
	strr,r0	RBUF
	strz	r1
	eorz	r0
	bsta,un	BTDO
	lodi,r0	HI(F1255)
	lodi,r1	LO(F1255)
	bsta,un	PUSHFP
	bsta,un	FPMULT
	bcta,un	FPMULT
*
F1255GG:
F1255:
	dw	$F002,$0039,$2156,$8627
*
LOADSP:
	loda,r0	*SP
	retc,un
*
INSSUP:
	coma,r0	*SP,r1
	retc,un
*
COMSB:
	loda,r0	*SP,r3,-
	retc,un
*
L3FE2:
	bsta,un	COMN3
	bctr,un	L3FEB
*
L3FE7:
	bsta,un	COMN3
L3FEA:
	lodz	r2
L3FEB:
	bcta,un	INCSP2
*
L3FEE:
	bcfr,eq	L3FE2
	strz	r2
	retc,eq
	bcta,un	COMST2
*
L3FF5:
	brna,r3	COMST2
	bctr,un	L3FEA
*
FILLER:
	org $4000
*
VALSUP:
	stra,r0	FPSTRS,r2
	retc,un
*
COMSTP:
	bsta,un	PPSTRS
	bsta,un	INCSP
	comi,r3	$01
	bcfa,eq	TTFER
	bsta,un	INCSP
	lodi,r1	$FF
	lodz	r3
	comz	r2
	bcta,un	L3FEE
*
COMST2:
	bsta,un	COMSB
	coma,r0	FPSTRS,r1,+
	bcfa,eq	L3FE7
	bcta,un	L3FF5
*
FPSTRG:
	bsta,un	ENSX10
	lodz	r1
	bcta,lt	OVFER
	comi,r1	$20
	bcta,lt	OVFER
	stra,r1	STRS
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bsta,un	ENSX10
	lodz	r1
	strz	r2
	strz	r3
	bctr,eq	STRG3
	loda,r0	STRS
STRG2:
	stra,r0	FPSTRS,r3,-
	brnr,r3	STRG2
STRG3:
	bcta,un	PHSTRS
*
MIDS:
	ds	2
*
FPMID:
	bsta,un	ENSX10
	strr,r1	MIDS
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bsta,un	LOADSP
	bcfr,eq	FPMID3
	bsta,un	ENSX
	comi,r1	$00
	bcta,eq	OVFER
	subi,r1	$01
	strr,r1	MIDS+1
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bctr,un	FPMID4
*
FPMID3:
	lodr,r0	MIDS
	bcta,eq	OVFER
	subi,r0	$01
	strr,r0	MIDS+1
	lodi,r0	$FF
	strr,r0	MIDS
FPMID4:
	bsta,un	PPSTRS
	coma,r2	MIDS+1
	bcfr,gt	FPMID6
	suba,r2	MIDS+1
	coma,r2	MIDS
	bctr,lt	FPMID5
	loda,r2	MIDS
FPMID5:
	stra,r2	MIDS
	lodz	r2
	bctr,eq	FPMID6
	loda,r1	MIDS+1
FPMID7:
	loda,r0	FPSTRS,r1
	strz	r3
	bsta,un	DECSP
	addi,r1	$01
	bdrr,r2	FPMID7
	loda,r3	MIDS
FPMID8:
	bsta,un	DECSP
	lodi,r3	$01
	bcta,un	DECSP
*
FPMID6:
	lodi,r3	$00
	bctr,un	FPMID8
*
FPLEFT:
	bsta,un	ENSX10
	stra,r1	FPLRS
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bsta,un	PPSTRS
	stra,r2	STRS
	loda,r1	FPLRS
	coma,r1	STRS
	bcfr,gt	LEFT2
	loda,r1	STRS
LEFT2:
	lodz	r1
	strz	r2
PHSTRS:
	lodi,r0	HI(FPSTRS)
	lodi,r1	LO(FPSTRS)
	bcta,un	PUSHST
*
PPSTRS:
	lodi,r0	HI(FPSTRS)
	lodi,r1	LO(FPSTRS)
	bcta,un	POPST
*
FPSTRS:
	ds	$100
STRS:
	ds	1
FPLRS:
	ds	1
*
FPRIGHT:
	bsta,un	ENSX10
	strr,r1	FPLRS
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bsta,un	PPSTRS
	strr,r2	STRS
	loda,r1	FPLRS
	coma,r1	STRS
	bcfr,gt	RIGHT2
	loda,r1	STRS
RIGHT2:
	lodz	r1
	strz	r2
	loda,r0	STRS
	subz	r1
	addi,r0	$EB
	strz	r1
	ppsl	$08
	lodi,r0	$40
	addi,r0	$00
	cpsl	$08
	bcta,un	PUSHST
*
INSTS:
	DS	4
*
FPINST:
	lodi,r1	$01
	bsta,un	LOADSP
	bcfr,eq	INST2
	bsta,un	ENSX10
	lodz	r1
	bcta,eq	OVFER
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
INST2:
	subi,r1	$01
	stra,r1	INSTS
	bsta,un	PPSTRS
	stra,r2	INSTS+1
	bsta,un	INCSP
	comi,r3	$05
	bcfa,eq	ARGER
	bsta,un	INCSP
	comi,r3	$01
	bcfa,eq	TTFER
	bsta,un	INCSP
	coma,r3	INSTS
	bcfa,gt	INST3A
	stra,r3	INSTS+3
	suba,r3	INSTS
	stra,r3	INSTS+2
INST2A:
	loda,r1	INSTS+2
	loda,r0	INSTS+1
	subi,r0	$01
	comz	r1
	bcta,eq	INST3A
	subi,r1	$01
	stra,r1	INSTS+2
	lodi,r2	$FF
	loda,r3	INSTS+1
INST3:
	loda,r0	FPSTRS,r2,+
	bsta,un	INSSUP
	bcfr,eq	INST2A
	subi,r1	$01
	bdrr,r3	INST3
	loda,r0	INSTS+3
	bsta,un	INCSP2
	loda,r1	INSTS+3
	suba,r1	INSTS+2
	eorz	r0
	bcta,un	BTDO
*
INST3A:
	loda,r0	INSTS+3
	bsta,un	INCSP2
	bcta,un	PUSH0
*
OPTION:
	lodi,r3	$00
	bsta,un	WRTMCR
	bsta,un	GETKB
	bsta,un	LTOU
	comi,r0	$1B
	bcta,eq	BSET
	comi,r0	$42
	bctr,eq	FBEGN
	comi,r0	$52
	bctr,eq	RUN
	comi,r0	$53
	bctr,eq	STEP
	comi,r0	$44
	bcta,eq	DIRECT
	bsta,un	WRBL
	lodi,r0	$3F
	bsta,un	WRT
	bctr,un	OPTION
*
FBEGN	bsta,un	FPSIN
	bcta,un	OPTION
*
RUN:
	lodi,r3	$01
	bsta,un	WRTM
NORM1:
	redd,r0
	andi,r0	$7F
	comi,r0	$1B
	bcfr,eq	RUN5
	bsta,un	PL
	bcta,un	OPTION
*
RUN5:
	lodi,r0	HI(NORM1) 
	lodi,r1	LO(NORM1) 
	bcta,un	EXEC
*
STEP:
	lodi,r3	$01
	bsta,un	WRTM
STEP1	bsta,un	SAVINP
	lodi,r2	$FF
	bsta,un	SBLIN
	bsta,un	PAUSE
	comi,r0	$1B
	bcta,eq	OPTION
	lodi,r0	HI(STEP1)	
	lodi,r1	LO(STEP1)
	bcta,un	EXEC
*
DIRECT:
	bsta,un	LFCR
	bsta,un	AROWCR
	lodi,r0	HI(DIRECT)
	lodi,r1	LO(DIRECT)
	bcta,un	EXEC
*
LET:
	bsta,un	GCVAR
	bctr,lt	LETSTR
	bcta,gt	ARGER
	bsta,un	STRCT
	bsta,un	SKPEC
	bsta,un	EVAL
	bcfa,eq	NOSTR
	bsta,un	POPCT
LETD:
	bsta,un	SKPSP
	comi,r0	$2C
	bctr,eq	LET
	bsta,un	DECPT
	bcta,un	NXTLIN
*
LETSTR:
	bsta,un	STRCT
	bsta,un	SKPEC
	bsta,un	EVAL
	bcfa,lt	NOSTR
	bsta,un	ZSTR
	bsta,un	STRINGT
	bctr,un	LETD
*
REM:
	bsta,un	SKPCR
	comi,r0	$0D
	bcfr,eq	REM
	bcta,un	*RTNADR						;INFO: indirect jump
*
EXTOUT:
	bsta,un	EVAL
	bsta,un	ENS1B
	strr,r1	XOUTX+1
	bsta,un	SKPCOM
	bsta,un	EVAL
	bsta,un	ENS1B
XOUTX	wrte,r1	$00    ; WRITE TO OUTPUT
	bcta,un	NXTLIN
*
ENDI:
	bsta,un	FPSIN
	bctr,un	STOP1
*
STOP:
	bsta,un	SKPSP
	bsta,un	CHKCR
	bcfa,eq	SYNER
STOP1:
	lodi,r3	$07
	bsta,un	WRTMCR
	bcta,un	OPTION
*
GOT0:
	bsta,un	FNDLIN
	bcta,eq	*RTNADR						;INFO: indirect jump
ENTER:
	lodi,r3	$08
	bcta,un	ERROR
*
PAUSER:
	bsta,un	EVAL
	bsta,un	ENS
	strz	r2
PAUS2:
	lodz	r1
	bcfr,eq	PAUS3
	lodz	r2
	bcta,eq	NXTLIN
PAUS3:
	lodi,r3	$3C
PAUS4:
	bstr,un	L1
	redd,r0
	andi,r0	$7F
	comi,r0	$1B
	bcta,eq	OPTION
	bdrr,r3	PAUS4
	subi,r1	$01
	ppsl	$08
	subi,r2	$00
	cpsl	$08
	bctr,un	PAUS2
*
L1:
	lodi,r0	$DB
L43B4:
	bdrr,r0	L43B4
	retc,un
*
READ:
	bsta,un	GCVAR
	bctr,lt	RDSTR
	bcta,gt	ARGER
	bsta,un	STRCT
	bsta,un	GETDAT
	bcta,gt	RDNIF
	bcta,lt	RDTYPE
	bsta,un	POPCT
RDDEL:
	bsta,un	SKPSP
	comi,r0	$2C
	bctr,eq	READ
	bsta,un	DECPT
	bcta,un	NXTLIN
*
RDSTR:
	bsta,un	STRCT
	bsta,un	ZSTR
	bsta,un	GETDAT
	bcta,gt	RDNIF
	bcta,eq	RDTYPE
	bsta,un	STRINGT
	bctr,un	RDDEL
*
COMMA:
	DS	1
DP:
	DS	1
PUSTG:
	DS	3
*
PUSING:
	bsta,un	EVAL
	bcfa,lt	NOSTR
	bsta,un	ZERCMS
	lodi,r0	HI(CMSTRS)
	lodi,r1	LO(CMSTRS)
	bsta,un	POPST
	bsta,un	SKPSP
	comi,r0	$3B
	bcfa,eq	SYNER
PUIOCP:
	bsta,un	PDGET
	bcta,eq	PUDEPT
	comi,r0	$21
	bcfr,eq	PU2
	bsta,un	EVAL
	bcta,gt	PRINTD6
	bcfa,lt	NOSTR
	lodi,r1	$01
	bsta,un	PRINTS
	bcta,un	PUDEI
*
PU2:
	comi,r0	$5E
	bcfr,eq	PU3
	lodi,r2	$01
PU2B:
	bsta,un	PDGET
	addi,r2	$01
	comi,r0	$5E
	bcfr,eq	PU2B
	stra,r2	PUSTG
	bsta,un	EVAL
	bcta,gt	PRINTD6
	bcfa,lt	NOSTR
	loda,r1	PUSTG
	bsta,un	PRINTS
	bcta,un	PUDEI
*
PU3:
	comi,r0	$23
	bctr,eq	PU4
	bsta,un	SENDIT
	bcta,un	PUIOCP
*
PU4:
	lodi,r2	$01
	stra,r2	COMMA
	stra,r2	DP
	eorz	r0
	stra,r0	PUSTG+2
PU5:
	bsta,un	PDGET
	addi,r2	$01
	comi,r0	$23
	bctr,eq	PU5
	comi,r0	$2C
	bctr,eq	PU6
	comi,r0	$2E
	bcfr,eq	PUEND
	subi,r2	$01
	stra,r2	PUSTG+1
	lodi,r2	$00
	stra,r2	DP
	bctr,un	PU5
*
PU6:
	loda,r0	DP
	bcta,eq	SYNER
	eorz	r0
	stra,r0	COMMA
	bctr,un	PU5
*
PUEND:
	subi,r1	$01
	bsta,un	STRPUS
	subi,r2	$01
	loda,r0	DP
	bctr,eq	PU7
	stra,r2	PUSTG+1
	bctr,un	PU8
*
PU7:
	stra,r2	PUSTG+2
PU8:
	bsta,un	EVAL
	bcta,gt	PRINTD6
	bcfa,eq	NOSTR
	loda,r0	PUSTG+1
	subi,r0	$01
	comi,r0	$FF
	bcta,eq	SYNER
	loda,r1	PUSTG+2
	loda,r2	COMMA
	loda,r3	DP
	bsta,un	PRNTPU
PUDEI:
	bsta,un	SKPSP
	comi,r0	$2C
	bcta,eq	PUIOCP
	comi,r0	$3B
	bcta,eq	PRINTD6
	bsta,un	DECPT
	bcta,un	NXTLIN
*
PUDEPT:
	lodi,r0	$FF
	stra,r0	*IPUSP
	bcta,un	PUIOCP
*
IPUSP:
	dw	PUSP
	
	
RESUME1	BSTA,UN FNDLIN
	BCFA,EQ	RETURN
	BSTA,UN INCSP
	COMI,R3 2
	BCFA,EQ NESTER
	BSTA,UN INCSP
	BSTA,UN INCSP
	BCTA,UN *RTNADR
X2STG:
	DS	2
*
X10:
	lodi,r3	$00
	ppsl	$08
	cpsl	$01
	rrl,r1
	rrl,r0
	rrl,r3
	strr,r0	X2STG
	strr,r1	X2STG+1
	rrl,r1
	rrl,r0
	rrl,r3
	rrl,r1
	rrl,r0
	rrl,r3
	addr,r1	X2STG+1
	addr,r0	X2STG
	addi,r3	$00
	cpsl	$08
	iori,r3	$00
	bcfa,eq	OVFER
	retc,un
*
FPEXP:
X4514:
	bsta,un	POPC1
	bsta,un	POPC2
	bsta,un	PUSHC1
	bsta,un	PUSHC2
	bsta,un	FPIN
	bsta,un	FPMULT
	bcta,un	FPEXP2
*
ChNEG:
	bsta,un	SKPSP
	comi,r0	$2B
	retc,eq
	comi,r0	$2D
	bcfa,eq	DECPT
	bsta,un	PUSH0
	lodi,r0	$22
	bcta,un	PUSHOP
*
CHKAN:
	bstr,un	CHINUM
	retc,eq
	comi,r0	$41
	retc,lt
	comi,r0	$5A
	retc,gt
	cpsl	$C0
	retc,un
*
CHINUM:
	comi,r0	$30
	retc,lt
	comi,r0	$39
	retc,gt
	cpsl	$C0
	retc,un
*
WRTMS:
	DS	2
*
WRTMCR:
	bsta,un	LFCR
WRTM:
	lodi,r2	$00
	lodi,r1	$FF
WRTM2:
	lodz	r2
	comz	r3
	bctr,eq	WRTM4
WRTM3:
	loda,r0	MSG0,r1,+
	comi,r0	$2E
	bcfr,eq	WRTM3
	addi,r2	$01
	bctr,un	WRTM2
*
WRTM4:
	loda,r0	MSG0,r1,+
	comi,r0	$2E
	retc,eq
	bsta,un	WRT
	bctr,un	WRTM4
*
OVFER:
	lodi,r3	$06
	bctr,un	ADER
*
NESTER:
	lodi,r3	$09
	bctr,un	ADER
*
TTFER:
	lodi,r3	$0A
	bctr,un	ADER
*
ARGER:
	lodi,r3	$0B
	bctr,un	ADER
*
DIMER:
	lodi,r3	$0C
	bctr,un	ADER
*
NDER:
	lodi,r3	$02
	bctr,un	ADER
*
NDER:
	lodi,r3	$0F
ADER:
	bcta,un	ERROR
*
ERASE:
	lodi,r2	$10
	lodi,r1	$00
	bsta,un	SETCUR
	lodi,r1	$10
ERASE1:
	bsta,un	LFCR
	bdrr,r1	ERASE1
	lodi,r2	$10
	lodi,r1	$00
	bcta,un	SETCUR
*
LTOU:
	tmi,r0	$60
	retc,lt
	andi,r0	$DF
	retc,un
*
PUSH1:
	lodi,r0	HI(FP1)
	lodi,r1	LO(FP1)
	bcta,un	PUSHFP
*
PUSHM1:
	lodi,r0	HI(FPM1)
	lodi,r1	LO(FPM1)
	bcta,un	PUSHFP
*
PUSH0:
	lodi,r0	HI(FP0)
	lodi,r1	LO(FP0)
	bcta,un	PUSHFP
*
FP0:
	dw	$F099,$0000,$0000,$0000
	
FP1:
	dw	$0001,$0010,$0000,$0000

FPM1:
	dw	$0001,$F010,$0000,$0000

*
POPC1:
	lodi,r0	HI(CBUF1)
	lodi,r1	LO(CBUF1)
	bcta,un	POPFP
*
PUSHC1:
	lodi,r0	HI(CBUF1)
	lodi,r1	LO(CBUF1)
	bcta,un	PUSHFP
*
POPC2:
	lodi,r0	HI(CBUF2)
	lodi,r1	LO(CBUF2)
	bcta,un	POPFP
*
PUSHC2:
	lodi,r0	HI(CBUF2)
	lodi,r1	LO(CBUF2)
	bcta,un	PUSHFP
*
TABSTC:
	DS	2
*
LOOKUP:
	strr,r0	TABSTC
	strr,r1	TABSTC+1
	bsta,un	SKPDEC
	bsta,un	SINPT
	lodi,r1	$FF
LOOK2:
	bsta,un	GETCHR
	strz	r3
	loda,r0	*TABSTC,r1,+
	comi,r0	$2E
	bctr,eq	LOOK4
	comz	r3
	bctr,eq	LOOK2
LOOK3:
	loda,r0	*TABSTC,r1,+
	comi,r0	$2E
	bcfr,eq	LOOK3
	bsta,un	PINPT
	addi,r1	$03
	loda,r0	*TABSTC,r1
	retc,lt
	subi,r1	$01
	bctr,un	LOOK2
*
LOOK4:
	loda,r0	*TABSTC,r1,+
	strz	r3
	loda,r0	*TABSTC,r1,+
	strz	r1
	lodz	r3
	bsta,un	DECPT
	cpsl	$C0
	retc,un
*
NOSTR:
	bcta,gt	ARGER
	bcta,un	TTFER
*
SKPLIN:
	bsta,un	SKPCR
	bcta,un	*RTNADR						;INFO: indirect jump
*
SKPSP:
	bsta,un	GETCHR
	comi,r0	$20
	bctr,eq	SKPSP
	retc,un
*
SKPCOM:
	bstr,un	SKPSP
	comi,r0	$2C
	bcfa,eq	SYNER
	retc,un
*
SKPEC:
	bsta,un	SKPSP
	comi,r0	$3D
	bcfa,eq	SYNER
	retc,un
*
RETNGT:
	cpsl	$C0
	ppsl	$40
	retc,un
*
RETNLT:
	cpsl	$C0
	ppsl	$80
	retc,un
*
RETCEC:
	cpsl	$C0
	retc,un
*
FNCTAB:
	
	db	'ABS.'
	db	$00, $00 
	DB	'SGN.' 
	DB	$00, $01
	db	'FIX.'
	db	$00, $02 
	DB	'PEEK.' 
	DB	$00,$03
	DB	'CHR$.'
	db	$00, $04
	db	'INP.'
	db	$00, $05
	db	'LEN.'
	DB	$00, $06
	db	'LPOS.'
	db	$00, $07
	db	'ASC.'
	db	$00,$08 
	DB	'INT.'
	db	$00, $09
	db	'ERR.' 
	DB	$00,$0A 
	DB	'POS.'
	db	$00, $0B
	db	'CALL.'
	db	$00, $0C 
	DB	'RIGHT$.'
	db	$00, $0D
	db	'LEFT$.'
	db	$00, $0E
	db	'MID$.'	
	db	$00, $0F
	db	'STRING$.'
	db	$00, $10
	db	'RND.'
	db	$00, $11
	DB	'VARPTR.'
	db	$00, $12
	db	'INSTR$.'
	db	$00, $13
	db	'FRC.'
	db	$00, $14
	db	'STR$.'
	db	$00, $15
	db	'VAL'
	db	$00, $16
X4704:
	db	'SIN.'
	db	$00, $17
	DB	'COS.'
	db	$00, $18
	db	'TAN.'
	db	$00, $19
	db	'ATN.'
	DB	$00, $1A
	db	'LN.'
	db	$00, $1B
	DB	'LOG.'
	db	$00, $1C
	db	'EXP.'
	DB	$00,$1D
	db	'SQR.'
	db	$00, $1E
	DB 	$FF
MSG0:
	db	'OPTION  .'
	DB	'OK.'
	db	'OUT OF DATA.'
	db	'USER FN.'
	db	'REDO FROM START  .'
	db	'SYNTAX.'
	db	'OVF.'
	db	'STOPPED.'
	db	'LINE NOT FOUND.'
	db	'NEST.'
	db	'TYPE MISMATCH.'
	db	'ARG.'
	db	'DIM.'
	db	'STACK OVF.'
	db	'STR SPACE OVF.'
	db	'VAR ALREADY DEFINED.'
	db	'*** .'
	db	' ERROR ***.'
	db	'EXPR TO COMPLEX.'
	
IFTBL:
	DB	'THEN.'
	DW	$0000
ELSETBL	DB	'ELSE.'
	DW	$0001
	DB	$FF

CNTTBL	DB	'GOTO.'
	DW	$0000
	DB	'GOSUB.'
	DW	$0002
	DB	'RESTORE.'
	DW	$0004
	DB	'EXIT.'
	DW	$0006
	DB	'ERROR.'
	DW	$0008
	DB	'RESUME.'
	DW	$000A
	DB	$ff
	
FORTBL	DB	'TO.'
	DW	$0001
	DB	'STEP.'
	dw	$0002
	DB	$FF
		
TABLIT	DB	'TAB.'
	dw	$0000
	db	$ff
	
DATTBL	DB	'DATA.'
	dw	$0000
	DB	'END.'
	DW	$0003
	DB	$FF
COMTBL2:
	db	'LET.'
	dw	LET
	db	'PRINT.' 
	DW	PRINT
	db	'PAUSE.'
	dw	PAUSE
	db	'IF.'
	dw	IFF
	db	'GOTO.'
	dw	GOT0
	db	'GOSUB.'
	dw	GOSUB
	db	'RETURN.'
	dw	RETURN

	db	'FOR.'
	dw	FOR

	db	'NEXT.'
	dw	NEXT

	db	'INPUT.'
	dw	INPUT

	db	'DATA.'
	dw	SKPLIN

	db	'ERASE.'
	dw	ERASEB

	db	'READ.'
	dw	READ

	db	'POKE.'
	dw	POKT
	
	db	'OUT.'
	dw	EXTOUT

	db	'DIM.'
	dw	DIM

	db	'RESTORE.'
	dw	RESTOR

	db	'ELSE.'
	dw	SKPLIN

	db	'END.'
	dw	ENDI


	db	'STOP.'
	dw	STOP

	db	'REM.'
	dw	REM

	db	'SWAP.'
	dw	SWAP
	
	db	'ON.'
	dw	ON
	

	db	'EXIT.'
	dw	EXIT

	db	'WAIT.'
	dw	WAIT

	db	'LPRINT.'
	dw	LPPINT

	db	'ERROR.'
	dw	ERRORC
	
	db	'RESUME.'
	dw	RESUME1

	db	'DEF.'
	dw	DEFF

	db	'RANDOMIZE.'
	dw	RANDOM

	db	'MID$(.'    ; HAAKJE IN SCAN : FOUT ?
	dw	$28AC 	; 2 MIDS LABELS

	db	'CLEAR.'
	dw	PURGE

	db	$FF
	
	
CURA 	DS	2
DIMA	DS	1
DUM2	DS	1
TMPAE	DS	1
TEMP2	DS	1
BSA1	DS	2
CHGA	DS	2
CBGST:	DS	2

BSTRT2	DW	BUFFSTART
IBST2	DW	INSBUFF
CBST	DW	VARSTART
ENDDRM2   DW	ENDRAM

TABSS	dB	$07, $12, $1B

MBUFF	DS	16

COMS	DS	1
NAME2	DS	16
TMPS	DS	1

TEMP	ds	1
BSHT	DW	BUFFSTART
*
EDITOR:
	;eorz	r0     NOT NEEDED SEE NEXT INSTRUCTION
	;lodz	r3
BSET:
	lodi,r0	$02
	lpsl
	ppsu	$40
	eorz	r0
	stra,r0	X4A59
	bsta,un	ERASE
	bsta,un	BEGIN2
RFFDW:
	bsta,un	DISP   ; SUPERVISOR
COMD:
	lodi,r2	$10
	lodi,r1	$2F
	bsta,un	SETCUR
	bsta,un	OLFCR
	lodi,r2	$10
	lodi,r1	$80
	bsta,un	SETCUR
	lodi,r3	$00
	bsta,un	PRING
	bsta,un	FINDND
	loda,r3	*BSTRT2
	suba,r3	DIMA
	subi,r3	$01
	bsta,un	BTODCT
	lodi,r2	$13
	lodi,r1	$20
	bsta,un	SETCUR
	lodi,r3	$58
	bsta,un	PRING
	redd,r0
	nop
	nop
	bsta,un	OLC
	lodi,r0	HI(COMS)
	lodi,r1	LO(COMS)
	lodi,r2	$11
	bsta,un	ARROW
	bcfa,eq	RETU  ;;RETURN SUPERVISOR 0083
	loda,r0	COMS
	bsta,un	LTOU
	bsta,un	OLC
	eorz	r0
	strz	r1
	lodi,r3	$FF
NI:
	loda,r0	NAME2,r3,+
	bctr,eq	CK0
	comi,r3	$10
	bcfr,lt	EADD
	comi,r0	$30
	bctr,lt	DSX
	comi,r0	$39
	bctr,gt	DSX
	lodz	r1
	lodi,r2	$09
ONE2:
	addz	r1
	tpsl	$01
	bctr,eq	D255
	bdrr,r2	ONE2
	strz	r1
	loda,r0	NAME2,r3
	subi,r0	$30
	addz	r1
	strz	r1
	tpsl	$01
	bcfr,eq	NI
D255:
	lodi,r1	$FF
	bctr,un	EADD
*
CK0:
	comi,r3	$00
	bcfr,eq	EADD
	lodi,r1	$01
	bctr,un	EADD
*
DSX:
	lodi,r1	$00
EADD:
	loda,r0	COMS
	bsta,un	LTOU
	strz	r3
	subi,r3	$41
	comi,r3	$19
	bcta,gt	COMD
	rrl,r3
	iori,r3	$80
	strr,r3	JUMPTB+1   ;MUST BE IN RAM
JUMPTB	bctr,un	*X4A47	 ;MUST BE IN RAM					;INFO: indirect jump
*
COMTAB:
	dw	ISAVE	;A=append buffer afyter line Y
	dw	BACK 	;B=Back X lines
	dw	CHANGE	;C= change lines
	dw	DELT 	;D=DELETE X LINES
	dw	$0083	;e=EXIT TO SUPERVISOR/PIPBUG
	dw	FBED	;F=FOWARD X LINES 
	dw	BASIC	;(OR ZSET ?  $1774) g=goto basic
	dw	SAVE 	;H-=HOLD X LINES IN INSERT BUFFER
	dw	INST	;INSERT LINES AFTER X
	dw	COMD 	
	dw	COMD
	dw	LOADL	;LOAD X LINES FROM DISK
	dw	MODIFY	;P=PRESET MODIFY PATTERNS
	dw	ULCASE 	;NORMAL LOWER CASE MODE
	dw	COMD
	dW	PMOD	;PRESET MODIFY PATTERNS 
	dw	COMD
X4A47:
	DW	COMD
	DW	TAPEO	;$51, $41 ; TO FIX 
	DW	COMD
	DW	UPONLY	;u = uppercase mode
	DW	COMD
	DW	COMD 
	DW	SEARCH	;X=SEARCH FOR ASCCI STRING
	DW	COMD
	DW	COMD
X4A59:
	DS	1
*
ULCASE:
	eorz	r0
	strr,r0	X4A59
	bcta,un	COMD
*
UPONLY:
	lodi,r0	$FF
	strr,r0	X4A59
	bcta,un	COMD
*
OLC:
	comi,r0	$2B
	bcta,eq	ENDF
	comi,r0	$2D
	bcta,eq	FBEGN
	comi,r0	$20
	bcta,eq	F15
	comi,r0	$2F
	bcta,eq	B15
	retc,un
*
CURIT:
	dw	CURSOR+1
LINEI:
	db	$00
*
DISP:
	bsta,un	MTDA
	strz	r1
	eorz	r0
	stra,r0	*CURIT
	stra,r0	DUM2
	strr,r0	LINEI
LINENO:
	bsta,un	OLFCR
	loda,r0	*CURIT
	andi,r0	$0F
	retc,eq
	loda,r0	*DIMA,r1
	bcta,lt	CLREND
	lodr,r0	LINEI
	addi,r0	$01
	strr,r0	LINEI
	strz	r3
	comi,r0	$09
	bctr,gt	TWOCR
	bsta,un	WRTBL
	bctr,un	WR2ND
*
TWOCR:
	lodi,r0	$31
	bsta,un	WRT
	subi,r3	$0A
WR2ND:
	iori,r3	$30
	lodz	r3
	bsta,un	WRT
	bsta,un	WRTBL
NXTC:
	loda,r0	*DIMA,r1
	bctr,lt	CLREND
	strz	r3
	birr,r1	NA1
	bsta,un	A1DA
	bcfr,lt	CLREND
NA1:
	comi,r3	$0D
	bcta,eq	LINENO
	lodz	r3
	bsta,un	WRT
	bctr,un	NXTC
*
ERASE2:
	eorz	r0
	stra,r0	*CURIT
	bsta,un	CLREND
	bsta,un	OLFCR
	retc,un
*
CLREND:
	loda,r0	*CURIT
	tmi,r0	$0F
	retc,eq
	bsta,un	OLFCR
	bctr,un	CLREND
*
FTEMP:
	DS	1
*
FWDX:
	bsta,un	MTDA
FWDX2:
	strz	r2
	lodz	r1
	retc,eq
	eorz	r0
	stra,r0	DUM2
NXTCHR:
	loda,r0	*DIMA,r2
	bctr,lt	ENDFW
	strr,r0	FTEMP
	birr,r2	CRCK
	bsta,un	A1DA
	bctr,lt	CRCK
	bsta,un	S1DA
	lodi,r2	$FF
	lodi,r0	$83
	stra,r0	*DIMA,r2
	bctr,un	ENDFW
*
CRCK:
	lodr,r0	FTEMP
	comi,r0	$0D
	bcfr,eq	NXTCHR
	bdrr,r1	NXTCHR
ENDFW:
	stra,r2	DUM2
	retc,un
*
A1DA:
	lodi,r0	$01
	adda,r0	DIMA
	stra,r0	DIMA
	coma,r0	*BSTRT2
	retc,un
*
ENDF:
	bstr,un	FINDND
	bsta,un	PCTA
	lodi,r1	$01
	bctr,un	BACK
*
FINDND:
	bsta,un	MTDA
FNDND2:
	lodi,r1	$FF
	bsta,un	FWDX2
	loda,r0	*DIMA
	retc,lt
	loda,r0	DUM2
	bctr,un	FNDND2
*
B15:
	lodi,r1	$0F
BACK:
	bstr,un	BACKX
	bctr,un	FBED
*
F15:
	lodi,r1	$0F
	bsta,un	FWDX
FBED:
	bstr,un	PCTA
	bcta,un	RFFDW
*
BACKX:
	bsta,un	MTDA
	strz	r2
	eorz	r0
	stra,r0	DUM2
	addi,r1	$01
	bctr,un	CBYI
*
SUBL:
	loda,r0	*DIMA,r2,-
CBYI:
	strz	r3
	comi,r2	$00
	bcfr,eq	NOSU
	bsta,un	S1DA
	coma,r0	*CBGST
	bctr,lt	REGN
NOSU:
	comi,r3	$0D
	bcfr,eq	SUBL
	bdrr,r1	SUBL
	comi,r2	$00
	bsta,eq	A1DA
	addi,r2	$01
	bsta,eq	A1DA
	stra,r2	DUM2
	retc,un
*
PCTA:
	loda,r0	DIMA
	stra,r0	CURA
	loda,r0	DUM2
	stra,r0	CURA+1
	retc,un
*
CREATE:
	bstr,un	BEGIN2
	lodi,r0	$83
	stra,r0	*CURA
REGN:
	bsta,un	BEGIN2
	bcta,un	RFFDW
*
BEGIN2:
	loda,r0	*CBGST
	stra,r0	CURA
	eorz	r0
	stra,r0	CURA+1
	retc,un
*
MTDA:
	loda,r0	CURA
	stra,r0	DIMA
	loda,r0	CURA+1
	stra,r0	DUM2
	retc,un
*
BTODCT:
	comi,r3	$63
	bcfr,gt	NO100
	lodi,r0	$31
	bsta,un	WRT
	subi,r3	$64
NO100:
	lodi,r2	$00
SUB10:
	comi,r3	$09
	bcfr,gt	TENIN
	subi,r3	$0A
	addi,r2	$01
	bctr,un	SUB10
*
TENIN:
	lodz	r2
	iori,r0	$30
	bsta,un	WRT
	lodz	r3
	iori,r0	$30
	bsta,un	WRT
	retc,un
*
INST:
	bsta,un	ERASE2
	bsta,un	IBADD
	bsta,un	FWDX
	bsta,un	PCTA
	bsta,un	FINDND
	lodi,r1	$00
NEXI:
	bsta,un	GETKB
	comi,r0	$08
	bcta,eq	PACKN
	comi,r0	$09
	bcta,eq	TAB0
	comi,r0	$03
	bctr,eq	BYPAS
	bsta,un	CKCTRL
	bctr,lt	NEXI
BYPAS:
	stra,r0	*TMPAE,r1
	comi,r0	$03
	bctr,eq	END1
	comi,r0	$0D
	bsta,eq	LFCR
	bstr,un	INSTS2
	bctr,un	NEXI
*
INSTS2:
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	ADDNY
	coma,r0	*BSTRT2
	bctr,lt	INCB2
	bsta,un	S1DA
	lodi,r0	$FE
	stra,r0	DUM2
	bctr,un	ENDINS
*
INCB2:
	birr,r1	RETCON
	lodi,r0	$01
	adda,r0	TMPAE
	coma,r0	*ENDDRM2
	bcfr,lt	STRTMP
	stra,r0	TMPAE
RETCON:
	retc,un
*
STRTMP:
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	lodi,r1	$FF
ENDINS:
	lodi,r0	$03
	stra,r0	*TMPAE,r1
END1:
	loda,r0	DIMA
	stra,r0	TMPAE
	loda,r3	DUM2
	bsta,un	FINDND
	bsta,un	SDCA
	loda,r1	DUM2
	eorz	r0
	stra,r0	DUM2
	stra,r0	TMPAE+1
DOWN:
	loda,r0	*DIMA,r1
	stra,r0	*TMPAE,r3
	lodi,r0	$01
	lodi,r2	$06
	bsta,un	SUBANT
	bcfr,eq	NCKK
	loda,r0	BSA1
	bctr,eq	INSTDN
NCKK:
	subi,r1	$01
	comi,r1	$FF
	bcfr,eq	NS1DA
	bsta,un	S1DA
	coma,r0	*CBGST
	bctr,lt	INSTDN
NS1DA:
	subi,r3	$01
	comi,r3	$FF
	bcfr,eq	DOWN
	loda,r0	TMPAE
	subi,r0	$01
	stra,r0	TMPAE
	bctr,un	DOWN
*
INSTDN:
	bsta,un	IBADD
	bsta,un	MTDA
	strz	r1
	eorz	r0
	stra,r0	DUM2
	lodi,r3	$FF
INSERT:
	loda,r0	*TMPAE,r3,+
	comi,r0	$03
	bctr,eq	INSTE
	stra,r0	*DIMA,r1
	comi,r3	$FF
	bsta,eq	A1TA
	birr,r1	INSERT
	bsta,un	A1DA
	bctr,lt	INSERT
INSTE:
	lodi,r1	$01
	bcta,un	BACK
*
S1DA:
	loda,r0	DIMA
	subi,r0	$01
	stra,r0	DIMA
	retc,un
*
SDCA:
	loda,r0	DUM2
	suba,r0	CURA+1
	stra,r0	BSA1
	ppsl	$08
	loda,r0	DIMA
	suba,r0	CURA
	stra,r0	TEMP2
	cpsl	$08
	lodi,r0	$01
	lodi,r2	$06
	bcta,un	ADDNY
*
IBADD:
	loda,r0	*BSTRT2
	stra,r0	TMPAE
	eorz	r0
	stra,r0	TMPAE+1
	retc,un
*
PACKN:
	bsta,un	BACK1
	bcta,lt	NEXI
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	bcta,un	NEXI
*
X4CF5:
	db	$01
*
SUBANT:
	strr,r0	X4CF5
	loda,r0	CURA+1,r2
	subr,r0	X4CF5
	stra,r0	CURA+1,r2
	ppsl	$08
	loda,r0	CURA,r2
	subi,r0	$00
	stra,r0	CURA,r2
	cpsl	$08
	retc,un
*
A1TA:
	lodi,r0	$01
	adda,r0	TMPAE
	stra,r0	TMPAE
	retc,un
*
DELT:
	bsta,un	FWDX
	bstr,un	SBIF
	lodi,r1	$01
	bcta,un	BACK
*
SBIF:
	loda,r3	CURA
	stra,r3	TMPAE
	loda,r3	CURA+1
	loda,r1	DUM2
	eorz	r0
	stra,r0	TMPAE+1
	stra,r0	DUM2
UP:
	loda,r0	*DIMA,r1
	stra,r0	*TMPAE,r3
	retc,lt
	addi,r3	$01
	bsta,eq	A1TA
	birr,r1	UP
	bsta,un	A1DA
	bctr,lt	UP
	retc,un
*
ADDNY:
	adda,r0	CURA+1,r2
	stra,r0	CURA+1,r2
	ppsl	$08
	eorz	r0
	adda,r0	CURA,r2
	stra,r0	CURA,r2
	cpsl	$08
	retc,un
*
NOTFON:
	lodi,r3	$19
	bcta,un	ERROR2
*
TME:
	lodi,r3	$10
	bcta,un	ERROR2
*
TAB0:
	bsta,un	TABSUB
	bcta,eq	NEXI
T13:
	lodi,r0	$20
	stra,r0	*TMPAE,r1
	bsta,un	WRT
	bsta,un	INSTS2
	bdrr,r3	T13
	bcta,un	NEXI
*
TABSUB:
	lodi,r3	$FF
	loda,r0	TMPAE
	stra,r0	TEMP2
	stra,r1	BSA1
TL1:
	addi,r3	$01
	lodi,r0	$01
	lodi,r2	$06
	bsta,un	SUBANT
	coma,r0	*BSTRT2
	bctr,lt	CPFND
	loda,r0	*TEMP2
	comi,r0	$0D
	bcfr,eq	TL1
CPFND:
	lodi,r2	$FF
TL2:
	loda,r0	TABSS,r2,+
	comi,r2	$03
	retc,eq
	comz	r3
	bcfr,gt	TL2
	subz	r3
	strz	r3
	retc,un
*
S2:
	bsta,un	MTDA
	strz	r1
	eorz	r0
	stra,r0	DUM2
	stra,r0	SSTAT
	loda,r0	DIMA
	stra,r0	TMPAE
	stra,r1	TMPAE+1
BIDO:
	lodi,r2	$FF
SL2:
	loda,r0	NAME2,r2,+
	bctr,eq	FOUND
	bsta,un	LTOU
	comi,r2	$10
	bctr,eq	FOUND
	strz	r3
	loda,r0	*DIMA,r1
	bcta,lt	NF
	bsta,un	LTOU
	stra,r0	TMPS
	birr,r1	NCAD
	bsta,un	A1DA
	bcfr,lt	NF
NCAD:
	loda,r0	TMPS
	comz	r3
	bctr,eq	SL2
	lodi,r0	$01
	lodi,r2	$04
	bsta,un	ADDNY
	loda,r0	TMPAE
	stra,r0	DIMA
	loda,r1	TMPAE+1
	bctr,un	BIDO
*
FOUND:
	stra,r1	DUM2
	stra,r2	TEMP
	lodz	r2
	lodi,r2	$02
	bsta,un	SUBANT
	loda,r2	TEMP
	retc,un
*
SSTAT:
	DS	1
*
NF:
	lodi,r0	$FF
	strr,r0	SSTAT
	bsta,un	MTDA
	retc,un
*
SEARCH:
	lodi,r1	$01
	bsta,un	FWDX
	bsta,un	PCTA
	bsta,un	S2
	lodr,r0	SSTAT
	bcta,lt	NOTFON
	bsta,un	PCTA
	lodi,r1	$00
	bcta,un	BACK
*
SAVE:
	bsta,un	IBADD
	bsta,un	FWDX
	bsta,un	SDCA
	bsta,un	MTDA
	strz	r1
	eorz	r0
	stra,r0	DUM2
	strz	r3
SL:
	loda,r0	*DIMA,r1
	stra,r0	*TMPAE,r3
	birr,r1	CER3
	bsta,un	A1DA
	bcfr,lt	SL3
CER3:
	birr,r3	SLCK
	bsta,un	A1TA
	coma,r0	*ENDDRM2
	bctr,lt	SLCK
SLCK:
	lodi,r0	$01
	lodi,r2	$06
	bsta,un	SUBANT
	bcfr,eq	SL
	loda,r0	BSA1
	comi,r0	$01
	bcfr,eq	SL
SL3:
	lodi,r0	$03
	stra,r0	*TMPAE,r3
	bcta,un	COMD
*
ISAVE:
	bsta,un	FWDX
	bsta,un	PCTA
	bsta,un	FINDND
	bsta,un	IBADD
	lodi,r1	$00
ISL2:
	lodi,r0	$03
ISL:
	coma,r0	*TMPAE,r1
	bctr,eq	IFOUND
	birr,r1	ISL
	bsta,un	A1TA
	coma,r0	*ENDDRM2
	bcfa,lt	RFFDW
	bctr,un	ISL2
*
IFOUND:
	loda,r0	TMPAE
	suba,r0	*BSTRT2
	adda,r0	DIMA
	stra,r0	DIMA
	lodz	r1
	lodi,r2	$02
	bsta,un	ADDNY
	coma,r0	*BSTRT2
	bcfa,lt	TME
	bcta,un	END1
*
PMOD:
	lodi,r2	$15
	lodi,r1	$0F
	bsta,un	SETCUR
	bsta,un	OLFCR
	lodi,r1	$FF
NXTNM:
	loda,r0	NAME2,r1,+
	stra,r0	MNAME,r1
	comi,r1	$0F
	bcfr,eq	NXTNM
	lodi,r3	$23
	bsta,un	PRING
	lodi,r1	$55
	lodi,r0	$49
	lodi,r2	$10
	bsta,un	ARROW
	bcta,un	COMD
*
MTEMP:
	DS	1
*
MODIFY:
	lodz	r1
	bcta,eq	COMD
	subi,r1	$01
	bsta,un	FWDX
	bsta,un	PCTA
	lodi,r1	$FF
	lodi,r2	$10
XFER:
	loda,r0	MNAME,r1,+
	stra,r0	NAME2,r1
	bdrr,r2	XFER
	lodi,r1	$01
	bsta,un	FWDX
	loda,r0	*DIMA
	strr,r0	MTEMP
	lodi,r0	$83
	stra,r0	*DIMA
	bsta,un	S2
	stra,r2	TMPS
	bsta,un	PCTA
	lodi,r1	$01
	bsta,un	FWDX
	lodr,r0	MTEMP
	stra,r0	*DIMA
	loda,r0	SSTAT
	bcta,lt	NOTFON
	bsta,un	MTDA
	loda,r0	TMPS
	lodi,r2	$02
	bsta,un	ADDNY
	bsta,un	SBIF
	bsta,un	IBADD
	lodi,r1	$FF
ML1:
	loda,r0	MBUFF,r1,+
	bctr,eq	ENDM
	stra,r0	*TMPAE,r1
	comi,r1	$0F
	bcfr,eq	ML1
	lodi,r1	$10
ENDM:
	lodi,r0	$03
	stra,r0	*TMPAE,r1
	stra,r1	TMPS
	bsta,un	FINDND
	loda,r0	TMPS
	lodi,r2	$02
	bsta,un	ADDNY
	coma,r0	*BSTRT2
	bcfa,lt	TME
	bcta,un	END1
*
CKCTRL:
	comi,r0	$0D
	bcfr,eq	CKDP12
	cpsl	$80
	ppsl	$40
	retc,un
*
CKDP12:
	eori,r0	$FF
	ppsl	$10
	strz	r1
	eori,r0	$FF
	tmi,r1	$E0
	bcfr,eq	NOCTCK
	ppsl	$80
	cpsl	$50
	retc,un
*
NOCTCK:
	cpsl	$D0
	retc,un
*
CHANGE:
	lodz	r1
	bcta,eq	COMD
	bsta,un	IBADD
	subi,r1	$01
	bsta,un	FWDX
	bsta,un	PCTA
	bsta,un	ERASE2
	bsta,un	FINDND
	loda,r0	CURA
	stra,r0	BSA1+1
	loda,r0	CURA+1
	stra,r0	CHGA+1
	lodi,r1	$00
DISPL:
	bsta,un	LFCR
	loda,r0	*CURIT
	tmi,r0	$0F
	bsta,eq	ERASE2
	loda,r2	BSA1+1
	stra,r2	TEMP2
	loda,r3	CHGA+1
DISPLP:
	loda,r0	*BSA1+1
	bcta,lt	INDCHG
	comi,r0	$0D
	bctr,eq	ELEND
	bsta,un	WRT
	lodi,r0	$01
	lodi,r2	$08
	bsta,un	ADDNY
	coma,r0	*BSTRT2
	bctr,lt	DISPLP
	bcta,un	INDCHG
*
ELEND:
	stra,r3	CHGA+1
	loda,r0	TEMP2
	stra,r0	BSA1+1
	bsta,un	LFCR
CHGL:
	bsta,un	GETKB
	comi,r0	$08
	bcfr,eq	NOCHBS
	bsta,un	CHBACK
	bctr,un	CHGL
*
NOCHBS:
	comi,r0	$09
	bcfr,eq	NOBT
	bsta,un	TABSUB
	bctr,eq	CHGL
TABL3:
	stra,r3	TEMP2
	lodi,r3	$20
	bsta,un	STRTMS
	loda,r3	TEMP2
	bdrr,r3	TABL3
	bcta,un	CHGL
*
NOBT:
	comi,r0	$15
	bcfr,eq	MOCOPY
	bsta,un	LOADD
	bctr,eq	CHGL
	bsta,un	STRTMS
	bctr,un	CHGL
*
MOCOPY:
	comi,r0	$19
	bcfr,eq	NOCWD
CWD1:
	bsta,un	LOADD
	bctr,eq	CHGL
	comi,r3	$20
	bcfr,eq	CWD3
	bsta,un	STRTMS
	bctr,un	CWD1
*
CWD2:
	loda,r3	*BSA1+1
	comi,r3	$20
	bcta,eq	CHGL
	comi,r3	$2C
	bcta,eq	CHGL
	bsta,un	LOADD
	bcta,eq	CHGL
CWD3:
	bsta,un	STRTMS
	bctr,un	CWD2
*
NOCWD:
	comi,r0	$0E
	bcfr,eq	NOIBWD
	stra,r1	CHGA+1
	loda,r0	TMPAE
	stra,r0	CHGA
ERWD1:
	lodi,r2	$0A
	lodi,r0	$01
	bsta,un	SUBANT
	loda,r0	*CHGA
	comi,r0	$20
	bcfr,eq	ERWD3
	bsta,un	CHBACK
	bctr,un	ERWD1
*
ERWD2:
	lodi,r2	$0A
	lodi,r0	$01
	bsta,un	SUBANT
	loda,r0	*CHGA
	comi,r0	$20
	bcta,eq	CHGL
	comi,r0	$2C
	bcta,eq	CHGL
ERWD3:
	bsta,un	CHBACK
	bctr,un	ERWD2
*
NOIBWD:
	comi,r0	$10
	bcfr,eq	MCCEOL
COPYLF:
	bsta,un	LOADD
	bcta,eq	CHGL
	bsta,un	STRTMS
	bctr,un	COPYLF
*
MCCEOL:
	comi,r0	$0F
	bcfr,eq	NODISC
	bsta,un	LOADD
	bcta,un	CHGL
*
NODISC:
	strz	r3
	comi,r0	$03
	bctr,eq	BYPASS
	bsta,un	CKCTRL
	bcta,lt	CHGL
BYPASS:
	bsta,un	STRT2
	lodz	r3
	comi,r0	$0D
	bctr,eq	ENDCEL
	comi,r0	$03
	bcfa,eq	CHGL
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	bcta,un	ENDCH
*
ENDCEL:
	bsta,un	LOADD
	bcfr,eq	ENDCEL
	bsta,un	A1SC
	bcta,un	DISPL
*
ENDCH:
	loda,r0	DIMA
	stra,r0	TEMP2
	loda,r0	DUM2
	stra,r0	BSA1
	loda,r0	BSA1+1
	stra,r0	DIMA
	loda,r0	CHGA+1
	stra,r0	DUM2
	bsta,un	SBIF
	loda,r0	TEMP2
	stra,r0	DIMA
	loda,r0	BSA1
	stra,r0	DUM2
	bcta,un	END1
*
LOADD:
	loda,r3	*BSA1+1
	comi,r3	$0D
	retc,eq
A1SC:
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	lodi,r0	$01
	lodi,r2	$08
	bsta,un	ADDNY
	lodi,r0	$80
	retc,un
*
STRTMS:
	lodz	r3
	bsta,un	WRT
STRT2:
	lodz	r3
	stra,r0	*TMPAE,r1
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	ADDNY
	coma,r0	*BSTRT2
	bctr,lt	A1R1
	bsta,un	S1DA
	lodi,r0	$FE
	stra,r0	DUM2
	bcta,un	INDCHG
*
A1R1:
	birr,r1	BETCND
	lodi,r0	$01
	adda,r0	TMPAE
	coma,r0	*ENDDRM2
	bcfr,lt	ABRUPT
	stra,r0	TMPAE
BETCND:
	retc,un
*
ABRUPT:
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	lodi,r1	$FF
INDCHG:
	lodi,r0	$03
	stra,r0	*TMPAE,r1
	bcta,un	ENDCH
*
CHBACK:
	bsta,un	BACK1
	retc,lt
	lodi,r0	$01
	lodi,r2	$02
	bsta,un	SUBANT
	retc,un
*
LOADLS:
	DS	3
*
LOADL:
	bsta,un	AOK
	bsta,un	LOADA
	bcfa,eq	SCERR
	bcta,un	RFFDW
SCERR:
	bcta,un	L17B7  ;ERROR2
*
	DB	$2F, $4C 
		
		;$3F, $17 $D9, 
TAPEO		BSTA,UN	L17D9	
		;$0C, $89, $4A
		LODA,R0	*BSTRT2
		;$CC, $09, $40,
		STRA,R0	DIMA 
		;$20
TAPEEOT		EORZ	R0
		;$C8, $B7, 
		STRR,R0	*SUMK
		;$CC, $09	$41, 
		STRA,R0	DUM2
		;$07, $3B, 
		LODI,R3	';'  ;(3b)
		;$3F $02, $4F, 
		BSTA,UN	SEROUT
		;$05, $FF
		LODI,R1	$FF
		;$0D, $29, $66, 
NAMO		LODA,R1	NAME2,+		
		;$C3
		STRZ	R3
		;$3F, $02, $4F,
		BSTA,UN	SEROUT
		;$E5 $07, 
		COMI,R1	07
		;$98, $75, 
		BCFR,EQ	NAMO
		;$0B $A0, 
		LODR,R3	*SUMK
		;$3F, $02, $4F
		BSTA,UN	SEROUT
		;$05, $00, 
		LODI,R1	0
		;$C9, $99
		STRR,R1	*SUMK
		;$0D, $E9, $40, 
BYTEO		LODA,R0	*DIMA,R1   ; ERROR ?
		;$C3
		STRZ	R3
		;$1A, $15, 
		BCTR,LT	ENDO
		;$3F, $02	$4F, 
		BSTA,UN	SEROUT
		;$D9, $75, 
		BIRR,R1	BYTEO
		;$0B $8C, 
		LODR,R3	*SUMK
		;$3F, $02, $4F
		BSTA,UN	SEROUT
		;$3F, $4B, $1A, 
		BSTA,UN 	A1DA
		;$9E $49, $89, 
		BCFA,LT	RFFDW
		;$1F, $51 $4A
		BCTA,UN	TAPEEOT
SUMK:
	dw	SUMC
*
ENDO:
	bsta,un	SEROUT 	;SUPERVISOR
	lodr,r3	*SUMK
	bsta,un	SEROUT	;SUPERVISOR
	bcta,un	RFFDW
*
LOADA:
	bsta,un	MTDA
WAITF:
	eorz	r0
	stra,r0	*SUMK
	bsta,un	SERIN	;SUPERVISOR
	comi,r3	$3B
	bcfr,eq	WAITF
	lodi,r1	$FF
NAML:
	bsta,un	SERIN	;SUPERVISOR
	loda,r0	NAME2,r1,+
	bctr,eq	OVERSI
	comz	r3
	bcfr,eq	WAITF
OVERSI:
	comi,r1	$07
	bcfr,eq	NAML
	bsta,un	SERIN	;SUPERVISOR
	loda,r0	*SUMK
	retc,lt
	retc,gt
	loda,r1	DUM2
	stra,r0	DUM2
	stra,r0	TMPS
BASCII:
	bsta,un	SERIN	;SUPERVISOR
	lodz	r3
	stra,r0	*DIMA,r1
	bctr,lt	ENDING
	birr,r1	IL1
	bsta,un	A1DA
	bctr,lt	IL1
	bsta,un	S1DA
	lodi,r1	$FF
	lodi,r0	$BC
	stra,r0	*DIMA,r1
	bcta,un	TME
*
IL1:
	loda,r2	TMPS
	addi,r2	$01
	stra,r2	TMPS
	bcfr,eq	BASCII
	bsta,un	SERIN	;SUPERVISOR
	stra,r1	DUM2
	loda,r3	*SUMK
	bcta,eq	WAITF
	retc,un
*
ENDING:
	bsta,un	SERIN	;SUPERVISOR
	loda,r0	*SUMK
	retc,un
*
AOK:
	lodi,r3	$63
	bsta,un	PRING
	bsta,un	ERAS1
	retc,un
*
MSGC:
	db	"BLOCKS  LEFT:  "
	db	$FF
MSGD:
	db	"TOO MUCH"
	db	$FF
MSGE:
	db	"NOT FOUND"
	db	$FF
MSGF:
	db	"MODIFY STRING '"
MNAME:
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
MSGTO:
	db	"' TO '"
	db	$FF
MSG10:
	db	"SUMCHECK ERROR"
	db	$FF
MSG1D:
	db	"COMMAND:  "
	db	$FF
MSG1F:
	db	" OK"
	db	$FF
*
FPSCR:
	bsta,un	POPC3
	bsta,un	PUSHC3
	loda,r0	C3SIGN
	bcta,lt	OVFER
	bsta,un	POPC4
	loda,r0	C4EX
	rrr,r0
	andi,r0	$77
	stra,r0	X52D5
	eorz	r0
	stra,r0	ZTEMP1
	bsta,un	PUSHC4
	lodi,r0	HI(QTR)
	lodi,r1	LO(QTR)
	bsta,un	PUSHFP
	bsta,un	FPMULT
	bsta,un	POPC4
	lodr,r0	X52D5
	stra,r0	C4EX
	bsta,un	PUSHC4
	bsta,un	POPC2
SCU1:
	bsta,un	PUSHC2
	bsta,un	POPC1
	bsta,un	PUSHC3
	bsta,un	PUSHC1
	bsta,un	FPDIV
	bsta,un	PUSHC1
	bsta,un	FPADD
	bsta,un	PUSHH
	bsta,un	FPMULT
	lodi,r0	$01
	adda,r0	ZTEMP1
	comi,r0	$FF
	retc,gt
	stra,r0	ZTEMP1
	bsta,un	POPC2
	bsta,un	COMNUM
	lodz	r3
	bcfr,eq	SCU1
	bcta,un	PUSHC2
*
X52D5:
	db	$00
*
PUSHH:
	lodi,r0	HI(HALF)
	lodi,r1	LO(HALF)
	bcta,un	PUSHFP
*
PS2:
	lodi,r0	HI(TWO)
	lodi,r1	LO(TWO)
	bcta,un	PUSHFP
*
PUSHC3:
	lodi,r0	HI(C3TEMP)
	lodi,r1	LO(C3TEMP)
	bcta,un	PUSHFP
*
POPC3:
	lodi,r0	HI(C3TEMP)
	lodi,r1	LO(C3TEMP)
	bcta,un	POPFP
*
PUSHC4:
	lodi,r0	HI(C4TEMP)
	lodi,r1	LO(C4TEMP)
	bcta,un	PUSHFP
*
POPC4:
	lodi,r0	HI(C4TEMP)
	lodi,r1	LO(C4TEMP)
	bcta,un	POPFP
*
PUSHC5:
	bdra,r3	LNGG ;$$
	rete,un
*
	db	$1F, $31, $38
*
POPC5:
	lodi,r0	HI(C5TEMP)
	lodi,r1	LO(C5TEMP)
	bcta,un	POPFP
*
PUSHPI:
	lodi,r0	HI(EEF)
	lodi,r1	LO(EEF)
	bcta,un	PUSHFP
*
PUSHF:
	lodi,r0	HI(EEF)
	lodi,r1	LO(EEF)
	bcta,un	PUSHFP
*
PUSHIN:
	lodi,r0	HI(LN10)
	lodi,r1	LO(LN10)
	bcta,un	PUSHFP
*
PUSHIG:
	lodi,r0	HI(LOGC)
	lodi,r1	LO(LOGC)
	bcta,un	PUSHFP
*
CGTERM:
	bsta,un	POPC1
	bsta,un	PUSHC1
	bsta,un	COMNUM
	lodz	r3
	bcfr,eq	GTERM
	lodi,r0	$01
	retc,un
*
GTERM:
	bsta,un	POPC2
	bsta,un	PUSHC2
	bsta,un	PUSHC3
	bsta,un	PUSHC4
	bsta,un	FPMULT
	bsta,un	POPC3
	bsta,un	PUSHC3
	loda,r1	TERMNM
	adda,r1	DUP
	stra,r1	TERMNM
	comi,r1	$78
	bctr,gt	GTERM2
	adda,r1	OFFSET
	addi,r1	$C5
	ppsl	$08
	eorz	r0
	addi,r0	$56
	cpsl	$08
	bsta,un	PUSHFP
	bsta,un	FPMULT
	eorz	r0
	retc,un
*
GTERM2:
	bsta,un	POPC1
	lodi,r0	$01
	retc,un
*
CTERM:
	bsta,un	POPC4
	bsta,un	PUSHC4
	lodi,r0	$08
	stra,r0	DUP
	lodi,r0	$F8
	stra,r0	TERMNM
	eorz	r0
	stra,r0	OFFSET
	stra,r0	SSIGN
	bsta,un	PUSH1
	bcta,un	POPC3
*
DOUBLE:
	bsta,un	PUSHC4
	bsta,un	PUSHC4
	bsta,un	FPMULT
	bsta,un	POPC4
	lodi,r0	$10
	stra,r0	DUP
	retc,un
*
GSIGN:
	bsta,un	POPC1
	bsta,un	PUSHC1
	bsta,un	PUSHC1
	bsta,un	PUSHPI
	bsta,un	FPDIV
	bsta,un	FPFIX
	bsta,un	POPC4
	loda,r0	C4EX
	bctr,eq	CSIGN2
	comi,r0	$0A
	bctr,gt	CSIGN2
	strz	r2
	subi,r0	$01
	rrr,r0
	andi,r0	$07
	loda,r0	C4MAIN,r0
	tmi,r2	$01
	bcfr,eq	CSIGN3
	rrr,r0
	rrr,r0
	rrr,r0
	rrr,r0
CSIGN3:
	tmi,r0	$01
	bcfr,eq	CSIGN2
	bsta,un	PUSHC4
	bsta,un	PUSH1
	loda,r0	C4SIGN
	bctr,eq	CSIGN5
	bsta,un	FPSUB
	bctr,un	CSIGN4
*
CSIGN5:
	bsta,un	FPADD
	bctr,un	CSIGN4
*
CSIGN2:
	bsta,un	PUSHC4
CSIGN4:
	bsta,un	PUSHPI
	bsta,un	FPMULT
	bcta,un	FPSUB
*
FPSIN:
	bsta,un	GSIGN
	bsta,un	CTERM
	bsta,un	POPC4
	bsta,un	PUSHC4
	bsta,un	POPC3
	bsta,un	PUSHC4
	eorz	r0
	stra,r0	TERMNM
SERI:
	bsta,un	DOUBLE
	bsta,un	GTERM
	bsta,un	FPSUB
FPSIN1:
	bsta,un	CGTERM
	retc,gt
	bsta,un	FPADD
	bsta,un	CGTERM
	retc,gt
	bsta,un	FPSUB
	bctr,un	FPSIN1
*
FPCOS:
	bsta,un	CTERM
	bsta,un	GSIGN
	bsta,un	POPC4
	bsta,un	PUSH1
	bctr,un	SERI
*
FPEXP2:
	bsta,un	CTERM
	bsta,un	POPC5
	bsta,un	PUSHC5
	bsta,un	PUSHC4
	bsta,un	FFABS
	bsta,un	ENS2
	iorz	r0
	bcfa,eq	OVFER
	stra,r1	ZTEMP2
	bsta,un	FPFRC
	bsta,un	POPC4
	bsta,un	PUSH1
FPEX1:
	loda,r1	ZTEMP2
	bctr,eq	FPEX2
	subi,r1	$01
	stra,r1	ZTEMP2
	bsta,un	PUSHF
	loda,r0	C5SIGN
	bctr,eq	FPEX5
	bsta,un	FPDIV
	bctr,un	FPEX1
*
FPEX5:
	bsta,un	FPMULT
	bctr,un	FPEX1
*
FPEX2:
	bsta,un	PUSH1
	bsta,un	GTERM
	bsta,un	FPADD
FPEX3:
	bsta,un	CGTERM
	bcfr,eq	FPEX4
	bsta,un	FPADD
	bctr,un	FPEX3
FPEX4:
	bcta,un	FPMULT
*
FPLOG:
	bsta,un	POPC1
	bsta,un	PUSHIG
	bsta,un	PUSHC1
	bsta,un	FPIN
	bcta,un	FPMULT
*
FPTAN:
	bsta,un	POPC5
	bsta,un	PUSHC5
	bsta,un	FPSIN
	bsta,un	PUSHC5
	bsta,un	FPCOS
	bcta,un	FPDIV
*
FPTSN:
	db	$00
*
FPATN:
	bsta,un	POPC4
	bsta,un	PUSHC4
	loda,r0	C4SIGN
	strr,r0	FPTSN
	bsta,un	FFABS
	bsta,un	POPC1
	bsta,un	PUSH1
	bsta,un	POPC2
	bsta,un	COMNUM
	comi,r3	$01
	bcfa,eq	ATN2
	lodi,r0	HI(HALFPI)
	lodi,r1	LO(HALFPI)
	bsta,un	PUSHFP
	bsta,un	PUSH1
	bsta,un	PUSHC1
	bsta,un	FPDIV
	eorz	r0
	bstr,un	APPROX
	bsta,un	FPSUB
FPTEND:
	bsta,un	POPC4
	lodr,r0	FPTSN
	stra,r0	C4SIGN
	bcta,un	PUSHC4
*
ATN2:
	bsta,un	PUSHC1
	eorz	r0
	bstr,un	APPROX
	bctr,un	FPTEND
*
AOFES:
	db	$00
APTEM:
	db	$00
*
APPROX:
	strr,r0	AOFES
	lodi,r1	$00
	strr,r1	APTEM
	bsta,un	POPC3
	bsta,un	PUSHC3
	bsta,un	POPC4
	bsta,un	PUSHC4
	lodr,r1	AOFES
	addi,r1	$45
	ppsl	$08
	eorz	r0
	addi,r0	$56
	cpsl	$08
	bsta,un	PUSHFP
	bsta,un	FPMULT
	bsta,un	POPC1
APP0:
	lodi,r1	$08
	addr,r1	APTEM
	comi,r1	$40
	bcta,eq	PUSHC1
	strr,r1	APTEM
	addr,r1	AOFES
	addi,r1	$45
	ppsl	$08
	eorz	r0
	addi,r0	$56
	cpsl	$08
	bsta,un	PUSHFP
	bsta,un	PUSHC4
	bsta,un	PUSHC3
	bsta,un	FPMULT
	loda,r0	AOFES
	comi,r0	$40
	bctr,eq	APP1
	bsta,un	PUSHC3
	bsta,un	FPMULT
APP1:
	bsta,un	POPC4
	bsta,un	PUSHC4
	bsta,un	FPMULT
	bsta,un	PUSHC1
	bsta,un	FPADD
	bsta,un	POPC2
	bsta,un	COMNUM
	lodz	r3
	bcta,eq	PUSHC2
	bsta,un	PUSHC2
	bsta,un	POPC1
	bcta,un	APP0
*
FPIN:
	bsta,un	CTERM
	bsta,un	POPC4
	loda,r0	C4SIGN
	bcta,lt	OVFER
	loda,r0	C4MAIN
	bcta,eq	OVFER
	lodi,r0	$80
	stra,r0	OFFSET
	bsta,un	PUSH0
	bsta,un	POPC5
	loda,r0	C4EX
	stra,r0	C5MAIN
	loda,r0	C4TEMP
	stra,r0	C5SIGN
	eorz	r0
	stra,r0	C4TEMP
	stra,r0	C5TEMP
	lodi,r0	$01
	stra,r0	C4EX
	lodi,r0	$02
	stra,r0	C5EX
	lodi,r0	HI(C5TEMP)
	lodi,r1	LO(C5TEMP)
	lodi,r2	$08
	ppsl	$08
	bsta,un	NORM
	lodi,r0	$02
	lpsl
	bsta,un	PUSHIN
	bsta,un	PUSHC5
	bsta,un	PUSH1
	bsta,un	FPSUB
	bsta,un	FPMULT
	bsta,un	PUSH0
	bsta,un	PUSHC4
LN2:
	bsta,un	POPC1
	bsta,un	PUSH1
	bsta,un	POPC2
	bsta,un	COMNUM
	comi,r3	$02
	bctr,eq	LN3
	bsta,un	PS2
	bsta,un	POPC2
	bsta,un	COMNUM
	comi,r3	$01
	bcfr,eq	LN4
	bsta,un	PUSH1
	bsta,un	FPADD
	bsta,un	PUSHC1
	bsta,un	PUSHH
	bsta,un	FPMULT
	bctr,un	LN2
*
LN3:
	bsta,un	PUSH1
	bsta,un	FPSUB
	bsta,un	PUSHC1
	bsta,un	PS2
*
LN31GG:
	db	$3F, $3B
*
LNGG:
	wrtd,r1
	bcta,un	LN2
*
LN4:
	lodi,r0	HI(LNN2)
	lodi,r1	LO(LNN2)
	bsta,un	PUSHFP
	bsta,un	FPMULT
	bsta,un	FPADD
	bsta,un	PUSHC1
	bsta,un	PUSH1
	bsta,un	FPSUB
	lodi,r0	$40
	bsta,un	APPROX
	bcta,un	FPADD
*

C3TEMP:
	db	$00
C3EX:
	db	$00
C3SIGN:
	db	$00
C3MAIN:
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
C4TEMP:
	db	$00
C4EX:
	db	$00
C4SIGN:
	db	$00
C4MAIN:
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
C5TEMP:
	db	$00
C5EX:
	db	$00
C5SIGN:
	db	$00
C5MAIN:
	db	$00
	db	$00
	db	$00
	db	$00
	db	$00
ZTEMP1:
	db	$00
ZTEMP2:
	db	$00
DUP:
	db	$00
OFFSET:
	db	$00
SSIGN:
	db	$00
TERMNM:
	db	$00
ATAB:
	dw	$0000,$0099,$9999,$3329
	dw	$0000,$F033,$3298,$5605
	dw	$0000,$0019,$9465,$3599
	dw	$0000,$F013,$9085,$3350
	dw	$F001,$0096,$4200,$4410
	dw	$F001,$F055,$9098,$8610
	dw	$F001,$0021,$8612,$2880
	dw	$F002,$F040,$5405,$8000
	
BTAB	dw	$0000,$0099,$9996,$4239
	dw	$0000,$F049,$9874,$1238
	dw	$0000,$0033,$1799,$0258
	dw	$0000,$F024,$0733,$8084
	dw	$0000,$0016,$7654,$0711
	dw	$F001,$F095,$3293,$8970
	dw	$F001,$0036,$0884,$9370
	dw	$F002,$F064,$5354,$4200
	
ETAB	dw	$0001,$0010,$0000,$0000
	dw	$0000,$0050,$0000,$0000
	dw	$0000,$0016,$6666,$6667
	dw	$F001,$0041,$6666,$6667
	db	$F0, $02, $00, $83,$33, $33, $33, $33
	db	$F0, $02, $00, $13,$88, $88, $88, $89
	db	$F0, $03, $00, $19,$84, $12, $69, $84
	db	$F0, $04, $00, $24,$80, $15, $87, $30
	db	$F0, $05, $00, $27,$55, $73, $19, $22
	db	$F0, $06, $00, $27,$55, $73, $19, $22
	db	$F0, $07, $00, $25,$05, $31, $08, $39
	db	$F0, $08, $00, $20,$87, $67, $56, $99
	db	$F0, $09, $00, $16,$05, $90, $43, $84
	db	$F0, $10, $00, $11,$47, $07, $45, $60
	db	$F0, $12, $00, $76,$47, $16, $37, $32
	db	$F0, $13, $00, $47,$49, $47, $73, $32
ETAB2:
ONE	dw	$0001,$0010,$0000,$0000 ;coefficients for function
HALF	dw	$0000,$0050,$0000,$0000 ;evaluation using polynomials ?
	dw	$0000,$0033,$3333,$3333
QTR	dw	$0000,$0025,$0000,$0000
	dw	$0000,$0020,$0000,$0000
	dw	$0000,$0016,$6666,$6667
	dw	$0000,$0014,$2857,$1429
	dw	$0000,$0012,$0500,$0000
	dw	$0000,$0011,$1111,$1111
	dw	$0000,$0010,$0000,$0000
	dw	$F001,$0090,$9090,$9091
	dw	$F001,$0083,$3333,$3333
	dw	$F001,$0076,$9230,$7692
	dw	$F001,$0071,$4285,$7143
	dw	$F001,$0066,$6666,$6667
	dw	$F001,$0062,$0500,$0000
	
LN10	dw	$0001,$0023,$0258,$5093
LOGC	dw	$0000,$0043,$4294,$4820
EEF	dw	$0001,$0027,$1828,$1828
FIE	dw	$0001,$0031,$4159,$2654
HALFPI	dw	$0001,$0015,$7079,$6327
LNN2	dw	$0000,$0069,$3147,$1805
TWO	dw	$0001,$0020,$0000,$0000

*	db	$00, $00, $00

	org 	$5800
X5800:
	db	$FF, $52, $49, $4E  ;RIN
	db	$54, $20, $22, $48  ;T "H
	db	$45, $4C, $4C, $4F  ;ELLO
X580C:
	db	$22, $0D, $46, $4F	;'FO
	db	$52, $20, $49, $20	;R I 
	db	$3D, $20, $31, $20  ;= 1 
	db	$54, $4F, $20, $37  ;TO 7
	db	$0D, $50, $52, $49
	db	$4E, $54, $20, $40
	db	$49, $2C, $33, $33
	db	$20, $22, $51, $57
	db	$45, $52, $54, $59
	db	$22, $0D, $4E, $45
	db	$58, $54, $0D
X5837:
	db	$45, $4E, $44, $0D
	db	$FF, $52, $53, $FF
	db	$44, $55, $50, $4C
	db	$49, $43, $41, $54
	db	$45, $20, $4C, $41
	db	$42, $4C, $45, $3A
	db	$20, $FF, $4F, $50
	db	$43, $4F, $44, $45
	db	$FF, $4C, $41, $42
	db	$4C, $45, $20, $55
	db	$53, $45, $44, $20
	db	$54, $57, $49, $43
	db	$45, $FF, $4F, $50
	db	$45, $52, $41, $4E
	db	$44, $FF, $52, $45
	db	$47, $49, $53, $54
	db	$45, $52, $20, $46
	db	$49, $45, $4C, $44
	db	$FF, $44, $49, $53
	db	$50, $4C, $41, $43
	db	$45, $4D, $45, $4E
	db	$54, $FF, $50, $41
	db	$47, $45, $49, $4E
	db	$47, $FF, $42, $49
	db	$4E, $41, $52, $59
	db	$20, $20, $4F, $55
	db	$54, $50, $55, $54
	db	$FF, $43, $4F, $4D
	db	$4D, $41, $4E, $44
	db	$3A, $20, $20, $FF
	db	$44, $41, $54, $41
	db	$20, $49, $4E, $50
	db	$55, $54, $FF, $20
	db	$4F, $4B, $FF, $05
	db	$09, $3F, $46, $C7
	db	$1F, $20, $4B, $00
	db	$0C, $99, $80, $3F
	db	$3A, $98, $C8, $77
	db	$07, $0A, $EF, $56
	db	$92, $18, $68, $5B
	db	$79, $C1, $C2, $44
	db	$03, $CC, $1A, $7E
	db	$51, $51, $01, $44
	db	$03, $C3, $CC, $19
	db	$7F, $51, $51, $01
	db	$45, $0E, $44, $01
	db	$9C, $39, $45, $E6
	db	$C0, $1C, $42, $13
	db	$E6, $40, $1C, $3B
	db	$9B, $0F, $76, $61
	db	$C3, $BF, $3A, $21
	db	$0F, $18, $C2, $47
	db	$E0, $67, $01, $C8
	db	$3A, $C9, $39, $CB
	db	$08, $0C, $1F, $06
	db	$93, $09, $31, $08
	db	$2E, $00, $C9, $2C
	db	$C8, $29, $13, $C8
	db	$28, $04, $02, $93
	db	$0C, $18, $C2, $44
	db	$FC, $E4, $C8, $18
	db	$09, $E4, $CC, $18
	db	$05, $0B, $16, $CF
	db	$1F, $06, $0F, $19
	db	$7F, $0F, $76, $65
	db	$C3, $08, $08, $09
	db	$07, $BF, $3A, $00
	db	$1F, $42, $13, $00
	db	$00, $00, $0F, $76
	db	$69, $C3, $BF, $3B
	db	$27, $0E, $18, $C2
	db	$0D, $1F, $06, $0C
	db	$1A, $7E, $F6, $40
	db	$1C, $39, $D7, $F4
	db	$03, $1C, $39, $84
	db	$50, $50, $21, $C1
	db	$D1, $61, $22, $1E
	db	$42, $13, $3F, $3B
	db	$0E, $0F, $18, $C2
	db	$F7, $20, $3C, $3A
	db	$B6, $08, $0C, $09
	db	$0B, $C8, $06, $C9
	db	$05, $1F, $42, $13
	db	$00, $00, $00, $00
	db	$00, $02, $9A, $62
	db	$08, $76, $E4, $02
	db	$18, $17, $3F, $3B
	db	$0E, $3F, $3A, $6D
	db	$C1, $20, $89, $6C
	db	$C9, $6A, $77, $08
	db	$88, $65, $C8, $63
	db	$75, $08, $1F, $39
	db	$6C, $09, $5B, $08
	db	$58, $C8, $2B, $C9
	db	$2A, $A5, $01, $77
	db	$08, $A6, $00, $75
	db	$08, $C8, $4A, $C9
	db	$49, $0A, $C6, $3F
	db	$3A, $98, $20, $CC
	db	$19, $80, $CC, $19
	db	$81, $02, $3F, $3B
	db	$2D, $08, $0B, $CC
	db	$19, $80, $08, $07
	db	$CC, $19, $81, $1F
	db	$39, $69, $00, $00
	db	$3F, $3A, $6D, $F6
	db	$80, $18, $07, $00
	db	$1C, $42, $13, $1F
	db	$39, $69, $F6, $20
	db	$18, $02, $84, $02
	db	$A4, $01, $3F, $3A
	db	$03, $00, $1C, $42
	db	$13, $3F, $3B, $0E
	db	$0C, $19, $82, $0D
	db	$19
*
	ORG $5a00
ZSET:
	lodi,r0	$02
	lpsl
	bsta,un	ERASE2
	lodi,r3	$00
	lodi,r0	$49
	stra,r0	*X5A69,r3,+
	lodi,r0	$7A
	stra,r0	*X5A69,r3,+
	lodi,r0	$FF
	lodi,r1	$58
	stra,r1	*X5A67
	stra,r1	ZTEMP
	stra,r0	*ZTEMP
	bsta,un	LFCR
	lodi,r3	$00
ZPRINT:
	loda,r0	ZTAB,r3
	bctr,lt	ZCON
	bsta,un	WRT
	birr,r3	ZPRINT
ZCON:
	bsta,un	PAUSE
	bsta,un	LTOU
	comi,r0	$4E
	bcta,eq	STRT
	comi,r0	$59
	bcfr,eq	ZCON
	lodi,r0	$FF
	stra,r0	*X5A65
	lodi,r1	$53
	stra,r1	ZTEMP
	stra,r0	*ZTEMP
	stra,r1	*X5A67
	lodi,r3	$FF
	lodi,r0	$1F
	stra,r0	*FPEX00,r3,+
	lodi,r0	$31
	stra,r0	*FPEX00,r3,+
	lodi,r0	$B1
	stra,r0	*FPEX00,r3,+
	bcta,un	STRT
	
	
ZTEMP:
	db	$58
	db	$00
FPEX00:
	dw	FPEXP
X5A65:
	dw	X4704
X5A67:
	dw	BUFFSTART
X5A69:
	dw	STRT
ZTAB:
	db	"DO YOU WISH TO DELETE THE EXTENDED FUNCTIONS? (Y/N)  "
L5AA0GG:
L5AA0:
	dw	$FFFF	
	
	
L1780:
	bcta,eq	PUSH0
	comi,r1	$09
	bcta,gt	PUSHC1
	bcta,un	FIX4
*
L178B:
	ppsl	$10
	lodr,r1	*X1794
	bsta,lt	LTOU
	strz	r1
	retc,un
*
X1794:
	dw	X4A59
*
L1796:
	ppsl	$08
	cpsl	$01
	rrl,r1
	retc,un
*
X179C:
	dw	PUSP
*
L179E:
	lodr,r0	*X179C
	comi,r0	$FF
	bctr,eq	L17AF
	bctr,un	L17AD
*
L17A6:
	lodi,r0	$20
	bsta,un	SENDIT
	subi,r1	$01
L17AD:
	brnr,r1	L17A6
L17AF:
	lodz	r3
	bcta,un	INCSP2
*
L17B3:
	lodi,r0	$00
	wrtd,r0
	retc,un
*
L17B7:
	bstr,un	L17B3
	lodi,r3	$49
	bcta,un	ERROR2
 
* 
L17C3:
      	lodi,r0 $24
        	lodi,r1 $FE
      	lodi,r2 $02
L17C9:
         	bdrr,r0 L17C9
         	bdrr,r1 L17C9
         	bdrr,r2 L17C9
         	retc,un
*
DISP:
	bstr,un	L17B3
	bcta,un	DISP
L17D0:
	lodi,r0 $08
	wrtd,r0
	retc,un
	
L17D4:
	bstr,un L17D0
	bcta,un AOK
*
L17D9:
	bstr,un L17D0
	bstr,un L17C3
	bcta,un AOK
*

	End