; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	Amiga E Compiler/Assembler/Linker by $#%! in 1991/92/93/94/95	;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;

S:	MOVE.L	A7,INITSTACK
	BSR	INITALL
	BSR	INITBUFFERS
	BSR	SETVARS
	BSR	MAKEKEYHASH
	BSR	MAKEASMHASH
	JSR	SETUPLIBS
	JSR	INITFUNCS
	JSR	ADDGLOBVARS
	BSR	GETCACHE
	BSR	CHECKCOOKIES
	BSR	TOKENIZE
	BSR	CHECKCOOKIES
	BSR	SECONDARYLOAD
	BSR	CHECKIDENTS
	BSR	SWAPVALUES
	JSR	MAKEINITCODE
	BSR	CHECKCOOKIES
	BSR	PASS1
	BSR	CHECKCOOKIES
	JSR	LINKDELEGATECONSTRUCTORS
	JSR	MAKEEXITCODE
	JSR	MATHEXITETC
	JSR	LINKFUNCS
	JSR	CALCADR
	BSR	WRITEEXE
	JSR	WRITELIBMOD
	BSR	CHECKCOOKIES
	BSR	NOERROR
	BSR	WRITEBUFFERS
	BSR	CLEANUPALL
	BSR	FIXRETVALUE
	RTS

K:	BSET	#6,CODEPREFS+3		; -w
	BRA	S

SC:	MOVE.L	#CLINE,A0
	MOVEQ	#CLEND-CLINE,D0
	BRA	S
CLINE:	DC.B	" ",10
CLEND:
	EVEN

EXAMPLE:
DC.B	" ",10

EXAMPLEEND:
DC.B	10,10

EVEN

DEMOVERS	= 0			; set to 1 for demo restrictions
DEMOSIZE	= 8765

UNDEF	= 0				; ident types
LOCV	= 1
GLOBV	= 2
LAB	= 3

EOI	= 0				; interimcodes
VALUE	= 1
LIBC	= 2
COM	= 3
ASSGN	= 4
IDENT	= 5
STR	= 6


ONEXT	= -4				; M O  OBJECT STRUCTURE OFFSETS
OOFF	= 0				; M
ODEL	= 0				;   O
OFLAGS	= 2				; M O
OSIZE	= 4				; M O
OID	= 6				; M O
OASCII	= 8				; M O
OPTRTYPE= 12				; M
OMEMB	= 12				;   O
OMETHOD	= 16				;   O
OSUPER	= 20				;   O
ODCODE	= 24				;   O
OACC	= 28				;   O
ODELOFF	= 32				;   O
ODESTR	= 34				;   O

M_NEXT	= 0				; METHOD
M_PROC	= 4
M_TYPE	= 8
M_FLAGS	= 9
M_OFF	= 10
M_NAME	= 12

MT_METHOD	= 0			; METHODFLAGS
MT_FROZEN	= 1
MT_SHARED	= 2
MT_EMPTY	= 3

MI_NEXT		= 0			; MODULEINFO
MI_FLAGS	= 4
MI_NAMELEN	= 6
MI_MOD		= 10
MI_LIST		= 14
MI_NAMEPTR	= 18
;MI_NAME	= 22			; ARRAY FROM HERE...

PC_NEXT		= 0			; PROC_OR_CLASS
PC_TYPE		= 4
PC_INFO		= 6
PC_ACC		= 10

CNEXT	= 0				; CONST STRUCTURE OFFSETS
CASCII	= 4
CVAL	= 8
CFLAGS	= 12

CURVERSION	= 10			; IMPORTANT, MODULE VERSION!!

SKIPMARK	= $8000

MAXREGVARS	= 5			; NOTE: DEPENDS ALSO ON EFUNCS!
MAXMULTRET	= 3			; NOTE: DEPENDS ON REGVARS!
MIDHEAVY	= $100
VARHEAVY	= 12			; OFFSET AT WHICH HEAVYINFOS IN ID

MINSTACKSIZE	= 10000			; van gen. code
MINSTACKSIZELIB	= 1500
MAXOBJSIZE	= 5000

CHOPMEM		= -100
CHOPLEFT	= -104
FMEMSIZE	= 5000

GLOBOFF		= -512
GLOBOFFNEWTAB	= GLOBOFF+16		; 16..256+16
NEWTABMAX	= 256

IOFF		= 100
KB		= 1024
MAXIDENT	= 1000			; size of *one* identifier
MAXSTACK	= 30000			; each rec.step=6-10b+rec.databuffer
MAXLIBRAISE	= 200			; EACH = 10 BYTES

MINIMUM_ACODE	= 100*KB		; GENERATED CODE-BUF

; MACRO SECTION

TSTMOD:	MACRO
	BTST	#4,CODEPREFS+2
	ENDM

; RANGE CHECK MACROS

CHKB:	MACRO				; \1=REG, \2=TRREG, \3=ERLAB
	MOVE.L	\1,\2
	BTST	#31,\2
	BEQ.S	*+4
	NEG.L	\2			; BAD: RANGE=(-255,255)=>(-128,255)
	AND.L	#$FFFFFF00,\2
	TST.L	\2
	BNE	\3
	ENDM

CHKW:	MACRO				; \1=REG, \2=TRREG, \3=ERLAB
	MOVE.L	\1,\2
	BTST	#31,\2
	BEQ.S	*+4
	NEG.L	\2
	AND.L	#$FFFF0000,\2
	TST.L	\2
	BNE	\3
	ENDM

; HASHING MACROS

HASHC:	MACRO				; \1=HASHREG, \2=CHAR
	LSL.W	#4,\1
	ADD.B	\2,\1
	ENDM

HASHE:	MACRO				; \1=HASHREG
	DIVU	#211,\1
	SWAP	\1
	EXT.L	\1
	ENDM

HASH:	MACRO				; \1=ASCREG, \2=DATREG, \3=TRASHREG
	MOVEQ	#0,\2
.H1:	MOVE.B	(\1)+,\3
	BEQ.S	.H2
	HASHC	\2,\3
	BRA.S	.H1
.H2:	HASHE	\2
	ENDM



; APART VAR ACCESS: ASM_GETLABEL

; GEN GLOB INFO: A4=MID INS.

GENGI:	MACRO				; \1=IDENTREC, \2=TRASHDX
	MOVE.L	6(\1),\2		; SEE IF WE HAVE TO ADD A GLOBINFO ENTRY
	BEQ.S	.GVNGI
	MOVEM.L	\1/A3,-(A7)
	MOVE.L	\2,\1
	MOVE.L	4(\1),\2
	MOVE.L	\1,A3
	GETM	\1
	MOVE.L	\1,4(A3)
	MOVE.L	\2,(\1)+
	MOVE.L	A4,(\1)+
	MOVE.W	OPERSIZE(PC),(\1)+
	DONEM	\1
	MOVEM.L	(A7)+,\1/A3
.GVNGI:
	ENDM

OPLONG:	MACRO
	MOVE.W	#4,OPERSIZE
	ENDM

OPINT:	MACRO
	MOVE.W	#2,OPERSIZE
	ENDM

OPCHAR:	MACRO
	MOVE.W	#1,OPERSIZE
	ENDM
	

; OFF_1:IMM, IDENT_2:Ax, OFFSET_3:EA.W, THRASH_4:Dx
             ; NOT A3-A5!!

GENVAR:	MACRO		
	MOVE.B	4(\2),\4
	BEQ	ERROR22			; TEST FOR UNIDENT
	CMP.B	#GLOBV,\4
	BNE.S	.GV1
	MOVE.W	-2(A4),\4
	BCLR	#\1,\4			; ADJUSTMODE
	MOVE.W	\4,-2(A4)

	GENGI	\2,\4

.GV1:	BTST	#3,5(\2)		; SEE IF REGVAR
	BNE.S	.GV2
	MOVE.W	\3,(A4)+
	BRA.S	.GV3
.GV2:	MOVE.W	10(\2),\4
	IF \1=0
	 ANDI.W	#%1111111111000000,-2(A4)
	ELSE
	 AND.W	#%1111000000111111,-2(A4)
	 LSL.W	#8,\4
	 LSL.W	#1,\4
	ENDIF
	OR.W	\4,-2(A4)
.GV3:					; END
	ENDM


	MOVEMS:		MOVEM.L	D0/D1,-(A7)
	MOVEMR:		MOVEM.L	(A7)+,D0/D1
	SMASK:		DC.W	0

BITM:	MACRO				; \1=BITNUM, \2=REG
	BTST	#\1,\2
	BEQ.S	.SR\1
	BSET	#15-\1,\2
.SR\1:
	ENDM

LSAVER:	MACRO				; \1=SAVEMASK.EA.W, \2=RETURN_SMASK.DX
	MOVE.W	\1,\2
	AND.W	#%11111000,\2		; diffr. from SAVER
	MOVE.W	\2,SMASK
	BEQ.S	.NOSR
	MOVE.W	MOVEMS,(A4)+
	BITM	7,\2
	BITM	6,\2
	BITM	5,\2
	BITM	4,\2
	BITM	3,\2
	CLR.B	\2
	MOVE.W	\2,(A4)+
	MOVE.W	SMASK,\2
.NOSR:					; \2 IS HERE ATLEAST BOOL
	ENDM

SAVER:	MACRO				; \1=SAVEMASK.EA.W, \2=RETURN_SMASK.DX
	MOVE.W	\1,\2
	AND.W	PROCMASK,\2
	MOVE.W	\2,SMASK
	BEQ.S	.NOSR
	MOVE.W	MOVEMS,(A4)+
	BITM	7,\2
	BITM	6,\2
	BITM	5,\2
	BITM	4,\2
	BITM	3,\2
	CLR.B	\2
	MOVE.W	\2,(A4)+
	MOVE.W	SMASK,\2
.NOSR:					; \2 IS HERE ATLEAST BOOL
	ENDM

RESTR:	MACRO				; \1=SMASK.EA
	TST.W	\1
	BEQ.S	.NORR
	MOVE.W	MOVEMR,(A4)+
	MOVE.W	\1,(A4)+
.NORR:
	ENDM

LOWER:	MACRO				; \1=AX (STRING,TRASH), \2=(TRASH)
.LOWL:	MOVE.B	(\1),\2
	BEQ.S	.LOWO
	CMP.B	#"A",\2
	BMI.S	.LOWN
	CMP.B	#"Z"+1,\2
	BPL.S	.LOWN
	ADD.B	#32,\2
.LOWN:	MOVE.B	\2,(\1)+
	BRA.S	.LOWL
.LOWO:					; ax points at 0-byte at end string
	ENDM

; FAST MEMORY ALLOCATION MACROS
	
GETM:	MACRO				; \1=Ax (START USING MEM)
	MOVE.L	HEAP(PC),\1
	ENDM

DONEM:	MACRO				; \1=Ax (DONE WITH MEM (LIGHT VERSION))
	MOVE.L	\1,HEAP
	SUBQ.W	#1,CHECKHEAP
	BNE.S	*+16
	JSR	EXPAND5
	MOVE.W	#5,CHECKHEAP		; MAX 200 BYTES EACH = IDENT OR STRUCT
	ENDM				; doesn't trash \1 !!!!

DONEH:	MACRO				; \1=Ax (HEAVY VERSION)
	MOVE.L	\1,HEAP
	JSR	EXPAND5
	ENDM


; CREATE GLOBINFO STRUCTURE FOR IDENT

GINFO:	MACRO				; \1=ASCIIPTR.EA, \2=TRASH.AX, \3=IDENTPTR.AX
	TSTMOD
	BEQ.S	.NGINF
	GETM	\2			; BUILD "GLOBINFO"
	BTST	#1,5(\3)
	BNE.S	.NGINF
	MOVE.L	\2,6(\3)
	MOVE.L	\1,(\2)+
	CLR.L	(\2)+
	DONEM	\2
	BRA.S	.NGOUT
.NGINF:	CLR.L	6(\3)
.NGOUT:
	ENDM

CHESTB:	MACRO				; CHeckEStackBuf \1=CURBUF.EA, \2=TR.DX
	SUBQ.W	#1,.BC			; \3=DIST, \4=ERROR
	BNE.S	.NC
	MOVE.W	#\3,.BC
	MOVE.L	#ESTACKBUF,\2
	ADD.L	#MAXSTACK,\2
	SUB.L	#1000,\2
	CMP.L	\1,\2
	BMI	\4
	BRA.S	.NC
.BC:	DC.W	\3
.NC:
	ENDM

INTERN:	MACRO				; \1=ERRNUM
	MOVE.W	#\1,GURUNUM
	JMP	DAMAGEDCOOKIES
	ENDM


;;PREP

; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	;
;	The (Macro) PreProcessor				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,	;

; - recursive macros
; - check end_of_source at each "\n" skipped.

MAC_NEXT	= 0
MAC_NAME	= 4
MAC_BODY	= 8
MAC_NARGS	= 12
MAC_FLAGS	= 14	; .B


      PREPCHARS:
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0	; 0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0	; 16
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0	; 32
	DC.B	4,4,4,4,4,4,4,4, 4,4,0,0,0,0,0,0	; 48

	DC.B	0,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5	; 64
	DC.B	5,5,5,5,5,5,5,5, 5,5,5,0,0,0,0,5	; 80
	DC.B	0,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5	; 96
	DC.B	5,5,5,5,5,5,5,5, 5,5,5,0,0,0,0,0

	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0	; 128
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0

	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
	DC.B	0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0


; IN TOKENIZE CONTEXT: A0=SOURCE, A1=INTERIM, A2=IDENT WORK, D4=LAST TOKEN

PREPTA:	MACRO				; \1=AX
	LEA	PREPCHARS(PC),\1
	ENDM

PREPID:	MACRO				; \1=TAB.AX, \2=CHAR.L.DX
	CMP.B	#5,0(\1,\2.L)
	ENDM

PREPIDR:MACRO				; \1=TAB.AX, \2=CHAR.L.DX
	CMP.B	#4,0(\1,\2.L)
	ENDM

      PREP:				; JUST READ A "#"
	ADDQ.L	#1,A0
	CMP.B	#"d",D6
	BEQ.S	PREPDEF
	CMP.B	#"i",D6
	BEQ.W	PREPIF
	CMP.B	#"e",D6
	BEQ.W	PREPENDIF
	BRA	ERROR63

; format:
; 32-255: normal chars
; "\t" and "\\\n" translated to " "
; "\n" is end of macro (0)
; chars 1-31 are args.
; ";" not allowed


      PREPDEF:				; #define
	LEA	.1(PC),A6
	BSR	PREPKCMP
	BSR	PREPWHITE
	GETM	A5			; A5=MEM
	MOVE.L	A5,A4			; A4=IDENT
	PREPTA	A6			; A6=TABLE
	MOVEQ	#0,D0
	MOVE.B	(A0)+,D0		; D0=CHAR
	MOVEQ	#0,D1			; D1=HASH
	PREPID	A6,D0
	BMI	ERROR64
.L:	HASHC	D1,D0
	MOVE.B	D0,(A5)+
	MOVE.B	(A0)+,D0
	PREPIDR	A6,D0
	BPL.S	.L
	SUBQ.L	#1,A0
	CLR.B	(A5)+
	MOVE.L	A5,D0
	BTST	#0,D0
	BEQ.S	.2
	CLR.B	(A5)+
.2:	HASHE	D1
	LSL.L	#2,D1
	ADD.L	#MACROHASH,D1
	MOVE.L	D1,A6
	BSR	PREPFINDMACRO
	TST.L	D0
	BNE	ERROR66
	MOVE.L	D1,A6
	MOVE.L	(A6),(A5)		; MAC_NEXT
	MOVE.L	A5,(A6)
	MOVE.L	A5,A6			; A6=MACOBJ
	ADDQ.L	#4,A5
	MOVE.L	A4,(A5)+		; MAC_NAME
	CLR.L	(A5)+			; MAC_BODY
	CLR.L	(A5)+			; MAC_NARGS + MAC_FLAGS
	DONEH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MP
	MOVE.W	PREPSTACKSIZE(PC),D0
	SUBQ.W	#1,D0
	BMI	ERROR65
	MOVE.W	D0,PREPSTACKSIZE
	;LEA	PREPIFSTACK(PC),A4
	;TST.B	0(A4,D0.W)
	;BEQ	ERROR65
	BRA.S	PREPDONE
.1:	DC.B	"ndif",0,0

      PREPDONE:
	MOVE.L	STARTINTERIM(PC),A6
	SUBQ.L	#2,A6
	CMPA.L	A6,A1
	BNE.S	.1
	MOVE.L	WORK(PC),A2
	BRA	PARSELOOP
.1:	INTERN	105

      PREPKCMP:
	CMPM.B	(A6)+,(A0)+
	BEQ.S	PREPKCMP
	TST.B	-(A6)
	BNE	ERROR63
	MOVE.B	-(A0),D6
	CMP.B	#" ",D6
	BEQ.S	.1
	CMP.B	#10,D6
	BEQ.S	.1
	CMP.B	#9,D6
	BNE	ERROR63
.1:	RTS

      PREPWHITE:				; TR ONLY D0.B
	MOVE.B	(A0),D0
	CMP.B	#" ",D0
	BEQ.S	.1
	CMP.B	#9,D0
	BNE.S	.2
.1:	ADDQ.L	#1,A0
	BRA.S	PREPWHITE
.2:	RTS

      PREPFINDMACRO:				; A6=LISTADR,A4=STR, OUT=D0/A6
	MOVEM.L	A0/A1,-(A7)
.L:	MOVE.L	(A6),D0
	BEQ.S	.1
	MOVE.L	D0,A6
	MOVE.L	MAC_NAME(A6),A0
	MOVE.L	A4,A1
.CL:	CMPM.B	(A0)+,(A1)+
	BNE.S	.L
	TST.B	-1(A0)
	BNE.S	.CL
.1:	MOVEM.L	(A7)+,A0/A1
	RTS

      PREPEXPAND:
	MOVE.L	WORK(PC),A4
	MOVE.L	HASHVAL(PC),D0
	LSL.L	#2,D0
	ADD.L	#MACROHASH,D0
	MOVE.L	D0,A6
	BSR	PREPFINDMACRO			; A6=MACOBJ
	TST.L	D0
	BNE.S	.C
	RTS

.C:	MOVEM.L	D1-D7/A1-A6,-(A7)		; KEEP ONLY A0,A6 FROM ENV

	TST.L	PREPESTACK
	BNE.S	.1
	MOVE.L	#PREPETOTAL,D0
	BSR	NEW
	TST.L	D0
	BEQ	ERROR38
	MOVE.L	D0,PREPESTACK
	ADD.L	#PREPESTACKSIZE,D0
	MOVE.L	D0,PREPEBUFUSE
	ADD.L	#PREPEBUFSIZE,D0
	MOVE.L	D0,PREPEBUFEND
.1:
	MOVE.L	PREPEBUFUSE(PC),PREPETEMP
	MOVE.W	MAC_NARGS(A6),D7		; D7.W=NARGS
	BEQ.S	.NARG
	BSR	PREPWHITE
	BSR	PREPMULTIEXPAND
	BRA.S	.INAC

.NARG:	MOVE.L	MAC_BODY(A6),D6			; D6=NEW ASCCODE
.INAC:	MOVE.W	PREPESTACKUSE(PC),D0
	CMP.W	#PREPESTACKSIZE,D0
	BPL	ERROR68
	MOVE.L	PREPESTACK(PC),A5		; A5=MACEXPANSIONSTACK
	MOVE.L	A0,0(A5,D0.W)
	MOVE.L	PREPETEMP(PC),4(A5,D0.W)
	ADDQ.W	#8,PREPESTACKUSE
	MOVE.L	D6,A0
	MOVEM.L	(A7)+,D1-D7/A1-A6
	ADDQ.L	#4,A7				; BSR OFF STACK
	BSR	MOVEBUF				; FOR LONG MACROS
	BRA	PARSELOOP


PREPESTACKSIZE	= 20*8
PREPEBUFSIZE	= 10*KB
PREPETOTAL	= PREPESTACKSIZE+PREPEBUFSIZE

; EACH STACKFRAME: LASTA0,LASTEBUF


      PREPESTACK:	DC.L	0
      PREPESTACKUSE:	DC.W	0

      PREPETEMP:	DC.L	0
      PREPEBUFEND:	DC.L	0
      PREPEBUFUSE:	DC.L	0

      PREPMACRODONE:
	MOVE.W	PREPESTACKUSE(PC),D0
	BEQ	E
	BMI	E
	SUBQ.W	#8,D0
	MOVE.L	PREPESTACK(PC),A6
	MOVE.L	0(A6,D0.W),A0
	MOVE.L	4(A6,D0.W),PREPEBUFUSE
	MOVE.W	D0,PREPESTACKUSE
	BRA	PARSELOOP

      PREPWRITEMACROLINE:
	MOVE.L	PREPMACROBODYERR(PC),D7
	BEQ.S	.1
	MOVE.L	#PREPMACROMSG,D2
	MOVEQ	#7,D3
	BSR	WRITECON
	MOVE.L	D7,A0
	MOVE.L	D7,A1
.L:	CMP.B	#10,-1(A0)
	BEQ.S	.L2
	CMP.B	#";",-1(A0)
	BEQ.S	.L2
	TST.B	-1(A0)
	BPL.S	.KLUD
.B:	SUBQ.L	#1,A0
	BRA.S	.L
.L2:	CMP.B	#10,(A1)
	BEQ.S	.D
	CMP.B	#";",(A1)
	BEQ.S	.D
	TST.B	(A1)
	BEQ.S	.D
	ADDQ.L	#1,A1
	BRA.S	.L2
.D:	CLR.B	(A1)
	MOVE.L	A1,D3
	MOVE.L	A0,D2
	SUB.L	D2,D3
	BSR	WRITECON
	BSR	WRITELN
.1:	RTS
.KLUD:	CMP.B	#8,-1(A0)		; MACBODY FROM MOD HAS LEN:INT,CHARS..
	BPL.S	.B
	;ADDQ.L	#1,A0			; why?
	BRA.S	.L2

      PREPMACROMSG:	DC.B	'MACRO: ',0		; 7

      PREPMACROBODYERR:	DC.L	0

      PREPMACROERROR:
	TST.W	PREPESTACKUSE
	BEQ.S	.1
	MOVE.L	A0,PREPMACROBODYERR
	MOVE.L	PREPESTACK(PC),A0		; OLDEST A0 BACK
	MOVE.L	(A0),A0
.1:	RTS


; IN:	A0=ASCII, A6=MACOBJ, D7.W=NARGS
; FILLS PREPBUFUSE++ TO MAX PREFBUFEND
; RET NEW ASCII IN D6


; PROBLEMS: <CONS>


      PREPMULTIEXPAND:
	MOVE.L	PREPEBUFUSE(PC),A5	; A5=CURBUF
	MOVE.W	D7,D0
	LSL.W	#3,D0
	MOVE.L	A5,A4			; A4,D4=ARGSBUF
	MOVE.L	A4,D4
	ADD.W	D0,A5
	CMPA.L	PREPEBUFEND(PC),A5
	BPL	ERROR37
	MOVE.L	A5,D6			; D6=BEGIN
	CMP.B	#"(",(A0)+
	BNE	ERROR0
	MOVEQ	#0,D5			; D5=BRACKET RECURSION
.BL:	MOVE.L	A0,(A4)+		; SHOVE ADR FOR ARG
.L:	MOV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.1:	DC.B	"intermediate code",0
.3:	DC.B	"libraries/generated code",0
.5:	DC.B	"general/identifier",0
.6:	DC.B	"label",0
	EVEN

      DEBUGDATA:
	DC.L	OLIST
	DC.L	PROCLIST
	DC.L	IDENTHASH
      DBUGV:
	DC.L	0
      DBUGA:
	DC.L	0
	DC.L	MODINFOLIST
	DC.L	CODELIST
	DC.L	MEMLIST
	DC.L	HEAP
	DC.L	MACROHASH

      INITBUFFERS:
	MOVE.W	#1,CURSPOT
	MOVE.L	EBUFSIZE(PC),D0
	LSR.L	#1,D0			; *1.5+50k
	ADD.L	EBUFSIZE(PC),D0
	ADD.L	BUFADD(PC),D0
	MOVE.L	D0,CURACODE+20
	BSR	REALLOC1
	BSR	ALLOC3
	BSR	ALLOC5
	BSR	REALLOC6
	MOVE.L	HEAP+20(PC),GENERALSIZE
	RTS

      REALLOC1:
	MOVEM.L	D6/A5,-(A7)
	LEA	CURINTERIM(PC),A5
	BSR	REALLOC
	MOVEM.L	(A7)+,D6/A5
	RTS

      ALLOC3:
	MOVEM.L	D6/A5,-(A7)
	LEA	CURACODE(PC),A5
	BSR	REALLOC
	MOVEM.L	(A7)+,D6/A5
	RTS

      CHECK3:
	MOVEM.L	D6/A5,-(A7)
	LEA	CURACODE(PC),A5
	BSR	CHECK
	MOVEM.L	(A7)+,D6/A5
	RTS

      ALLOC5:
	MOVEM.L	D6/A5,-(A7)
	LEA	HEAP(PC),A5
	BSR	REALLOC
	MOVEM.L	(A7)+,D6/A5
	RTS

      EXPAND5:
	MOVEM.L	D6/A5,-(A7)
	LEA	HEAP(PC),A5
	BSR	EXPANDBUF
	MOVEM.L	(A7)+,D6/A5
	RTS

      REALLOC6:
	MOVEM.L	D6/A5,-(A7)
	LEA	LABM(PC),A5
	BSR	REALLOC
	MOVEM.L	(A7)+,D6/A5
	RTS

COOKIE	= $BE

      NEW:
	MOVEM.L	D1/D2/A0/A1/A6,-(A7)	; SIZE-->D0-->ADDR
	ADDQ.L	#8,D0
	ADDQ.L	#1,D0
	MOVE.L	D0,D2
	MOVEQ	#0,D1
	MOVE.L	4.W,A6
	JSR	-198(A6)
	TST.L	D0
	BEQ.S	.EXX
	MOVE.L	D0,A0
	ADDQ.L	#8,D0
	MOVE.B	#COOKIE,-1(A0,D2.L)
	MOVE.L	MEMLIST(PC),(A0)
	MOVE.L	D2,4(A0)
	MOVE.L	A0,MEMLIST
.EXX:	MOVEM.L	(A7)+,D1/D2/A0/A1/A6
	RTS

      MEMLIST:	DC.L	0

      DISPOSE:				; ADR-->D0
	MOVEM.L	D0/D1/A0/A1/A2/A6,-(A7)
	TST.L	D0
	BEQ.S	.1
	SUBQ.L	#8,D0
	LEA	MEMLIST(PC),A1
.L:	MOVE.L	(A1),D1
	BEQ.S	.1
	MOVE.L	A1,A2			; ADR TO LINK BACK TO
	MOVE.L	D1,A1
	CMP.L	D1,D0
	BNE.S	.L
	MOVE.L	4(A1),D0		; MEMSIZE
	MOVE.L	(A1),(A2)		; LINK BACK
	MOVE.L	4.W,A6
	JSR	-210(A6)
.1:	MOVEM.L	(A7)+,D0/D1/A0/A1/A2/A6
	RTS


      REALLOC:				; CALLED FROM EVERYWHERE
	MOVE.L	8(A5),D6
	ADD.L	12(A5),D6
	SUB.L	16(A5),D6
	CMP.L	(A5),D6
	BMI.S	.1
	RTS
.1:	MOVEM.L	D0/D1/D7/A0/A1/A6,-(A7)
	MOVE.L	12(A5),D0
	ADD.L	20(A5),D0		; NEW SIZE
	MOVE.L	D0,D6			; D6=SIZE
	BSR	NEW
	TST.L	D0
	BEQ.S	.ER
	MOVE.L	D0,D7			; D7=ADR
	TST.L	12(A5)
	BEQ.S	.2			; NO COPYING/FREEMEM
	MOVE.L	D7,A1
	MOVE.L	8(A5),A0
	MOVE.L	12(A5),D0
	MOVE.L	4.W,A6
	JSR	-630(A6)		; COPYMEMQUICK
	MOVE.L	8(A5),D0
	BSR	DISPOSE
.2:	TST.L	(A5)			; NEW SETTINGS
	BNE.S	.3
	MOVE.L	D7,(A5)
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INEBUF

	IF	DEMOVERS=1

	JSR	DOCHECKSUM

	ENDIF

	RTS

      GETLINEBUF:
	BTST	#5,CODEPREFS+1
	BEQ.S	.1
	MOVEQ	#0,D0
	MOVE.W	MAXLINENUM(PC),D0
	LSL.L	#3,D0
	ADD.L	#1000,D0
	BSR	NEW
	TST.L	D0
	BEQ	ERROR38
	MOVE.L	D0,LINEBUF
	MOVE.L	D0,A0
	MOVE.L	#$3F1,(A0)+		; HUNKID
	CLR.L	(A0)+			; HUNKLEN, _LATER_.
	CLR.L	(A0)+			; ADD2HUNK=0
	MOVE.L	#"LINE",(A0)+
	ADDQ.L	#4,A0
	MOVE.L	A0,A2
	MOVE.L	#NAMEBUF,A1
.L:	MOVE.B	(A1)+,(A0)+
	BNE.S	.L
	MOVE.B	#".",-1(A0)
	MOVE.B	#"e",(A0)+
	CLR.B	(A0)+
	CLR.B	(A0)+
	CLR.B	(A0)+
	MOVE.L	A0,D0
	SUB.L	A2,D0
	LSR.L	#2,D0
	MOVE.L	D0,-4(A2)
	LSL.L	#2,D0
	LEA	0(A2,D0.L),A0
	MOVE.L	A0,LINEBUFCUR
	MOVE.L	A0,LINEBUFCURSTART	; IF THE SAME LATER, DON'T SAVE
.1:	RTS

      ADDLINEDBG:
	TST.W	PROCF
	BEQ.S	.1
	MOVEM.L	D0/A0,-(A7)
	MOVE.L	LINEBUFCUR(PC),A0
	MOVEQ	#0,D0
	MOVE.W	LINENUM(PC),D0
	ADDQ.L	#1,D0
	MOVE.L	D0,(A0)+
	MOVE.L	A4,D0
	SUB.L	ACODE(PC),D0
	MOVE.L	D0,(A0)+
	MOVE.L	A0,LINEBUFCUR
	BTST	#6,CODEPREFS+1
	BEQ.S	.3
	MOVE.W	.2(PC),(A4)+		; ADD A NOP
.3:	MOVEM.L	(A7)+,D0/A0
.1:	RTS
.2:	NOP

      DEBUGLIST:	DC.L	0
      MAXLINENUM:	DC.W	0
      LINEBUF:		DC.L	0
      LINEBUFCUR:	DC.L	0
      LINEBUFCURSTART:	DC.L	0

      SETVARS:
	MOVE.L	#BRACKETSBUF,CURBRACK
	MOVE.L	#HASHBUFS,A0		; CLEAR HASHTABLES
	MOVE.L	#ENDHASHBUFS,D0
	SUB.L	A0,D0
	LSR.L	#2,D0
	SUBQ.L	#1,D0
	MOVEQ	#0,D1
.CLR:	MOVE.L	D1,(A0)+
	DBRA	D0,.CLR
	MOVE.L	DIRNAMEX(PC),A1		; STD MODULE PATH
	LEA	STDDIR(PC),A0
.1:	MOVE.B	(A0)+,(A1)+
	BNE.S	.1
	MOVE.W	#-1,KILLFLAG		; FROM NOW, DELETE IF PROBLEMS
	LEA	SELFNAME(PC),A0
	HASH	A0,D0,D1
	LSL.L	#2,D0
	ADD.L	#IDENTHASH,D0
	MOVE.L	D0,SELFHASHADR
	RTS

      STDDIR:
	DC.B	'emodules:',0


;;PARSE

; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	;
;	The Parsing Routines					;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,	;

	LEXMESSY:	DC.B	'lexical analysing ...',10
	ENDLEXMESSY:	EVEN

      TOKENIZE:
	MOVE.W	#-1,EXPORTFLAG
	BTST	#6,CODEPREFS+2		; SEE IF EXPORT ALL
	BNE.S	.EA
	CLR.W	EXPORTFLAG
.EA:	MOVE.W	#2,CURSPOT
	BTST	#7,CODEPREFS+2
	BNE.S	.11
	MOVE.L	#LEXMESSY,D2
	MOVEQ	#ENDLEXMESSY-LEXMESSY,D3
	BSR	WRITECON
.11:	CLR.W	LINENUM
	CLR.L	CONSTD
	MOVE.W	#1,ERRWHERE
.2:	MOVE.L	CURECODE(PC),A0
	CMP.L	ENDECODE(PC),A0
	BPL.S	.1
	BSR	PARSELINE
	BRA.S	.2
.1:	TST.W	PREPSTACKSIZE
	BNE	ERROR65
	MOVE.W	LINENUM(PC),MAXLINENUM
	MOVE.L	CURINTERIM(PC),A1
	MOVE.L	A1,TOKENEND
	MOVE.L	#-1,(A1)+
	MOVE.W	#-1,LINENUM
	MOVE.W	#0,ERRWHERE
	CLR.W	LINENUM2
	RTS

      PARSELINE:
	BSR	REALLOC1
	BSR	WRITELINENUM
	MOVE.W	#-1,CURINS
	MOVE.L	CURECODE(PC),A0
	MOVE.L	CURINTERIM(PC),A1
	MOVE.W	#21,(A1)+
	MOVE.W	LINENUM2(PC),(A1)+
	LEA	2(A1),A2
	MOVE.L	A2,STARTINTERIM
	MOVE.L	WORK(PC),A2
	MOVEQ	#0,D0
	MOVE.W	D0,PARSEBRACKET
	MOVE.W	D0,XF
	MOVEQ	#0,D4
	MOVE.W	#-1,CURINS
      PARSELOOP:
	MOVEQ	#0,D7
	MOVE.B	(A0)+,D7		; CURRENT CHAR
	MOVE.B	(A0),D6			; NEXT CHAR; WE CAN LOOK AHEAD ! YEAH !
	MOVE.W	D7,D5
	LSL.W	#2,D5
	MOVE.L	JUMPTAB(PC,D5.W),A4
	JMP	(A4)

      JUMPTAB:
	DC.L	PREPMACRODONE,E,E,E,E,E,E,E			; 0
	DC.L	E,PARSELOOP,PARSEENDLINE,E,PARSELOOP,E,E,E	; 8
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 16
	DC.L	PARSELOOP,PARSEFLT,PARSELONGSTR,ASM_PARSEIMM	; 32
	DC.L	PARSEHEXNUM,PARSEBINNUM,E,PARSESTRING		; 36
	DC.L	PARSEOPEN,PARSECLOSE,PARSEPROD,PARSEPLUS	; 40
	DC.L	PARSECOMMA,PARSEMINUS,PARSEPERIOD,PARSEDIV	; 44
	DC.L	VAL,VAL,VAL,VAL,VAL,VAL,VAL,VAL			; 48
	DC.L	VAL,VAL,PARSEBECOMES,PARSEENDLINE		; 56
	DC.L	PARSESMALLER,PARSEEQ,PARSEBIGGER,E		; 60
	DC.L	E,ID,ID,ID,ID,ID,ID,ID				; 64
	DC.L	ID,ID,ID,ID,ID,ID,ID,ID				; 72
	DC.L	ID,ID,ID,ID,ID,ID,ID,ID				; 80
	DC.L	ID,ID,ID,PARSESQ1,E,PARSESQ2,PARSEPTR,ID	; 88
	DC.L	PARSEQUOTE,ID,ID,ID,ID,ID,ID,ID			; 96
	DC.L	ID,ID,ID,ID,ID,ID,ID,ID				; 104
	DC.L	ID,ID,ID,ID,ID,ID,ID,ID				; 112
	DC.L	ID,ID,ID,PARSECURL1,PARSECONS,PARSECURL2,E,E	; 120
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 128
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 144
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 160
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 176
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 192
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 208
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 224
	DC.L	E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E			; 240

E: BRA ERROR3

      PARSECOMMA:			; ,
	MOVEQ	#COM,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEPLUS:			; + ++
	CMP.B	#'+',D6
	BEQ.S	.1
	MOVEQ	#7,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.1:	ADDQ.L	#1,A0
	MOVEQ	#33,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEMINUS:			; - --
	CMP.B	#'-',D6
	BEQ.S	.1
	CMP.B	#'>',D6
	BEQ.S	.2
	MOVEQ	#8,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.1:	ADDQ.L	#1,A0
	MOVEQ	#34,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.2:	MOVEQ	#10,D0
.L:	CMP.B	(A0)+,D0
	BNE.S	.L
	SUBQ.L	#1,A0
	BRA	PARSELOOP

      PARSEPROD:			; /
	CMP.B	#'/',D6
	BEQ	ERROR27
	MOVEQ	#9,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEDIV:				; *
	CMP.B	#'*',D6
	BEQ.S	COMMENT
	MOVEQ	#10,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      COMMENT:				; /* */
	MOVE.L	A0,A3			; BACKUP
	MOVE.L	LINENUM(PC),A4		; BACKUPTOO
	MOVEQ	#1,D0			; COUNTING COMMENTS
	MOVEQ	#'/',D1
	MOVEQ	#'*',D2
	MOVE.L	ENDECODE(PC),D3
	CMP.L	D3,A0
	BMI.S	.NM
	MOVEQ	#0,D3			; IN A MACRO
.NM:	MOVEQ	#10,D5
	ADDQ.L	#1,A0
.1:	TST.L	D0
	BEQ.S	.3
	TST.L	D3
	BEQ.S	.MA
	CMP.L	D3,A0
	BPL.S	.ER
.B:	MOVE.B	(A0)+,D7
	MOVE.B	(A0),D6
	CMP.B	D7,D5
	BEQ.S	.4
.5:	CMP.B	D1,D7			; IS THIS LIKE "/*" ?
	BNE.S	.2
	CMP.B	D2,D6
	BNE.S	.2
	ADDQ.L	#1,D0
	ADDQ.L	#1,A0
	BRA.S	.1
.2:	CMP.B	D2,D7			; OR LIKE "*/" ?
	BNE.S	.1
	CMP.B	D1,D6
	BNE.S	.1
	SUBQ.L	#1,D0
	ADDQ.L	#1,A0
	BRA.S	.1
.3:	BRA	PARSELOOP
.4:	ADDQ.W	#1,LINENUM
	BRA.S	.5
.ER:	MOVE.L	A3,A0			; FOR ERROR REPORT
	SUBQ.L	#1,A0
	MOVE.L	A4,LINENUM
	BRA	ERROR27
.MA:	TST.B	(A0)
	BEQ.S	.ER
	BRA.S	.B

      PARSEQUOTE:			; `
	MOVEQ	#36,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEEQ:				; =
	MOVEQ	#11,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEPTR:				; ^
	MOVEQ	#32,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEFLT:				; !
	MOVEQ	#37,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSECONS:			; |
	MOVEQ	#46,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSECURL1:			; {
	MOVEQ	#23,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSECURL2:			; }
	MOVEQ	#0,D4
	MOVE.W	#24,(A1)+
	BRA	PARSELOOP

MAXBRACK	= 50
CURBRACK:	DC.L	0

      PARSESQ1:				; [
	MOVEQ	#29,D4
	MOVE.W	D4,(A1)+
	MOVE.L	CURBRACK(PC),A3		; 29:INT, otherbrackoff:LONG
	CMPA.L	#BRACKETSBUF,A3
	BNE.S	.1
	MOVE.L	A0,SQBRAKPOS
	MOVE.L	LINENUM(PC),SQBRAKLINE
.1:	MOVE.L	A1,(A3)+
	MOVE.L	A3,CURBRACK
	CLR.L	(A1)+
	BRA	PARSELOOP

      PARSESQ2:				; ]
	MOVEQ	#30,D4
	MOVE.W	D4,(A1)+
	MOVE.L	CURBRACK(PC),A3
	CMPA.L	#BRACKETSBUF,A3
	BEQ	ERROR52
	MOVE.L	-(A3),A4
	MOVE.L	A3,CURBRACK
	MOVE.L	A1,D0
	SUB.L	A4,D0
	MOVE.L	D0,(A4)			; OFFSET = {otherbrackoff} .. ob+2
	BRA	PARSELOOP

      PARSEPERIOD:			; . .l .b .w
	MOVEQ	#26,D4
	CMP.B	#'W',D6
	BNE.S	.1
	MOVE.W	D4,(A1)+
	BRA	.3
.1:	CMP.B	#'B',D6
	BNE.S	.2
	MOVE.W	#28,(A1)+
	BRA	.3
.2:	CMP.B	#'L',D6
	BNE.S	.4
	MOVE.W	#27,(A1)+
.3:	ADDQ.L	#1,A0
	BRA	PARSELOOP
.4:	CMP.B	#58,D6
	BMI.S	.5
.6:	MOVEQ	#35,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.5:	CMP.B	#48,D6
	BMI.S	.6
	BRA	PARSEVALUE

      PARSEBIGGER:			; > >=
	CMP.B	#'=',D6
	BEQ.S	.1
	MOVEQ	#12,D4
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.1:	MOVEQ	#14,D4
	MOVE.W	D4,(A1)+
	ADDQ.L	#1,A0
	BRA	PARSELOOP

      PARSESMALLER:
	CMP.B	#'=',D6
	BEQ.S	.1
	CMP.B	#'>',D6
	BEQ.S	.2
	MOVEQ	#13,D4			; <
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.1:	ADDQ.L	#1,A0
	CMP.B	#'>',(A0)
	BEQ.S	.3
	MOVEQ	#15,D4			; <=
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP
.2:	MOVEQ	#16,D4			; <>
	MOVE.W	D4,(A1)+
	ADDQ.L	#1,A0
	BRA	PARSELOOP
.3:	MOVEQ	#40,D4			; <=>
	MOVE.W	D4,(A1)+
	ADDQ.L	#1,A0
	BRA	PARSELOOP

      PARSEBECOMES:
	CMP.B	#'=',D6
	BNE.S	.1
	MOVEQ	#ASSGN,D4		; :=
	MOVE.W	D4,(A1)+
	MOVE.B	(A0)+,D7
	BRA	PARSELOOP
.1:	CMP.B	#':',D6
	BNE.S	.2
	MOVEQ	#41,D4			; ::
	MOVE.W	D4,(A1)+
	MOVE.B	(A0)+,D7
	BRA	PARSELOOP	
.2:	MOVEQ	#19,D4			; :
	MOVE.W	D4,(A1)+
	BRA	PARSELOOP

      PARSEOPEN:			; (
	MOVEQ	#17,D4
	MOVE.W	D4,(A1)+
	TST.W	PARSEBRACKET
	BNE.S	.1
	MOVE.L	A0,BRAKPOS
	MOVE.L	LINENUM(PC),BRAKLINE
.1:	ADDQ.W	#1,PARSEBRACKET
	BRA	PARSELOOP

      PARSECLOSE:			; )
	MOVEQ	#18,D4
	MOVE.W	D4,(A1)+
	TST.W	PARSEBRACKET
	BEQ	ERROR20
	SUBQ.W	#1,PARSEBRACKET
	BRA	PARSELOOP

      PARSEBRACKET:	DC.W	0
      BRAKPOS:		DC.L	0
      BRAKLINE:		DC.L	0
      SQBRAKPOS:	DC.L	0
      SQBRAKLINE:	DC.L	0

      ID:
      PARSEIDENT:
	MOVEQ	#0,D5			; D5=HASHVALUE!!!
.3:	HASHC	D5,D7
	MOVE.B	D7,(A2)+		; IDENT
	CMP.B	#123,D6
	BPL.S	.4
	CMP.B	#97,D6
	BPL	.2
	CMP.B	#91,D6
	BPL.S	.5
	CMP.B	#65,D6
	BPL	.2
	CMP.B	#58,D6
	BPL.S	.4
	CMP.B	#48,D6
	BPL	.2
.4:	CLR.B	(A2)+			; IDENT FINISHED
	MOVE.B	#-1,(A2)+
	HASHE	D5
	MOVE.L	D5,HASHVAL
	MOVE.L	WORK(PC),A2
	BTST	#7,CODEPREFS+1
	BEQ.S	.NMAC
	BSR	PREPEXPAND
.NMAC:	MOVE.B	(A2),D0
	CMP.B	#'_',D0
	BMI.S	PARSEUPPER
	BRA.S	PARSELOWER
.2:	MOVE.B	(A0)+,D7
	MOVE.B	(A0),D6
	BRA.S	.3
.5:	CMP.B	#'_',D6
	BEQ.S	.2
	BRA.S	.4

      HASHVAL:	DC.L	0		; IDENT HASHVALUE!!!
      INPROC:	DC.W	0
      REGSTOP:	DC.W	0

      PARSELOWER:
	BSR	PARSEGETIDENTNR
	MOVE.L	WORK(PC),A2
	BRA	PARSELOOP

      PARSEUPPER:
	MOVE.B	1(A2),D0		; INS or Ins or Rx
	CMP.B	#58,D0
	BMI	ASM_PARSEREG
      REGBACK:
	CMP.B	#'a',D0
	BPL	PARSEUPLOW
	CMP.B	#'.',(A0)
	BEQ	PARSECONSTASM
	BSR.W	PARSEGETINSNR		; INS
	TST.W	D0
	BEQ	PARSECONSTASM
	LEA	.TAB-(4*IOFF)(PC),A3
	MOVE.L	D0,D1
	LSL.W	#2,D1
	MOVE.L	0(A3,D1.W),A3
	JMP	(A3)

.TAB:	DC.L	.P,   .EP,  .DONE,.DONE,.DONE,.DONE	; PROC .. WHILE
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE	; ENDW .. DEFAULT
	DC.L	.DONE,.DONE,.DONE,.DONE,.D,   .DONE	; ENDS .. LOCAL
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE	; ELSE .. INC
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE	; DEC  .. AND
	DC.L	.DONE,.RESO,.RESO,.RESO,.DONE,.DONE	; OR   .. FULL
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE	; LARG .. ARRAY
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE	; STRI .. LIST
	DC.L	.OBJ, .EOBJ,.DONE,.EP2, .DONE,.RESO	; OBJE .. ENUM
	DC.L	.RESO,.DONE,.HAND,.DONE,.RSE, .EXP	; SET  .. EXPORT
	DC.L	.REG, .DONE,.EP,  .DONE,.DONE,.DONE	; REG  .. PRIVATE
	DC.L	.DONE,.DONE,.RESO,.DONE,.DONE,.DONE	; SUPE ..
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE
	DC.L	.DONE,.DONE,.DONE,.DONE,.DONE,.DONE


.RESO:	TST.L	CONSTD
	BNE	.SER
	MOVE.L	A1,CONSTD
	MOVE.L	LINENUM(PC),LINENUMZ
	MOVE.W	D0,(A1)+
	MOVE.W	D0,D4
	MOVE.L	WORK(PC),A2
	BRA	PARSELOOP

.BRAK:	TST.W	PARSEBRACKET
	BNE	ERROR20
	RTS

.DONE:	MOVE.W	D0,(A1)+
	MOVE.W	D0,D4
	TST.W	MAXREGALLOC
	BNE	.HEAVY			; DO REGALLOC STATS
.HB:	MOVE.L	WORK(PC),A2
	BRA	PARSELOOP

.P:	MOVE.W	#-1,.DEFF
	MOVE.W	#-1,INPROC
	CLR.W	REGSTOP
	BSR.S	.BRAK
	BRA.S	.RESO
.EP2:	CMP.W	#18,D4			; RETURN PREC ")" OR <OBJ>
	BEQ.S	.EP
	CMP.W	#31,D4
	BNE.S	.DONE
.EP:	CLR.W	INPROC
	BSR.S	.BRAK

	BRA	.DONE

.OBJ:	MOVE.L	#-1,OBJECTD
	CLR.L	OBJNAME
	BRA.S	.DONE
.EOBJ:	CLR.L	OBJECTD
	BRA.S	.DONE

.D:	TST.L	CONSTD
	BNE	ERROR12
	TST.W	.DEFF
	BEQ.S	.DONE
	MOVEQ	#IOFF+17,D0		; SET DEF TO LOCAL
	MOVE.W	#17,CURINS		; FIX
	BRA.W	.DONE
.DEFF:	DC.W	0

.RSE:	MOVE.W	#-1,BUSYRAISE
	BRA	.RESO
.SER:	CMP.W	#IOFF+33,D0
	BNE	ERROR12
	BRA	.DONE
.EXP:	MOVE.W	#-1,EXPORTFLAG
	TSTMOD
	BEQ	ERROR49
	BRA	.DONE
.HAND:	MOVE.L	CPROC(PC),A2
	BSET	#2,2(A2)		; SET NO_REGALLOC
	MOVE.W	#1,REGSTOP
	BRA	.DONE
.REG:	CMP.W	#19,D4
	BNE	.DONE
	MOVE.L	LASTID(PC),D1
	BEQ	.DONE
	MOVE.L	D1,A3

	BTST	#3,5(A3)		; SET REG!
	BNE	ERROR50
	BSET	#3,5(A3)
	MOVE.L	6(A3),A6		; A6=PROC
	TST.W	REGSTOP
	BNE	ERROR56			; NO :REG IN HANDLE
	ADDQ.B	#1,3(A6)
	MOVE.B	3(A6),D7
	EXT.W	D7
	CMP.W	#MAXREGVARS+1,D7
	BPL	ERROR56			; TOOMUCH regvars per proc
	NEG.W	D7
	ADDQ.W	#8,D7
	MOVE.W	D7,10(A3)		; set regnum instead of offset

	BRA	.DONE

; UPDATE HEAVYNESS FACTOR ACCORDING TO KEYWORDS (KEY=D4)

.HEAVY:	TST.W	REGSTOP
	BNE	.HB
	MOVE.W	D4,D0
	SUB.W	#IOFF,D0		; D0=REL_KEY
	MOVE.L	HEAVYNESS,D1		; D1 BECOMES NEW HEAVYNESS
	LE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JUMP-AND
		DC.B "               "	; OR-PTR
		DC.B "            s  "	; OF-EXPORT
		DC.B "               "	; REG...
		DC.B "               "
		EVEN

; s	h:=8		start of PROC etc.
; m	h:=h*8		start of loop
; d	h:=h/8		end of loop
; i	lf;h:=h/2	if
; e	h:=h*2		endif
; E	h:=h*4		endselect
; S	h:=h*16;lf;/4	select
; D	lf		do/then
; U	lf;h:=h/8	until

      POSTOPTI:

;	MOVE.W	LINENUM,D0		; WRITE TABLE AT $1E0000
;	MOVE.L	#$1E0000,A2
;	LSL.W	#2,D0
;	ADD.W	D0,A2
;	MOVE.L	HEAVYNESS,(A2)

	TST.W	MAXREGALLOC
	BEQ.S	.E
	TST.W	REGSTOP
	BNE.S	.E
	TST.W	POSTACTION
	BEQ.S	.EC
	MOVEM.L	D0/D1,-(A7)
	MOVE.L	HEAVYNESS(PC),D1
	MOVE.W	POSTACTION(PC),D0
	CMP.W	#1,D0
	BNE.S	.S
	MOVE.W	POSTMFACTOR(PC),D0
	LSL.L	D0,D1
	MOVE.W	POSTDFACTOR(PC),D0
	LSR.L	D0,D1
	BRA.S	.R
.S:	LSR.L	#6,D1			; /16/4
.R:	CMP.L	#1,D1
	BPL.S	.O
	MOVEQ	#1,D1
.O:	MOVE.L	D1,HEAVYNESS
	MOVEM.L	(A7)+,D0/D1
	CLR.W	POSTACTION
.EC:	CLR.L	POSTMFACTOR
.E:	RTS

      CONSTD:		DC.L	0
      OBJECTD:		DC.L	0
      BUSYRAISE:	DC.W	0

      PARSECONSTASM:
	MOVE.L	WORK(PC),A2
	BSR	ASM_PARSE
	MOVE.L	WORK(PC),A2
	TST.L	D0
	BNE	PARSELOOP
	MOVE.L	#CONSTHASH,A3
	MOVE.L	HASHVAL,D0
	LSL.L	#2,D0
	ADD.L	D0,A3			; A3=START CONST TABEL
	MOVE.L	A3,A6			; A6=BACKUP
.1:	MOVE.L	(A3),A3
	MOVE.L	A3,D0
	BEQ	.3
	MOVE.L	CASCII(A3),A4		; A4=ASCIIPTR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	MOVE.L	ACODE(PC),A3		; IT MIGHT BE A LIBRARY CALL!
	MOVEQ	#0,D1			; (WE USE ASMCODE BUF !!!)
.1:	MOVE.L	(A3)+,A4		; ASC
	CMP.L	A4,D1
	BEQ.S	PNOLIB
	MOVE.L	(A3)+,D0		; D0=OFFSETS
	MOVE.W	(A3)+,D2		; D2=EXCEPTION
	MOVE.L	A2,A5
.2:	CMPM.B	(A4)+,(A5)+
	BNE.S	.1
	CMP.B	#32,(A4)
	BPL.S	.2
	CMP.B	#32,(A5)
	BPL.S	.2
	MOVEQ	#LIBC,D4
	TST.W	BUSYRAISE
	BNE.S	.RAISE
	MOVE.W	D4,(A1)+
	MOVE.L	D0,(A1)+
	MOVEQ	#0,D0
	MOVEQ	#0,D1			; MOVEM.L MASK
	MOVE.L	A4,(A1)+
.4:	MOVE.B	(A4)+,D0
	CMP.W	#16,D0
	BPL.S	.3
	BSET	D0,D1
	BRA.S	.4
.3:	MOVE.W	D1,(A1)+
	MOVE.W	D2,(A1)+		; PUT EXCEPTION #
	BRA.S	PLIBOUT
.RAISE:	LEA	-10(A3),A3
	MOVE.W	#38,(A1)+
	MOVE.L	A3,(A1)+
	BRA.S	PLIBOUT
      PNOLIB:				; WHAT ELSE?
	MOVE.L	WORK(PC),ERROROBJ
	BRA	ERROR24
      PLIBOUT:
	MOVE.L	WORK(PC),A2
	BRA	PARSELOOP

      VAL:
      PARSEVALUE:
.2:	MOVE.B	D7,(A2)+
	MOVE.B	(A0)+,D7
	CMP.B	#58,D7
	BPL.S	.1
	CMP.B	#48,D7
	BPL	.2
	CMP.B	#".",D7
	BEQ.S	.2
.1:	SUBQ.L	#1,A0
	MOVE.B	#0,(A2)+		; VALUE FINISHED
	MOVE.L	WORK(PC),A2
	BSR	PARSEGETVALUE
	MOVE.L	WORK(PC),A2

	MOVEQ	#VALUE,D4
	TST.L	D7
	BEQ.S	.3
	ADD.W	#42,D4			; FLOAT
.3:
	MOVE.W	D4,(A1)+
	MOVE.L	D0,(A1)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L	#BRACKETSBUF,CURBRACK		; OPEN [ ( COUNT
	BNE	PCONTINUE
	TST.W	PARSEBRACKET
	BNE	PCONTINUE
	CMP.W	#IOFF,D4
	BPL.S	.2TAB
	MOVE.B	CONTINUETAB(PC,D4.W),D6		; CHECK FOR "," ETC.
	TST.B	D6
	BNE	PCONTINUE
	BRA.S	.1
.2TAB:	MOVE.B	CONTINUEKEY-IOFF(PC,D4.W),D6	; CHECK FOR KEYWORDS
	TST.B	D6
	BNE	PCONTINUE
	BRA.S	.1
.SKIP:	CMP.L	#BRACKETSBUF,CURBRACK
	BEQ.S	.1C
	MOVE.L	SQBRAKPOS(PC),D0
	BEQ.S	.1D
	MOVE.L	D0,A0
	MOVE.L	SQBRAKLINE(PC),LINENUM
.1D:	BRA	ERROR34
.1C:	TST.W	PARSEBRACKET
	BEQ.S	.1
	MOVE.L	BRAKPOS(PC),D0
	BEQ.S	.1B
	MOVE.L	D0,A0
	MOVE.L	BRAKLINE(PC),LINENUM
.1B:	BRA	ERROR20
.1:	MOVE.L	CONSTD(PC),D0
	BNE	RESOLVECONST
      RESBACK:
	BTST	#6,CODEPREFS+2		; SEE IF EXPORT ALL
	BNE.S	.EA
	CLR.W	EXPORTFLAG
.EA:	MOVE.L	A0,CURECODE
	MOVEQ	#0,D4
	MOVE.W	D4,(A1)+
	CMP.B	#10,-1(A0)
	BNE.S	.2
	ADDQ.W	#1,LINENUM		; COUNT LINES
	MOVE.W	LINENUM(PC),LINENUM2
.2:	MOVE.L	STARTINTERIM(PC),A0	; SEE IF WE PARSED AN EMPTY LINE
	CMP.L	A1,A0
	BEQ.S	.1
	MOVE.L	A1,CURINTERIM
	ADDQ.W	#1,STATS
	BRA.S	.3
.1:	SUBQ.L	#6,A0
	MOVE.L	A0,CURINTERIM
.3:	BSR	POSTOPTI
	RTS				; THE ONLY WAY OUT

CONTINUEKEY:	DC.B	1,0,1,0,1,1,0,1,0,1,1,0	; PROC .. DEFA
		DC.B	0,0,1,1,1,1,0,1,0,0,0,1	; ENDS .. INC
		DC.B	1,1,0,0,0,1,1,1,1,0,0,0	; DEC  .. FULL
		DC.B	0,0,0,1,1,0,0,1,1,1,1,0	; LARG .. LIST
		DC.B	1,0,1,0,1,1,1,1,0,0,1,0	; OBJE .. EXPO
		DC.B	0,1,1,1,0,0,0,0,1,0,0,0	; REG  ..
		EVEN


; ALSO CALLED FROM PREP!!!

      MOVEBUF:
	MOVE.L	A1,CURINTERIM		; FOR CHECK.
	MOVE.L	A1,D7			;
	BSR	REALLOC1		; CHECK DOUBLECHECK
	MOVE.L	CURINTERIM(PC),A1	;
	SUB.L	A1,D7			;
	BEQ.S	.1			;
	NEG.L	D7			;
	ADD.L	D7,STARTINTERIM		;
	TST.L	CONSTD			;
	BEQ.S	.1			;
	ADD.L	D7,CONSTD		;
.1:	RTS

      PCONTINUE:
	BSR.S	MOVEBUF
	CMP.B	#10,-1(A0)
	BNE	PARSELOOP
	ADDQ.W	#1,LINENUM		; COUNT LINES
	BRA	PARSELOOP

      REBACK:
	MOVE.W	#1,ERRWHERE
	MOVE.L	LINENUMZ,LINENUM
	BRA	RESBACK

      STATS:	DC.W	0

      RESOLVECONST:
	ADDQ.W	#1,STATS
	MOVE.W	#2,ERRWHERE		; A1 NOW
	MOVE.L	LINENUM(PC),D6
	MOVE.L	LINENUMZ(PC),LINENUM
	MOVE.L	D6,LINENUMZ
	MOVE.L	A1,D6			; D6=ENDPARSE
	MOVEQ	#0,D4
	MOVE.W	D4,(A1)+
	MOVE.L	D0,A1
	MOVE.L	D0,A3
	MOVE.L	A3,INTERMED		; !!!!
	MOVE.W	(A3)+,D7		; INS. CODE
	CLR.L	CONSTD
	CMP.W	#IOFF,D7
	BEQ	PROCPARSE
	CMP.W	#IOFF+32,D7
	BEQ	.OPT
	CMP.W	#IOFF+33,D7
	BEQ	MODULELOAD
	CMP.W	#IOFF+53,D7
	BEQ	DOENUM
	CMP.W	#IOFF+54,D7
	BEQ	DOSET
	CMP.W	#IOFF+58,D7
	BEQ	DORAISE
	CMP.W	#IOFF+68,D7
	BEQ	DOLIBRARY
.1:	TST.W	INPROC
	BNE	ERROR35
	GETM	A4			; CONST
	CMP.W	#25,(A3)+
	BNE	ERROR0
	MOVE.L	(A3)+,4(A4)
	MOVE.L	(A3)+,A6
	MOVE.L	(A6),(A4)
	MOVE.L	A4,(A6)
	ADDQ.L	#8,A4
	CMP.W	#11,(A3)+
	BNE	ERROR0
	MOVE.L	A0,-(A7)
	BSR	ASM_GRABVALUE
	MOVE.L	(A7)+,A0
	CMP.W	#-1,D0
	BEQ	ERROR30
	MOVE.L	D1,(A4)+
	CLR.W	(A4)+
	TST.W	EXPORTFLAG
	BEQ.S	.NE
	BSET	#0,-2(A4)
.NE:	DONEM	A4
	CMP.W	#COM,(A3)+
	BEQ.S	.1
	TST.W	-2(A3)
	BNE	ERROR0
	BRA	REBACK
.OPT:	CMP.W	#1,STATS		; OPT
	BNE	ERROR35
	CLR.W	STATS
.2:	MOVE.W	(A3)+,D7
	CMP.W	#VALUE,D7
	BEQ	.CPU
	CMP.W	#IOFF+34,D7		; --> STACK=X
	BNE.S	.4B
	CMP.L	#$B0001,(A3)+
	BNE	ERROR0
	MOVE.L	(A3)+,D7
	CMP.L	#MINSTACKSIZE,D7
	BMI	ERROR31
	BSET	#0,CODEPREFS+3
	MOVE.L	D7,CODESTACK
	BRA	.5
.4B:	CMP.W	#IOFF+67,D7		; --> PREPROCESS
	BNE.S	.4BB
	BSET	#7,CODEPREFS+1
	BRA	.5
.4BB:	CMP.W	#IOFF+59,D7		; --> EXPORT
	BNE.S	.4C
	BSET	#6,CODEPREFS+2
	BRA	.5
.4C:	CMP.W	#$276,D7		; --> RTD
	BNE.S	.4D
	;BSET	#0,CODEPREFS+1		; probs with hooks/callbacks etc.
	BRA	.5
.4D:	CMP.W	#IOFF+60,D7		; --> REG=X
	BNE.S	.6
	CMP.L	#$B0001,(A3)+
	BNE	ERROR0
	MOVE.L	(A3)+,D7
	TST.L	D7
	BMI	ERROR31
	CMP.L	#MAXREGVARS+1,D7
	BPL	ERROR31
	MOVE.W	D7,MAXREGALLOC
	BRA	.5
.6:	CMP.W	#IOFF+37,D7		; --> ASM
	BNE.S	.7
	BSET	#3,CODEPREFS+3
	MOVE.W	#-1,SCOPE		;     NO NEED OF SCOPES ANYMORE
	MOVE.W	#-1,MAINF		;     ... AND NO MAIN EITHER
	BRA	.5
.7:	CMP.W	#IOFF+38,D7		; --> NOWARN
	BNE.S	.8
	BSET	#4,CODEPREFS+3
	BRA	.5
.8:	CMP.W	#IOFF+43,D7		; --> DIR
	BNE.S	.9
	CMP.L	#$B0006,(A3)+
	BNE	ERROR0
	ADDQ.L	#2,A3
	MOVE.W	(A3)+,D0
	MOVE.L	DIRNAMEX(PC),A4
	SUBQ.W	#1,D0
.L:	MOVE.W	(A3)+,(A4)+
	DBRA	D0,.L
	BRA.S	.5
.9:	CMP.W	#IOFF+52,D7		; --> OSVERSION
	BNE.S	.10
	BSET	#0,CODEPREFS+2
	CMP.L	#$B0001,(A3)+
	BNE	ERROR0
	MOVE.L	(A3)+,D7
	CMP.L	#33,D7
	BMI	ERROR31
	CMP.L	#100,D7
	BPL	ERROR31
	MOVE.W	D7,OSVERSION
	BRA.S	.5
.10:	CMP.W	#IOFF+36,D7		; --> LARGE
	BNE.S	.11
	BSET	#2,CODEPREFS+3
	BRA.S	.5
.11:	CMP.W	#IOFF+33,D7		; --> MODULE (OPT)
	BNE	ERROR1
	BSET	#4,CODEPREFS+2
.5:	CMP.W	#COM,(A3)+
	BEQ	.2
	TST.W	-2(A3)
	BNE	ERROR0
	BRA	REBACK
.CPU:	MOVE.L	(A3)+,D7		; --> OPT 040
	LEA	CPUTAB(PC),A6
.CPUL:	CMP.W	#-1,(A6)
	BEQ	ERROR31
	ADDQ.L	#8,A6
	CMP.W	(A6),D7
	BNE.S	.CPUL
	MOVE.W	2(A6),D0
	BEQ.S	.C1
	TST.W	ECPU
	BNE	ERROR50
	MOVE.W	D0,ECPU
.C1:	MOVE.W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ALREADY THERE
	MOVE.L	D0,A0
	TST.L	D0
	BNE.S	.GOTM

	MOVE.L	D6,D0
	BSR	FILELENGTH
	MOVE.L	D0,D3
	BEQ	ERROR36
	BMI	ERROR36
	MOVE.L	#1005,D2
	JSR	-30(A6)			; OPEN
	MOVE.L	D0,D5			; D5=HANDLE
	BEQ	ERROR36
	MOVE.L	D3,D0
	ADDQ.L	#8,D0
	BSR	NEWCACHE
	MOVE.L	D0,D2
	BEQ	ERROR38
	MOVE.L	D5,D1
	JSR	-42(A6)			; READ
	MOVE.L	D0,D4
	MOVE.L	D5,D1
	JSR	-36(A6)			; CLOSE
	CMP.L	D3,D4
	BNE	ERROR36
	MOVE.L	D2,A0
	ADD.L	D3,D2
	MOVE.L	D2,A1
	CLR.B	(A1)+
	CLR.B	(A1)+
	CLR.B	(A1)+
	CLR.B	(A1)+
	CLR.B	(A1)+
	CLR.B	(A1)+			; max 8!
.GOTM:	MOVEM.L	D0-D7/A0-A6,-(A7)
	TST.L	THISMOD
	BEQ.S	.3
	MOVE.L	THISMOD,A1
	MOVE.L	A0,MI_MOD(A1)
	BRA.S	.GM
.3:	GETM	A1				; CREATE A MODINFO
	MOVE.L	A1,THISMOD
	MOVE.L	MODINFOLIST(PC),(A1)		; MI_NEXT
	MOVE.L	A1,MODINFOLIST
	ADDQ.L	#4,A1
	CLR.W	(A1)+				; MI_FLAGS
	MOVE.L	CACHENAMEEND(PC),A2
	SUB.L	CACHENAMESTART(PC),A2
	MOVE.L	A2,(A1)+			; MI_NAMELEN
	MOVE.L	A0,(A1)+			; MI_MOD
	CLR.L	(A1)+				; MI_LIST
	LEA	4(A1),A2
	MOVE.L	A2,(A1)+			; MI_NAMEPTR
	MOVE.L	CACHENAMESTART(PC),A2		; MI_NAME
.L:	MOVE.B	(A2)+,(A1)+
	BNE.S	.L
	MOVE.L	A1,D0
	BTST	#0,D0
	BEQ.S	.E
	CLR.B	(A1)+
.E:	DONEH	A1
.GM:	CMP.L	#"EMOD",(A0)+
	BNE	ERROR36
	JSR	MODULEJOBENTRY
	MOVEM.L	(A7)+,D0-D7/A0-A6
.NEXT:	MOVE.L	D7,A0
	MOVE.B	#0,(A0)+
	CMP.W	#COM,(A3)+
	BEQ	MODULELOOP
	TST.W	-2(A3)
	BNE	ERROR0
	MOVEM.L	(A7)+,A0/A1
	BRA	REBACK

      MODINFOLIST:	DC.L	0

; GETS NAME FROM CACHENAMESTART, RETURNS MODINFO OR NIL IN D0

      SEARCHINMODLIST:
	MOVEM.L	D1-D2/A0-A2,-(A7)
	LEA	MODINFOLIST(PC),A0	; A0=MODLIST
	MOVE.L	CACHENAMESTART(PC),D1	; D1=NAME
	MOVE.L	CACHENAMEEND(PC),D2
	SUB.L	D1,D2			; D2=LEN
.L:	MOVE.L	(A0),D0
	BEQ.S	.X
	MOVE.L	D0,A0
	CMP.L	MI_NAMELEN(A0),D2
	BNE.S	.L
	MOVE.L	MI_NAMEPTR(A0),A1
	MOVE.L	D1,A2
.CMP:	CMPM.B	(A1)+,(A2)+
	BNE.S	.L
	TST.B	-1(A1)
	BNE.S	.CMP
	MOVE.L	A0,D0
.X:	MOVEM.L	(A7)+,D1-D2/A0-A2
	RTS

      AGAIN:	DC.W	0

      SECONDARYLOAD:
.ML:	CLR.W	AGAIN
	MOVE.L	DOSBASE,A6		; A6=BASE
	LEA	MODINFOLIST(PC),A5	; A5=LIST
.L:	MOVE.L	(A5),D0
	BEQ.W	.X
	MOVE.L	D0,A5
	BTST	#0,MI_FLAGS(A5)
	BEQ.S	.L
	BCLR	#0,MI_FLAGS(A5)

	MOVE.L	MI_NAMEPTR(A5),D0
	MOVE.L	D0,ERROROBJ
	MOVE.L	D0,CACHENAMESTART
	ADD.L	MI_NAMELEN(A5),D0
	MOVE.L	D0,CACHENAMEEND
	BSR	SEARCHINCACHE
	MOVE.L	D0,A0
	TST.L	D0
	BNE.S	.GOTM

	MOVE.L	MI_NAMEPTR(A5),D0
	BSR	FILELENGTH
	MOVE.L	D0,D3
	BEQ	ERRO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VE.L	D0,6(A2)		; DEFARGSLIST IN PROCSTRUCT
	DONEH	A6
.EX:	CMP.W	#IOFF+45,(A3)+		; NOW CHECK FOR of_object
	BNE	.NOM
	CMP.W	#31,(A3)+
	BNE	.REX
	MOVE.L	(A3)+,A3		; A3=OBJECTHEAD, A2=PROC
	BTST	#1,2(A3)
	BNE	ERROR69
	MOVE.L	A3,10(A2)		; SET PROC TO METHOD
	MOVE.L	-4(A2),PROCLIST		; DISCONNECT FROM PROCLIST
	CLR.L	-4(A2)

	MOVE.L	14(A2),A6
	MOVE.L	(A6),D0
	MOVE.L	A3,A6
	MOVE.L	A0,-(A7)
	JSR	FINDMETHOD		; WANTS OBJ=A6,NAME=D0, TRASHES A0,
	MOVE.L	(A7)+,A0
	TST.L	D1			;   RETURNS D1=METHOD | NIL
	BNE	ERROR61

	GETM	A6
	MOVE.L	OMETHOD(A3),D2		; BUILD NEW METHOD:
	MOVE.L	A6,OMETHOD(A3)
	MOVE.L	A6,22(A2)
	MOVE.L	D2,(A6)+		; SET M_NEXT
	MOVE.L	A2,(A6)+		; SET M_PROC
	MOVE.B	#MT_METHOD,(A6)+	; SET M_TYPE
	CLR.B	(A6)+
	MOVEQ	#4,D0
	TST.L	D2
	BEQ.S	.F
	MOVE.L	D2,A4
	MOVE.W	M_OFF(A4),D0
	ADDQ.W	#4,D0
.F:	MOVE.W	D0,(A6)+		; SET M_OFF TO LAST M_OFF+4
	ADDQ.W	#4,D0
	MOVE.W	D0,ODEL(A3)
	MOVE.L	14(A2),A4		; A4=IDENT
	MOVE.L	(A4),(A6)+		; SET M_NAME
	BSET	#4,5(A4)		; SET FLAGS OR METHOD
	BSET	#0,5(A4)
	DONEM	A6
	BSET	#1,2(A2)
	MOVE.L	CURSELF(PC),D0		; NOW MAKE A "self" FOR THIS METHOD
	BNE.S	.GOTS
	GETM	A6
	MOVE.L	SELFHASHADR(PC),A4
	MOVE.L	(A4),(A6)+
	MOVE.L	A6,(A4)
	MOVE.L	A6,D0
	MOV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)+		; ()        A4 --> RECORD
	BNE	ERROR23
	MOVE.W	(A3)+,D1
	CMP.W	#11,D1
	BMI	ERROR0
	CMP.W	#17,D1
	BPL	ERROR0
	MOVE.W	D1,(A4)
	CMP.W	#8,(A3)
	BNE.S	.2
	ADDQ.L	#2,A3
	CMP.W	#VALUE,(A3)
	BNE.S	.2
	NEG.L	2(A3)
.2:	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	MOVE.L	(A3)+,6(A4)
	CMP.W	#COM,(A3)+
	BEQ	.1
	TST.W	-2(A3)
	BNE	ERROR0
	CLR.W	BUSYRAISE		; !
	BRA	REBACK

RAISENUM:	DC.W	0

OSVERSION:	DC.W	0
WARNINGS:	DC.L	0
CODEPREFS:	DC.L	0
CODESTACK:	DC.L	0
MAXREGALLOC:	DC.W	0

ECPU:		DC.W	0		; 0,1,2 = 000+, 020+, 040+
EFPU:		DC.W	0		; 0,1,2 = FFP, 881/882, 040
ASMCPU:		DC.W	0		; BITSET

CPUTAB:	DC.W	010,0,0,0		; CPU,ECPUTYPE,EFPUTYPE,ASMCPUBIT#
	DC.W	020,1,0,1
	DC.W	030,1,0,2
	DC.W	040,2,2,3
	DC.W	060,2,2,4
	DC.W	881,0,1,8
	DC.W	882,0,1,9
	DC.W	851,0,0,10
	DC.W	-1

      PARSEGETINSNR:			; GETS INSNR OUTOF WORKBUF
	MOVEQ	#0,D0			; INSNR (MUST BE <>0 AT END)
	MOVE.W	CURINS(PC),-(A7)
	MOVEQ	#-1,D1
	MOVE.W	D1,CURINS
	MOVE.L	HASHVAL(PC),D7
	LSL.L	#2,D7
	ADD.L	#KEYHASH,D7
	MOVE.L	D7,A6
.LOOP:	MOVE.L	(A6),A6			; A6 _NOW_ POINTS TO ENTRY IN INSTABLE
	MOVE.L	A6,D6
	BEQ.S	.4
	MOVE.L	WORK(PC),A4
	MOVE.L	(A6)+,A5
.2:	CMPM.B	(A4)+,(A5)+
	BNE.S	.LOOP
	TST.B	-1(A4)
	BNE.S	.2
	SUB.L	#INSTABLE,D6
	LSR.L	#3,D6
	MOVE.L	D6,D1
	MOVEQ	#IOFF,D0
	ADD.W	D1,D0			; STAY: 0..20, 50..59, 62..
	CMP.W	#IOFF+20,D0
	BPL.S	.4
	MOVE.W	D1,CURINS
.3:	ADDQ.L	#2,A7
	RTS
.4:	CMP.W	#IOFF+50,D0
	BPL.S	.5
.6:	MOVE.W	(A7)+,CURINS
	RTS
.5:	CMP.W	#IOFF+60,D0
	BPL.S	.7
	BRA.S	.3
.7:	CMP.W	#IOFF+62,D0
	BPL.S	.3
	BRA.S	.6

      MAKEKEYHASH:
	MOVE.L	#KEYHASH,A0		; A0=TABEL
	LEA	INSTABLE,A1
	MOVE.L	A0,A2
	MOVE.L	#255,D0
.CL:	CLR.L	(A2)+			; CLEAR TABLE
	DBRA	D0,.CL
.LOOP:	MOVE.L	(A1),D0
	BEQ.S	.EX
	MOVE.L	D0,A2
	HASH	A2,D0,D1
	LSL.L	#2,D0

LEA	0(A0,D0.L),A2
	MOVE.L	(A2),D0			; READ PREVIOUS LIST (OR NIL)
	MOVE.L	A1,(A2)			; PUT ENTRY IN LIST
	MOVE.L	D0,4(A1)		; AND LINK TAIL TO IT
	ADDQ.L	#8,A1
	BRA.S	.LOOP
.EX:	RTS

	CURINS:	DC.W	0

;;IDENT

      PARSEGETIDENTNR:			; GETS IDENTNR OUTOF WORKBUF
	TST.L	OBJECTD
	BNE	OBJECTIDENT

	MOVE.L	CPROC(PC),D3
	MOVEQ	#0,D5
	MOVEQ	#UNDEF,D7
	MOVE.W	CURINS(PC),D6		; INS-ioff

	CMP.W	#35,D4			; .
	BEQ	.1
	CMP.W	#IOFF+39,D4		; TO
	BEQ.S	.5
	CMP.W	#19,D4			; :
	BEQ.S	.4
	CMP.W	#IOFF+45,D4		; OF
	BEQ.S	.2
	CMP.W	#IOFF+50,D4		; SIZEOF
	BEQ.S	.1
	CMP.W	#41,D4			; ::
	BEQ.S	.1
	BRA.S	XNEXT
.5:	CMP.W	#I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ok
	CMP.L	CPROC(PC),D0
	BNE.S	IDCHECKLOOP
	BRA.S	.3
.2:	CMPI.B	#LAB,4(A5)		; check if redef loc/glob > lab
	BNE.S	.3
	CMP.W	#LOCV,D7
	BEQ.S	IDCHECKLOOP
	CMP.W	#GLOBV,D7
	BEQ.S	IDCHECKLOOP
.3:	MOVE.L	A5,D5
	CMPI.B	#GLOBV,4(A5)		; check if locv > globv
	BEQ.S	IDCHECKLOOP

; HIERNA D4 TIJDLK. GETRASHED
	
      IDALREADYPRESENT:
	TST.W	D7			; USE IN EXP
	BEQ.W	.X2                     ; !!!!!!!!!!!!! WAS .X
	MOVE.B	4(A5),D4		; USE IN 'LOCAL'
	CMP.B	#LOCV,D7
	BNE.S	.10
	TST.B	D4			; var has type?
	BNE.S	.2
	MOVE.L	6(A5),D0
	CMP.L	D3,D0
	BNE.S	.X
	MOVE.B	#LOCV,4(A5)		; no: local
	BRA.S	.X
.2:	CMP.B	#GLOBV,D4
	BEQ	UNIDENT2
	CMP.B	#LOCV,D4
	BNE	ERROR21			; LAB AS LOC OR LOC*2
	CMP.L	6(A5),D3
	BEQ	ERROR21			; same local name in other proc
	BRA	UNIDENT2
.10:	CMP.B	#LAB,D7			; USE IN 'DEF'
	BEQ.S	.20
	CMP.B	#LOCV,D4
	BEQ	UNIDENT2
	BTST	#2,5(A5)
	BNE.S	.12
	TST.B	D4
	BNE	ERROR21
	BRA.S	.12B
.12:	TST.W	EXPORTFLAG		; allow bases to be redefined nonexport
	BNE.S	.12B
	BCLR	#2,5(A5)
.12B:	MOVE.B	#GLOBV,4(A5)
	BRA.S	.X
.20:	CMP.B	#":",(A0)		; ONLY TEST LABELS, NOT PROCS/METHODS
	BNE.S	.MH
	CMP.B	#LAB,D4			; OK THIS TEST?
	BEQ	ERROR14
.MH:	TST.B	D4			; USE IN 'PROC' OR ':'
	BNE	UNIDENT3
	MOVE.B	#LAB,4(A5)
	MOVE.W	#-1,10(A5)
.X:	MOVE.L	D3,6(A5)
.X2:	MOVE.L	D4,D2
	MOVEQ	#IDENT,D4
	MOVE.W	D4,(A1)+
	MOVE.L	D5,(A1)+
	TST.W	MAXREGALLOC
	BEQ.S	.NR
	CMP.B	#LOCV,4(A5)
	BNE.S	.NR
	CMP.W	#23,D2			; used in {}
	BEQ.S	.NR2
	TST.L	VARHEAVY(A5)
	BEQ.S	.NR
	MOVE.L	HEAVYNESS(PC),D0
	ADD.L	D0,VARHEAVY(A5)
.NR:	TST.B	D7
	BEQ.S	.S
	TST.W	EXPORTFLAG
	BEQ.S	.NOEXP
	BSET	#0,5(A5)		; USED IF DEF+EXPORT
.NOEXP:	RTS
.S:	BSET	#0,5(A5)		; SET IF USED
	RTS
.NR2:	CLR.L	VARHEAVY(A5)
	BRA.S	.NR

      UNIDENT3:
	TST.L	10(A5)			; see if objhead in procstruct
	BEQ.W	ERROR21			; no method!
	MOVE.L	CPROC(PC),A6
	BSET	#1,2(A6)		; SET METHOD
	BRA.S	UNIDENT2
      UNIDENT:
	TST.L	D5
	BNE	DOUBLENAME
      UNIDENT2:
	GETM	A3			; A3=FRESH MEM
	MOVE.L	WORK(PC),A4
	MOVE.L	A3,A5			; A5=ASCIIPTR IN HEAP
.1:	MOVE.B	(A4)+,(A3)+
	BNE.S	.1
	MOVE.L	A3,D0
	BTST	#0,D0
	BEQ.S	.OK
	CLR.B	(A3)+
.OK:	MOVE.L	IDHASHADR,A4
	MOVE.L	(A4),(A3)+
	MOVE.L	A3,(A4)
	MOVEQ	#IDENT,D4
	MOVE.W	D4,(A1)+
	MOVE.L	A3,(A1)+
	MOVE.L	A3,LASTID
	MOVE.L	A3,A6			; A6=BASE ID
	MOVE.L	A5,(A3)+
	MOVEQ	#0,D0
	MOVE.B	D7,(A3)+		; TST
	BEQ	.S
	TST.W	EXPORTFLAG
	BNE.S	.SE
	CLR.B	(A3)+
	BRA.S	.S2
.SE:	MOVE.B	#4,(A3)+		; SET EXPORT
	CMP.W	#2,D7
	BEQ.S	.S2
	BSET	#0,-1(A3)		; +USED
	BRA.S	.S2
.S:	MOVE.B	#1,(A3)+		; SET FLAGS=1 IF USED (D7=0)
	; ALS IDENT<>LABEL DAN ERROR22
.S2:	MOVE.L	D3,(A3)+
	CMP.B	#LAB,D7
	BEQ.S	.2
	MOVE.W	D0,(A3)+		; VARS:   OFFSET=0
	CMP.B	#LOCV,D7
	BNE.S	.3			; SEE IF LOCAL --> HEAVYNESS
	TST.W	MAXREGALLOC
	BEQ.S	.3
	TST.W	REGSTOP
	BNE.S	.2A
	MOVE.L	HEAVYNESS(PC),(A3)+	; must be offs VARHEAVY
	BRA.S	.3
.2A:	CLR.L	(A3)+			; no regalloc in HANDLEr
	BRA.S	.3
.2:	MOVE.W	#-1,(A3)+		; LABELS: OFFSET=-1
.3:	CMP.L	#"main",(A5)
	BNE.S	.NM
	TST.B	4(A5)
	BNE.S	.NM
	BSET	#0,5(A6)
.NM:	CMP.L	#"self",(A5)
	BNE.S	.NS
	TST.B	4(A5)
	BNE.S	.NS
	MOVE.L	A6,CURSELF
.NS:	DONEM	A3
	RTS
      DOUBLENAME:
	MOVE.L	D5,A5
	BRA	IDALREADYPRESENT

      LASTID:		DC.L	0
      IDHASHADR:	DC.L	0
      CURSELF:		DC.L	0
      SELFHASHADR:	DC.L	0
      SELFNAME:		DC.B	"self",0,0

      NEWPROC:
	GETM	A3
	MOVE.L	PROCLIST(PC),(A3)+
	MOVE.L	A3,PROCLIST
	MOVE.L	A3,CPROC
	MOVE.L	A3,D3
	CLR.L	(A3)+
	BTST	#0,CODEPREFS+1
	BEQ.S	.1
	TSTMOD
	BNE.S	.1
	BSET	#0,-2(A3)		; USE RTD
.1:	CLR.W	(A3)+			; FIRST 10 BYTES IN USE
	CLR.L	(A3)+			; DEFARGS
	CLR.L	(A3)+			; of_object
	CLR.L	(A3)+			; IDENT
	CLR.L	(A3)+			; SELF
	CLR.L	(A3)+			; METHOD
	CLR.L	(A3)+			; if regalloc then table
	DONEM	A3
	RTS

	PROCLIST:	DC.L	0
	CPROC:		DC.L	0
	OBJNAME:	DC.L	0

      FINDOBJ:				; D1=ASCII, RET D0=OBJH | NIL
	MOVEM.L	A3/A4/A5,-(A7)
	LEA	OLIST+4(PC),A3
.L:	MOVE.L	ONEXT(A3),A3
	MOVE.L	A3,D0
	BEQ.S	.X
	MOVE.L	D1,A4
	MOVE.L	OASCII(A3),A5		; ASCII
.L2:	CMPM.B	(A5)+,(A4)+
	BNE.S	.L
	TST.B	-1(A5)
	BNE.S	.L2
	MOVE.L	A3,D0
.X:	MOVEM.L	(A7)+,A3/A4/A5
	RTS

      OBJUSE:
	CMP.W	#35,D4			; SEARCHING OBJECTNAME OR FIELD
	BEQ.S	.FIELD
	MOVE.L	WORK(PC),D1		; D1=ASCIIPTR
	BSR	FINDOBJ
	MOVEQ	#31,D4			; FOUND
	MOVE.W	D4,(A1)+
	MOVE.L	D0,(A1)+
	BEQ	ERROR42
	RTS
.FIELD:	MOVE.L	WORK(PC),D1		; IS THIS PART NECESSARY ?
	LEA	MEMBERLIST+4(PC),A3
.FL:	MOVE.L	ONEXT(A3),A3
	MOVE.L	A3,D0
	BEQ	.MODF
	MOVE.L	D1,A4
	MOVE.L	OASCII(A3),A5
	MOVE.L	A5,D0			; SKIP IF PRIVATE
	BEQ.S	.FL
.FL2:	CMPM.B	(A5)+,(A4)+
	BNE.S	.FL
	TST.B	-1(A5)
	BNE.S	.FL2
	MOVEQ	#39,D4
	MOVE.W	D4,(A1)+
	MOVE.L	A3,(A1)+
	RTS
.MODF:	MOVE.L	WORK(PC),D1		; SEARCH IN "MODULE" LIST
	LEA	OLIST+4(PC),A3		; (AFTER OWN OBJECTS!)
.MFL:	MOVE.L	ONEXT(A3),A3
	MOVE.L	A3,D0
	BEQ	.UNF
	LEA	OMEMB+4(A3),A6
.ML:	MOVE.L	ONEXT(A6),A6
	MOVE.L	A6,D0
	BEQ.S	.MFL
	MOVE.L	D1,A4
	MOVE.L	OASCII(A6),A5
	MOVE.L	A5,D0			; SKIP IF PRIVATE
	BEQ.S	.ML
.ML2:	CMPM.B	(A5)+,(A4)+
	BNE.S	.ML
	TST.B	-1(A5)
	BNE.S	.ML2
	MOVEQ	#39,D4
	MOVE.W	D4,(A1)+
	MOVE.L	A6,(A1)+
	RTS
.UNF:	MOVEQ	#42,D4			; NOT FOUND SOFAR
	MOVE.W	D4,(A1)+
	GETM	A3
	MOVE.L	A3,(A1)+
	MOVE.L	WORK(PC),A4
.UFL:	MOVE.B	(A4)+,(A3)+		; KAN DUS NIET!!!
	BNE.S	.UFL			; DOUBLE COPY
	MOVE.L	A3,D1
	BTST	#0,D1
	BEQ.S	.UF2
	ADDQ.L	#1,A3
.UF2:	DONEM	A3
	RTS


      OLIST:		DC.L	0
      MEMBERLIST:	DC.L	0	; TIJDENS LEX

      OBJECTIDENT:			; definition
	CMP.W	#19,D4			; 2. bla:INT IPV x:bla
	BEQ.S	.S
	CMP.W	#IOFF+39,D4		; TO
	BEQ.S	.S
	CMP.W	#IOFF+45,D4		; OF
	BNE.S	.NEW
.S:	MOVE.L	WORK(PC),A5
	MOVE.L	A5,D5
	LEA	OLIST+4(PC),A6		; A6=LINKED LIST
.L:	MOVE.L	ONEXT(A6),A6
	MOVE.L	A6,D0
	BEQ.S	.MUT
	MOVE.L	OASCII(A6),A4
	MOVE.L	D5,A5
.COMP:	CMPM.B	(A5)+,(A4)+
	BNE.S	.L
	TST.B	-1(A5)
	BNE.S	.COMP
	CMP.W	#IOFF+48,D4		; 1. OBJECT <DOUBLEDECL>
	BEQ	ERROR43
	MOVEQ	#31,D4			; FOUND
	MOVE.W	D4,(A1)+
	MOVE.L	A6,(A1)+
	RTS
.MUT:	CMP.W	#IOFF+39,D4		; ONLY "TO". ILLEGAL = "OF", ":"
	BNE	ERROR42
	MOVEQ	#45,D4
	MOVE.W	D4,(A1)+
	GETM	A3
	MOVE.L	A3,(A1)+
	MOVE.L	D5,A5
.MUTL:	MOVE.B	(A5)+,(A3)+
	BNE.S	.MUTL
	MOVE.L	A3,D0
	ADDQ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GETVALUE:			; A2 STRING, =>D0 LONGINT
	TST.B	(A2)+
	BNE.S	PARSEGETVALUE
	SUBQ.L	#1,A2
	MOVEQ	#0,D0			; RESULT
	CMPA.L	#WORKBUF+11,A2
	BPL	ERROR7
	LEA	VALUETAB(PC),A3
	MOVEQ	#0,D7
.1:	MOVEQ	#0,D3
	MOVE.L	(A3)+,D2
	MOVE.B	-(A2),D3
	SUB.W	#48,D3
	BMI.S	.2			; DAMN! WERE DOING A FLOAT!
	MOVE.L	D3,D1
	MULU	D2,D3
	SWAP	D2
	MULU	D2,D1
	SWAP	D1
	ADD.L	D1,D3
	ADD.L	D3,D0
	BCS	ERROR7
.3:	CMPA.L	WORK(PC),A2
	BNE.S	.1
	TST.L	D7			; NEED TO CONVERT FLOAT?
	BNE.S	.4
	RTS				; NO
.4:	MOVE.L	D0,D6
	MOVEM.L	A0/A1,-(A7)
	BSR	ISOPENMATH
	MOVE.L	MATHBASE(PC),A6		; YES
	MOVE.L	D6,D0
	JSR	-36(A6)			; SPFLT
	CMP.L	#1,D7
	BEQ.S	.5
	MOVE.L	D0,D6
	MOVE.L	D7,D0
	JSR	-36(A6)
	MOVE.L	D6,D1
	EXG.L	D0,D1
	MOVE.W	#-1,IEEEPROBLEM
	JSR	-84(A6)			; SPDIV
	CLR.W	IEEEPROBLEM
.5:	MOVEM.L	(A7)+,A0/A1
	RTS
.2:	TST.L	D7
	BNE	ERROR0
	MOVE.L	D2,D7			; = FLT FACTOR
	SUBQ.L	#4,A3
	BRA.S	.3

      IEEEPROBLEM:	DC.W	0

      VALUETAB:
	DC.L	1,10,100,1000,10000,100000,1000000
	DC.L	10000000,100000000,1000000000

      PARSESTRING:
	MOVEQ	#STR,D4
	MOVE.W	D4,(A1)+
	ADDQ.L	#4,A1
	MOVE.L	A1,A4
.LOOP:	MOVE.B	(A0)+,D0
	CMP.B	#10,D0
	BEQ.S	.ER
	CMP.B	#'\',D0
	BEQ.S	.SPEC
	CMP.B	#'%',D0
	BEQ.S	.P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E.B	(A0)+,D1
	CMP.B	#58,D1
	BPL.S	.X
	CMP.B	#48,D1
	BMI.S	.X
	MOVE.B	D1,(A5)+
	BRA.S	.8
.X:	CMP.B	#']',D1
	BNE.S	.F2
	CMP.L	D5,A5
	BEQ.S	.6
	MOVE.B	#0,(A5)+
	MOVE.L	D5,A5
.L:	MOVE.B	(A5)+,(A1)+
	BNE.S	.L
	MOVE.B	#'.',-1(A1)
	MOVE.L	D5,A5
.L2:	MOVE.B	(A5)+,(A1)+
	BNE.S	.L2
	SUBQ.L	#1,A1
	BRA.S	.6
.F2:	MOVE.L	SSTR(PC),A0
	BRA.S	.6



; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The ASSEMBLER part !!!!!!!				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;

      ASM_PARSE:
	MOVE.L	#ASM_INSTAB,D2
	MOVE.L	WORK(PC),D0
	MOVE.L	D0,A2
	MOVE.L	(A2),D1
	AND.L	#$FFFFFF00,D1
	CMP.L	#'PC'*$10000,D1
	BEQ	ASM_PC
	MOVE.L	HASHVAL(PC),D7
	LSL.L	#2,D7
	ADD.L	#ASMHASH,D7
	MOVE.L	D7,A6
.LOOP:	MOVE.L	(A6),A6			; A6 _NOW_ POINTS TO ENTRY IN INSTABLE
	MOVE.L	A6,D6
	BEQ.S	.2
	MOVE.L	(A6)+,A4
	MOVE.L	D0,A2
.3:	CMPM.B	(A4)+,(A2)+
	BNE.S	.LOOP
	TST.B	-1(A2)
	BNE.S	.3
	SUB.L	D2,D6
	LSR.L	#3,D6
	ADDQ.L	#1,D6
	MOVE.L	D6,D0			; D0=1..112
	MOVE.W	#$200,D1
	CMP.B	#'.',(A0)		; SEE IF THERE'S A:     .B .W .L .S
	BNE.S	.4
	ADDQ.L	#1,A0
	MOVE.B	(A0)+,D2
	CMP.B	#'L',D2
	BNE.S	.5
	MOVE.W	#$300,D1
	BRA.S	.4
.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0,.11,0,.12,0,.13,0,.14,0,.15,0,.16,0,.17,0
	DC.L	.18,0,.19,0,.20,0,.21,0,.22,0,.23,0,.24,0,.25,0,.26,0,.27,0,.28,0,.29,0,.30,0,.31,0,.32,0
	DC.L	.33,0,.34,0,.35,0,.36,0,.37,0,.38,0,.39,0,.40,0,.41,0,.42,0,.43,0,.44,0,.45,0,.46,0
	DC.L	.47,0,.48,0,.49,0,.50,0,.51,0,.52,0,.53,0,.54,0,.55,0,.56,0,.57,0,.58,0,.59,0,.60,0
	DC.L	.61,0,.62,0,.63,0,.64,0,.65,0,.66,0,.67,0,.68,0,.69,0,.70,0,.71,0,.72,0,.73,0,.74,0
	DC.L	.75,0,.76,0,.77,0,.78,0,.79,0,.80,0,.81,0,.82,0,.83,0,.84,0,.85,0,.86,0,.87,0,.88,0
	DC.L	.89,0,.90,0,.91,0,.92,0,.93,0,.94,0,.95,0,.96,0,.97,0,.98,0,.99,0,.100,0,.101,0,.102,0
	DC.L	.103,0,.104,0,.105,0,.106,0,.107,0,.108,0,.109,0,.110,0,.111,0,.112,0
	DC.L	.113,0,.114,0,.115,0,.116,0,.117,0,.118,0,0

.1:	DC.B	"MOVE",0
.2:	DC.B	"RTS",0
.3:	DC.B	"ADD",0
.4:	DC.B	"SUB",0
.5:	DC.B	"MOVEQ",0
.6:	DC.B	"ASR",0
.7:	DC.B	"BSR",0
.8:	DC.B	"CLR",0
.9:	DC.B	"CMP",0
.10:	DC.B	"EOR",0
.11:	DC.B	"JMP",0
.12:	DC.B	"JSR",0
.13:	DC.B	"LSL",0
.14:	DC.B	"LSR",0
.15:	DC.B	"SUBQ",0
.16:	DC.B	"ADDQ",0
.17:	DC.B	"OR",0
.18:	DC.B	"ROL",0
.19:	DC.B	"ROR",0
.20:	DC.B	"AND",0
.21:	DC.B	"ASL",0
.22:	DC.B	"BTST",0
.23:	DC.B	"MOVEM",0
.24:	DC.B	"ADDA",0
.25:	DC.B	"ADDI",0
.26:	DC.B	"ADDX",0
.27:	DC.B	"CMPA",0
.28:	DC.B	"CMPM",0
.29:	DC.B	"CMPI",0
.30:	DC.B	"MOVEA",0
.31:	DC.B	"BRA",0
.32:	DC.B	"NEGX",0
.33:	DC.B	"ORI",0
.34:	DC.B	"SUBA",0
.35:	DC.B	"SUBI",0
.36:	DC.B	"SUBX",0
.37:	DC.B	"NOT",0
.38:	DC.B	"MULS",0
.39:	DC.B	"MULU",0
.40:	DC.B	"NEG",0
.41:	DC.B	"TST",0
.42:	DC.B	"SWAP",0
.43:	DC.B	"LEA",0
.44:	DC.B	"DIVS",0
.45:	DC.B	"DIVU",0
.46:	DC.B	"EXG",0
.47:	DC.B	"STOP",0
.48:	DC.B	"RTR",0
.49:	DC.B	"RTE",0
.50:	DC.B	"ABCD",0
.51:	DC.B	"SBCD",0
.52:	DC.B	"MOVEP",0
.53:	DC.B	"NOP",0
.54:	DC.B	"ROXL",0
.55:	DC.B	"ROXR",0
.56:	DC.B	"BCHG",0
.57:	DC.B	"BCLR",0
.58:	DC.B	"BSET",0
.59:	DC.B	"CHK",0
.60:	DC.B	"EXT",0
.61:	DC.B	"LINK",0
.62:	DC.B	"UNLK",0
.63:	DC.B	"NBCD",0
.64:	DC.B	"PEA",0
.65:	DC.B	"RESET",0
.66:	DC.B	"TRAP",0
.67:	DC.B	"TRAPV",0
.68:	DC.B	"BHI",0
.69:	DC.B	"BLS",0
.70:	DC.B	"BCC",0
.71:	DC.B	"BCS",0
.72:	DC.B	"BNE",0
.73:	DC.B	"BEQ",0
.74:	DC.B	"BVC",0
.75:	DC.B	"BVS",0
.76:	DC.B	"BPL",0
.77:	DC.B	"BMI",0
.78:	DC.B	"BGE",0
.79:	DC.B	"BLT",0
.80:	DC.B	"BGT",0
.81:	DC.B	"BLE",0
.82:	DC.B	"DBRA",0
.83:	DC.B	"DBF",0
.84:	DC.B	"DBT",0
.85:	DC.B	"DBHI",0
.86:	DC.B	"DBLS",0
.87:	DC.B	"DBCC",0
.88:	DC.B	"DBCS",0
.89:	DC.B	"DBNE",0
.90:	DC.B	"DBEQ",0
.91:	DC.B	"DBVC",0
.92:	DC.B	"DBVS",0
.93:	DC.B	"DBPL",0
.94:	DC.B	"DBMI",0
.95:	DC.B	"DBGE",0
.96:	DC.B	"DBLT",0
.97:	DC.B	"DBGT",0
.98:	DC.B	"DBLE",0
.99:	DC.B	"SHI",0
.100:	DC.B	"SLS",0
.101:	DC.B	"SCC",0
.102:	DC.B	"SCS",0
.103:	DC.B	"SNE",0
.104:	DC.B	"SEQ",0
.105:	DC.B	"SVC",0
.106:	DC.B	"SVS",0
.107:	DC.B	"SPL",0
.108:	DC.B	"SMI",0
.109:	DC.B	"SGE",0
.110:	DC.B	"SLT",0
.111:	DC.B	"SGT",0
.112:	DC.B	"SLE",0
.113:	DC.B	"ST",0
.114:	DC.B	"SF",0
.115:	DC.B	"ANDI",0
.116:	DC.B	"EORI",0
.117:	DC.B	"ILLEGAL",0
.118:	DC.B	"RTD",0
	EVEN

; ADDR. MODE MASKS

ASRC	= %111111111111
NASRC	= %111111111101
MMSRC	= %011111101100
PSRC	= %011111100000

DEST	= %000111111101
MDEST	= %000111111100
QDEST	= %000111111111
BTDEST	= %011111111101
MMDEST	= %011111110100

JLEA	= %011111100100

;---------------------------------------

SIZE	= 2
SIZEM	= 3
SIZEA	= 16
SIZEE	= 17
SIZEF	= 26	; FIXED SIZE

EA	= 4
EAM	= 5

COMMA	= 6

ADDSUB	= 7
IMMMQ	= 8
IMMQ	= 9

BCC	= 10
DBCC	= 11
DOEXG	= 19
CMPM	= 20
MOVEM	= 21
TRAP	= 22
MOVEP	= 23
CMP_I	= 24

ADRREG	= 12
DATAREG	= 14

SHIFT	= 13
BIT	= 15
XREG	= 18

CPUSUP	= 25

      ASM_INSJOB:
	DC.L	.1,.2,.3,.4,.5,.6,.7,.8,.9,.10,.11,.12,.13,.14,.15,.16,.17
	DC.L	.18,.19,.20,.21,.22,.23,.24,.25,.26,.27,.28,.29,.30,.31,.32
	DC.L	.33,.34,.35,.36,.37,.38,.39,.40,.41,.42,.43,.44,.45,.46
	DC.L	.47,.48,.49,.50,.51,.52,.53,.54,.55,.56,.57,.58,.59,.60
	DC.L	.61,.62,.63,.64,.65,.66,.67,.68,.69,.70,.71,.72,.73,.74
	DC.L	.75,.76,.77,.78,.79,.80,.81,.82,.83,.84,.85,.86,.87,.88
	DC.L	.89,.90,.91,.92,.93,.94,.95,.96,.97,.98,.99,.100,.101,.102
	DC.L	.103,.104,.105,.106,.107,.108,.109,.110,.111,.112
	DC.L	.113,.114,.115,.116,.117,.118,0

.1:	DC.W	$0000,SIZEM,12,EA,ASRC,0,COMMA,EAM,QDEST,6,0	; MOVE
.2:	DC.W	$4E75,0						; RTS
.3:	DC.W	$D000,SIZE,6,ADDSUB,$0600,0			; ADD
.4:	DC.W	$9000,SIZE,6,ADDSUB,$0400,0			; SUB
.5:	DC.W	$7000,IMMMQ,0					; MOVEQ
.6:	DC.W	$E000,SHIFT,$E0C0,0				; ASR
.7:	DC.W	$6100,BCC,0					; BSR
.8:	DC.W	$4200,SIZE,6,EA,DEST,0,0			; CLR
.9:	DC.W	$B000,SIZE,6,CMP_I,EA,ASRC,0,COMMA,DATAREG,9,0	; CMP
.10:	DC.W	$B100,SIZE,6,DATAREG,9,COMMA,EA,DEST,0,0	; EOR
.11:	DC.W	$4EC0,EA,JLEA,0,0				; JMP
.12:	DC.W	$4E80,EA,JLEA,0,0				; JSR
.13:	DC.W	$E108,SHIFT,$E3C0,0				; LSL
.14:	DC.W	$E008,SHIFT,$E2C0,0				; LSR
.15:	DC.W	$5100,SIZE,6,IMMQ,COMMA,EA,QDEST,0,0		; SUBQ
.16:	DC.W	$5000,SIZE,6,IMMQ,COMMA,EA,QDEST,0,0		; ADDQ
.17:	DC.W	$8000,SIZE,6,ADDSUB,0,0				; OR
.18:	DC.W	$E118,SHIFT,$E7C0,0				; ROL
.19:	DC.W	$E018,SHIFT,$E6C0,0				; ROR
.20:	DC.W	$C000,SIZE,6,ADDSUB,$0200,0			; AND
.21:	DC.W	$E100,SHIFT,$E1C0,0				; ASL
.22:	DC.W	$0100,BIT,$0800,0				; BTST
.23:	DC.W	$4880,SIZEE,MOVEM,0				; MOVEM
.24:	DC.W	$D0C0,SIZEA,EA,ASRC,0,COMMA,ADRREG,9,0		; ADDA
.25:	DC.W	$0600,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; ADDI
.26:	DC.W	$D100,SIZE,6,XREG,0				; ADDX
.27:	DC.W	$B0C0,SIZEA,EA,ASRC,0,COMMA,ADRREG,9,0		; CMPA
.28:	DC.W	$B108,SIZE,6,CMPM,0				; CMPM
.29:	DC.W	$0C00,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; CMPI
.30:	DC.W	$0040,SIZEM,12,EA,ASRC,0,COMMA,ADRREG,9,0	; MOVEA
.31:	DC.W	$6000,BCC,0					; BRA
.32:	DC.W	$4000,SIZE,6,EA,DEST,0,0			; NEGX
.33:	DC.W	$0000,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; ORI
.34:	DC.W	$90C0,SIZEA,EA,ASRC,0,COMMA,ADRREG,9,0		; SUBA
.35:	DC.W	$0400,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; SUBI
.36:	DC.W	$9100,SIZE,6,XREG,0				; SUBX
.37:	DC.W	$4600,SIZE,6,EA,DEST,0,0			; NOT
.38:	DC.W	$C1C0,SIZEF,2,EA,NASRC,0,COMMA,DATAREG,9,0	; MULS
.39:	DC.W	$C0C0,SIZEF,2,EA,NASRC,0,COMMA,DATAREG,9,0	; MULU
.40:	DC.W	$4400,SIZE,6,EA,DEST,0,0			; NEG
.41:	DC.W	$4A00,SIZE,6,EA,DEST,0,0			; TST
.42:	DC.W	$4840,DATAREG,0,0				; SWAP
.43:	DC.W	$41C0,EA,JLEA,0,COMMA,ADRREG,9,0		; LEA
.44:	DC.W	$81C0,SIZEF,2,EA,NASRC,0,COMMA,DATAREG,9,0	; DIVS
.45:	DC.W	$80C0,SIZEF,2,EA,NASRC,0,COMMA,DATAREG,9,0	; DIVU
.46:	DC.W	$C100,DOEXG,0					; EXG
.47:	DC.W	$4E72,EA,$800,-1,0				; STOP
.48:	DC.W	$4E77,0						; RTR
.49:	DC.W	$4E73,0						; RTE
.50:	DC.W	$C100,XREG,0					; ABCD
.51:	DC.W	$8100,XREG,0					; SBCD
.52:	DC.W	$0108,SIZEE,MOVEP,0				; MOVEP
.53:	DC.W	$4E71,0						; NOP
.54:	DC.W	$E110,SHIFT,$E5C0,0				; ROXL
.55:	DC.W	$E010,SHIFT,$E4C0,0				; ROXR
.56:	DC.W	$0140,BIT,$0840,0				; BCHG
.57:	DC.W	$0180,BIT,$0880,0				; BCLR
.58:	DC.W	$01C0,BIT,$08C0,0				; BSET
.59:	DC.W	$4180,EA,NASRC,0,COMMA,DATAREG,9,0		; CHK
.60:	DC.W	$4880,SIZEE,DATAREG,0,0				; EXT
.61:	DC.W	$4E50,ADRREG,0,COMMA,EA,$800,-1,0		; LINK
.62:	DC.W	$4E58,ADRREG,0,0				; UNLK
.63:	DC.W	$4800,EA,DEST,0,0				; NBCD
.64:	DC.W	$4840,EA,PSRC,0,0				; PEA
.65:	DC.W	$4E70,0						; RESET
.66:	DC.W	$4E40,TRAP,0					; TRAP
.67:	DC.W	$4E76,0						; TRAPV
.68:	DC.W	$6200,BCC,0					; Bcc
.69:	DC.W	$6300,BCC,0
.70:	DC.W	$6400,BCC,0
.71:	DC.W	$6500,BCC,0
.72:	DC.W	$6600,BCC,0
.73:	DC.W	$6700,BCC,0
.74:	DC.W	$6800,BCC,0
.75:	DC.W	$6900,BCC,0
.76:	DC.W	$6A00,BCC,0
.77:	DC.W	$6B00,BCC,0
.78:	DC.W	$6C00,BCC,0
.79:	DC.W	$6D00,BCC,0
.80:	DC.W	$6E00,BCC,0
.81:	DC.W	$6F00,BCC,0
.82:	DC.W	$51C8,DBCC,0					; DBRA
.83:	DC.W	$51C8,DBCC,0					; DBF
.84:	DC.W	$50C8,DBCC,0					; DBT
.85:	DC.W	$52C8,DBCC,0					; DBcc
.86:	DC.W	$53C8,DBCC,0
.87:	DC.W	$54C8,DBCC,0
.88:	DC.W	$55C8,DBCC,0
.89:	DC.W	$56C8,DBCC,0
.90:	DC.W	$57C8,DBCC,0
.91:	DC.W	$58C8,DBCC,0
.92:	DC.W	$59C8,DBCC,0
.93:	DC.W	$5AC8,DBCC,0
.94:	DC.W	$5BC8,DBCC,0
.95:	DC.W	$5CC8,DBCC,0
.96:	DC.W	$5DC8,DBCC,0
.97:	DC.W	$5EC8,DBCC,0
.98:	DC.W	$5FC8,DBCC,0
.99:	DC.W	$52C0,EA,DEST,0,0				; Scc
.100:	DC.W	$53C0,EA,DEST,0,0
.101:	DC.W	$54C0,EA,DEST,0,0
.102:	DC.W	$55C0,EA,DEST,0,0
.103:	DC.W	$56C0,EA,DEST,0,0
.104:	DC.W	$57C0,EA,DEST,0,0
.105:	DC.W	$58C0,EA,DEST,0,0
.106:	DC.W	$59C0,EA,DEST,0,0
.107:	DC.W	$5AC0,EA,DEST,0,0
.108:	DC.W	$5BC0,EA,DEST,0,0
.109:	DC.W	$5CC0,EA,DEST,0,0
.110:	DC.W	$5DC0,EA,DEST,0,0
.111:	DC.W	$5EC0,EA,DEST,0,0
.112:	DC.W	$5FC0,EA,DEST,0,0
.113:	DC.W	$50C0,EA,DEST,0,0				; ST
.114:	DC.W	$51C0,EA,DEST,0,0				; SF
.115:	DC.W	$0200,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; ANDI
.116:	DC.W	$0A00,SIZE,6,EA,$800,-1,COMMA,EA,DEST,0,0	; EORI
.117:	DC.W	$4AFC,0						; ILLEGAL
.118:	DC.W	$4E74,CPUSUP,%11111110,EA,$800,-1,0		; RTD=118!!!

;;ASM

      ASM_COMPILE:			; GETS INSCODE IN D7
	MOVEM.L	A2/A5,-(A7)		; JUST A3-A4 STAY PRESERVED
	MOVEQ	#0,D0
	MOVE.B	D7,D0			; D0=INSNR/ADDRESSMOD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VEP,ASM_CMPI
	DC.L	ASM_CPUSUP,ASM_SIZEFIXED

      ASM_NOTIMPL:			; 1
	BRA	ERROR1		; TEMP

      ASM_PUTSIZE:			; 2
	MOVE.L	D1,D0
	SUBQ.L	#1,D0
	MOVE.W	(A0)+,D2		; FIND OFFSET
	LSL.L	D2,D0
	OR.W	D0,(A1)			; PUT IN INS.WORD
	RTS

      ASM_PUTSIZEMOVE:			; 3
	MOVE.L	D1,D0
	CMP.W	#1,D0
	BEQ.S	.1
	BCHG	#0,D0
.1:	MOVE.W	(A0)+,D2		; FIND OFFSET
	LSL.L	D2,D0
	OR.W	D0,(A1)			; PUT IN INS.WORD
	RTS

      ASM_DOEA:				; 4
	BSR.W	ASM_GETEA
	MOVE.W	(A0)+,D2
	BTST	D0,D2
	BEQ	ERROR19
	MOVE.W	(A0)+,D2
	TST.W	D2
	BMI.S	.1			; OFFS=-1 --> NO OR.W EA
	LSL.W	D2,D3
	OR.W	D3,(A1)
.1:	RTS

      ASM_DOEAMOVEDEST:			; 5  MASK IN D3, # IN D0
	BSR.W	ASM_GETEA
	MOVE.W	(A0)+,D2
	BTST	D0,D2
	BEQ	ERROR19
	MOVE.L	D3,D0
	LSR.W	#3,D3			; UPPER BITS
	AND.W	#%111,D0		; LOWER
	LSL.W	#3,D0
	ADD.W	D3,D0			; SWAPPED REGISTER AND MODE FIELDS
	MOVE.W	(A0)+,D2
	LSL.W	D2,D0
	OR.W	D0,(A1)
	RTS

      ASM_COMMA:			; 6
	CMP.W	#COM,(A3)+
	BNE	ERROR5
	RTS

      ASM_ADDSUB:			; 7
	BSR	ASM_REGID
	MOVE.B	(A3),D2
	CMP.B	#4,D2
	BEQ.S	.1
	CMP.B	#15,D2
	BEQ.S	.3
.2:	BSR.W	ASM_GETEA		; EA --> Dx
	SKIP244
	OR.W	D3,(A1)
	BSR.S	ASM_COMMA
	CMP.B	#5,(A3)
	BEQ.S	.4
	MOVEQ	#9,D0
	BSR.W	ASM_GETDATAREG
	ADDQ.L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.W	D2,(A1)
	SKIP244
	RTS

      ASM_ANYEA:			; D7=SHIFT, res=d3.ea after shift
	BSR.W	ASM_GETEA
	LSL.W	D7,D3
	ADD.W	D3,(A1)
	RTS

      ASM_MOVEQ:			; 8
	CMP.W	#$0F00,(A3)+
	BNE	ERROR30

	MOVEM.L	A0/D1,-(A7)
	BSR	ASM_GRABVALUE
	TST.L	D0
	BEQ	ERROR30
	MOVE.L	D1,D0
	MOVEM.L	(A7)+,A0/D1

	CMP.L	#128,D0
	BPL	ERROR31
	CMP.L	#-127,D0
	BMI	ERROR31
	MOVE.B	D0,1(A1)
	BSR.W	ASM_COMMA
	MOVEQ	#9,D0
	BSR.S	ASM_GETDATAREG
	RTS

      ASM_ASQ:				; 9
	CMP.W	#$0F00,(A3)+
	BNE	ERROR30
	
	MOVEM.L	A0/D1,-(A7)
	BSR	ASM_GRABVALUE
	TST.L	D0
	BEQ	ERROR30
	MOVE.L	D1,D2
	MOVEM.L	(A7)+,A0/D1

	TST.L	D2
	BEQ	ERROR31
	CMP.L	#8,D2
	BNE.S	.1
	MOVEQ	#0,D2
.1:	MOVE.L	D2,D3
	AND.L	#$FFFFFFF8,D3
	TST.L	D3
	BNE	ERROR31
	AND.W	#%111,D2
	MOVEQ	#9,D3
	LSL.W	D3,D2
	ADD.W	D2,(A1)
	RTS

      ASM_BCC:				; 10
	CMP.W	#IDENT,(A3)+
	BNE	ERROR4
	MOVE.L	(A3)+,A2
	CMP.B	#LAB,4(A2)
	BNE	ERROR4
	BTST	#4,5(A2)		; CHECK IF METHOD
	BNE	ERROR4
	CMP.W	#1,D1			; A Bcc.S ?
	BNE.S	.1
	MOVE.B	#5,1(A1)
	BRA.S	.2
.1:	MOVE.W	#0,(A4)+
.2:	MOVE.W	10(A2),D0
	MOVEM.L	D1/A0,-(A7)
	CLR.W	NEWOP
	BSR	ADDBRANCH
	MOVEM.L	(A7)+,D1/A0
	RTS

      ASM_DBCC:				; 11
	BSR	ASM_REGID
	CMP.B	#4,(A3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,D0		; COMPLEX OR BASIC ADR.MODE
	BMI	.2
	SUB.W	#$400,D0		; LOWBYTE IS ADR.MASK, HI IS #ADR.MODE
	MOVEQ	#0,D3
	MOVE.B	D0,D3			; D3.L = ADR.MODE MASK
	LSR.W	#8,D0			; D0.W = # ADR.MODE
	CMP.W	#11,D0
	BEQ.S	.1
	CMP.W	#5,D0
	BPL	ERROR19
	CMP.W	#1,D0
	BEQ.S	.AX
.X:	RTS				; DELIVERS MASK IN D3 AND # IN D0
.AX:	CMP.W	#1,D1
	BEQ	ERROR19
	BRA.S	.X
.1:	MOVEM.L	D1/A0,-(A7)
	BSR	ASM_GRABVALUE
	MOVE.L	D1,D4
	MOVEM.L	(A7)+,D1/A0
	CMP.W	#-1,D0			; IMMEDIATE VALUE?
	BEQ	ERROR19
	MOVE.W	#%111100,D3
	MOVEQ	#11,D0
	CMP.W	#3,D1
	BNE.S	.4
	MOVE.L	D4,(A4)+		; .L #
	BRA.S	.X
.4:	CMP.W	#2,D1
	BNE.S	.5
	CHKW	D4,D5,ERROR31
	MOVE.W	D4,(A4)+		; .W #
	BRA.S	.X
.5:	CHKB	D4,D5,ERROR31
	MOVE.B	#0,(A4)+		; .B #
	MOVE.B	D4,(A4)+
	BRA.S	.X
.2:	SUBQ.L	#2,A3			; ANY OTHER MODE
	MOVEM.L	D1/A0,-(A7)
	BSR	ASM_GRABVALUE
	MOVE.L	D1,D4			; D4=VALUE
	CMP.W	#-1,D0
	BEQ	ASM_GETLABEL
	MOVEM.L	(A7)+,D1/A0
	MOVE.B	(A3),D2			; SEE WHAT'S NEXT
	CMP.B	#4,D2
	BMI.S	.6			; ABS OR INDEXED MODE
	CMP.B	#6,D2
	BNE	ERROR19
	MOVE.W	(A3)+,D3
	AND.W	#%111,D3
	OR.W	#%101000,D3
	MOVEQ	#5,D0
	MOVE.W	D4,(A4)+
	CHKW	D4,D5,ERROR31
	BRA	.X
.6:	MOVE.W	(A3),D2
	CMP.W	#17,D2
	BEQ.S	.9
	CMP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244
	AND.W	#%111,D2
	MOVEQ	#12,D4
	LSL.W	D4,D2
	ADD.W	D2,D5
.13:	MOVE.W	(A3)+,D2
	CMP.W	#26,D2
	BEQ.S	.13
	CMP.W	#18,D2
	BEQ	.14
	CMP.W	#27,D2
	BNE	ERROR0
	BSET	#11,D5
	BRA.S	.13
.14:	MOVE.W	D5,(A4)+
	RTS
.4:	CMP.W	#LIBC,D0		; LIBCALL(Ax)
	BNE	ERROR19
	ADDQ.L	#2,A3
	MOVE.W	(A3)+,(A4)+
	ADDQ.L	#8,A3
	CMP.B	#6,(A3)+
	BNE	ERROR19
	MOVE.B	(A3)+,D3
	AND.W	#%111,D3
	ADD.W	#%101000,D3
	MOVEQ	#5,D0
	RTS



; EATS INTERIM CODE FOR TRUE VALUES + CALC
; -->D0=TRUE/FALSE WAS VALUE
; -->D1=RESULT
; TRASHES: D0-D4,A0

      ASM_GRABVALUE:
	MOVEQ	#0,D1
	MOVEQ	#-1,D0			; IF D0=-1 THEN NOVALUE ELSE CODENR 
.L:	MOVEQ	#0,D2			; D2<>0 --> NEGATE
	MOVE.W	(A3)+,D3
	CMP.W	#8,D3			; '-' SIGN ?
	BNE.S	.1
	MOVEQ	#-1,D2
	MOVE.W	(A3)+,D3
	CMP.W	#VALUE,D3
	BNE.S	.X2
	BRA.S	.2
.1:	CMP.W	#VALUE,D3		; VALUE ?
	BNE.S	.X			; sizeof or exit
.2:	CMP.W	#-1,D0			; SIZEOFBACK
	BNE.S	.3
	MOVEQ	#6,D0			; ATLEAST ONE VALUE
.3:	TST.L	D2
	BEQ.S	.4
	NEG.L	(A3)
.4:	SUBQ.W	#6,D0
	LSL.W	#2,D0
	MOVE.L	.T(PC,D0.W),A0
	JMP	(A0)
.B:	MOVE.W	(A3)+,D0
	CMP.W	#11,D0
	BPL.S	.X3
	CMP.W	#7,D0
	BMI.S	.X3			; SEE IF AND/OR, ELSE QUIT
.AOB:	BRA.S	.L
.X2:	SUBQ.L	#4,A3
	CMP.W	#-1,D0
	BEQ.S	.5
	SUBQ.L	#2,A3
	RTS
.X:	CMP.W	#IOFF+50,D3		; check for sizeof
	BNE.S	.XNS
	CMP.W	#31,(A3)+		; OBJECT
	BNE	ERROR40
	MOVE.L	(A3)+,A0		; WE USE A0=OBJ
	MOVE.W	4(A0),-(A3)
	BEQ	ERROR40			; NO SIZEOF IN CONST DECL. (SOB..)
	CLR.W	-(A3)
	BRA.S	.2
.XNS:	SUBQ.L	#2,A3			; ASSUMES NEXT WORD ALREADY READ
	CMP.W	#-1,D0
	BEQ.S	.5
	SUBQ.L	#2,A3
.5:	RTS
.X3:	CMP.W	#IOFF+29,D0		; CHECK FOR AND/OR
	BEQ.S	.AO
	CMP.W	#IOFF+30,D0
	BEQ.S	.AO
	SUBQ.L	#2,A3
	RTS
.AO:	SUB.W	#IOFF+18,D0
	BRA.S	.AOB
.T:	DC.L	.MOVE,.ADD,.SUB,.MUL,.DIV,.AND,.OR
.MOVE:	MOVE.L	(A3)+,D1
	BRA	.B
.ADD:	ADD.L	(A3)+,D1
	BRA	.B
.SUB:	SUB.L	(A3)+,D1
	BRA	.B
.AND:	AND.L	(A3)+,D1
	BRA	.B
.OR:	OR.L	(A3)+,D1
	BRA	.B
.MUL:	MOVE.L	(A3)+,D4
	MOVE.L  D4,D2
	MOVE.L  D4,D3
	MULU    D1,D4
	SWAP    D3
	MULU    D1,D3
	SWAP    D3
	CLR.W   D3
	ADD.L   D3,D4
	SWAP    D1
	MULU    D1,D2
	SWAP    D2
	CLR.W   D2
	ADD.L   D2,D4
	MOVE.L	D4,D1
	BRA	.B

;.DIV:	MOVE.L	(A3)+,D4
;	MOVEQ   #32,D3
;	MOVEQ   #0,D2
;.D1:	SUB.L   D4,D2
;	BCC.B   .D2
;	ADD.L   D4,D2
;.D2:	ROXL.L  #1,D1
;	ROXL.L  #1,D2
;	DBF     D3,.D1
;	NOT.L   D1
;	BRA	.B

.DIV:	MOVE.L	D1,-(A7)
	MOVE.L	(A3)+,-(A7)
	TST.L	(A7)
	BEQ	ERROR15
	JSR	I_DIV
	ADDQ.L	#8,A7
	MOVE.L	D0,D1
	BRA	.B


;;CHIDENT

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The CheckIdents and Procs part				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


      CHECKIDENTS:
	MOVE.W	#4,CURSPOT
	MOVE.L	#IDENTHASH+4,A5
.1A:	MOVE.L	A5,A4
	ADDQ.L	#4,A5
	CMP.L	#IDENTHASH+1028,A5
	BEQ.W	.2
.1:	MOVE.L	-(A4),A4
	MOVE.L	A4,D0
	BEQ.S	.1A
	BTST	#0,5(A4)		; SEE IF UNREFERENCED
	BEQ	.UNREF
.UNRB:	MOVE.B	4(A4),D0
	TST.B	D0
	BEQ.S	.1			; WAS .4
	CMP.B	#GLOBV,D0
	BEQ.W	.3
	CMP.B	#LOCV,D0
	BNE	.5
	MOVEQ	#1,D0			; -->LOC
	MOVE.L	D0,(A4)			; PTR TO CHAR
	MOVE.L	6(A4),A3
	TST.W	10(A4)			; AN ARG OR REGVAR
	BNE.S	.1

	; no test for regalloc here.

;bra.s .pp
;.ppp: dc.l $1e0000
;.pp:
;move.l .ppp,a0
;move.l 12(a4),(a0)+
;move.l a0,.ppp

	MOVE.L	VARHEAVY(A4),D0		; if 0 then cannot be regvar
	BEQ.W	.NR

	MOVE.W	MAXREGALLOC(PC),D0
	CMP.B	3(A3),D0
	BLE.S	.RCALC

	BSET	#3,5(A4)		; MAKE IT A REGVAR!
	ADDQ.B	#1,3(A3)
	MOVE.B	3(A3),D7
	EXT.W	D7
	NEG.W	D7
	ADDQ.W	#8,D7
	MOVE.W	D7,10(A4)
	MOVE.L	26(A3),D7
	BTST	#3,2(A3)
	BNE.S	.GOTT
	GETM	A0
	MOVE.L	A0,D7
	MOVE.L	A0,26(A3)
	BSET	#3,2(A3)		; HASTABLE
	MOVEQ	#MAXREGVARS,D0		; ONE TOO MUCH: NIL TERM
.ATL:	CLR.L	(A0)+
	DBRA	D0,.ATL
	DONEM	A0
.GOTT:	MOVE.L	D7,A0
.PL:	TST.L	(A0)+
	BNE.S	.PL
	MOVE.L	A4,-(A0)		; ONE OF THE REGVARS
	BRA.W	.1

.RCALC:	BTST	#3,2(A3)
	BEQ.S	.NR
	MOVE.L	26(A3),A0		; A0=NOW FIND SMALLEST
	MOVE.L	#$7FFFFFFF,D1		; D1=SMALLEST HEAVYNESS
	MOVEQ	#0,D2
.RCS:	MOVE.L	(A0)+,D0
	BEQ.S	.RCSO
	MOVE.L	D0,A1
	CMP.L	VARHEAVY(A1),D1
	BMI.S	.RCS
	MOVE.L	VARHEAVY(A1),D1
	MOVE.L	A1,D2			; D2=BLACK SHEEP
	MOVE.L	A0,A2			; A2=PLUG BACK
	BRA.S	.RCS
.RCSO:	TST.L	D2
	BNE.S	.RCR
	INTERN	104
.RCR:	MOVE.L	D2,A0			; A0=OTHER IDENT
	MOVE.L	VARHEAVY(A0),D0
	CMP.L	VARHEAVY(A4),D0
	BPL.S	.NR
	MOVE.L	A4,-(A2)
	MOVE.W	10(A0),10(A4)
	BSET	#3,5(A4)
	BCLR	#3,5(A0)
	MOVE.W	4(A3),D0		; MAKE IT A NEW LOCOFFSET
	SUBQ.W	#4,D0
	MOVE.W	D0,10(A0)
	MOVE.W	D0,4(A3)
	BRA	.1

.NR:	MOVE.W	4(A3),D0		; MAKE IT A NEW LOCOFFSET
	SUBQ.W	#4,D0
	MOVE.W	D0,10(A4)
	MOVE.W	D0,4(A3)
	BRA.W	.1

.2:	TST.W	.UR			; EXIT. BSR FROM OTHER POINTS
	BNE	.WL
	RTS
.WL:	MOVEQ	#1,D3
	MOVE.L	#.WL2,D2
	BSR	WRITECON
	RTS
.WL2:	DC.B	10,0

.3:	GINFO	(A4),A3,A4
	MOVEQ	#1,D0			; SET FLAGS=PTR TO CHAR
	MOVE.L	D0,(A4)
	TST.W	10(A4)
	BNE	.1
	SUBQ.W	#4,NRGLOB		; -->GLOB
	MOVE.W	NRGLOB(PC),10(A4)
	BRA	.1	

.5:	CMP.W	#-4,10(A4)
	BEQ	.1
	CMP.W	#-3,10(A4)
	BEQ	.1
	CMP.W	#-2,10(A4)		; -->LAB
	BEQ.S	.6
	CMP.W	#-1,10(A4)
	BNE.S	.ERL
	CLR.L	6(A4)
.6:	MOVE.L	(A4),A1			; CHECK FOR "MAIN"
	CMP.B	#"m",(A1)
	BNE.S	.NM
	CMP.B	#"a",1(A1)
	BNE.S	.NM
	CMP.B	#"i",2(A1)
	BNE.S	.NM
	CMP.B	#"n",3(A1)
	BNE.S	.NM
	CMP.B	#0,4(A1)
	BNE.S	.NM
	MOVE.W	#1,10(A4)		; SET LAB MAIN
	MOVE.L	6(A4),A1
	TST.W	(A1)			; MAIN --> NO ARGS
	BNE	ERROR23
	BRA	.1
.NM:	MOVE.W	CURLABNAME+2(PC),10(A4)
	ADDQ.L	#1,CURLABNAME
	BSR	CHECKLABBUF
	BRA	.1
.ERL:	BSR	.2
	BRA	ERROR14

.UNREF:	BTST	#1,5(A4)
	BNE	.UNRB
	TST.W	.UR
	BNE.S	.12
	MOVE.L	#.13,D2
	MOVE.L	#.14,D3
	SUB.L	D2,D3
	BSR	WRITECON
	BRA.S	.16
.12:	MOVEQ	#1,D3
	MOVE.L	#.14,D2
	BSR	WRITECON
.16:	MOVE.L	(A4),A0
.15:	TST.B	(A0)+
	BNE.S	.15
	SUB.L	(A4),A0
	SUBQ.L	#1,A0
	MOVE.L	A0,D3
	MOVE.L	(A4),D2
	BSR	WRITECON
	MOVE.W	#-1,.UR
	BRA	.UNRB
.13:	DC.B	"UNREFERENCED: "
.14:	DC.B	","
	EVEN
.UR:	DC.W	0			; MESSY DONE?

      NRGLOB:
	DC.W	GLOBOFF			; HASTABE initialized

      CHECKLABBUF:
	SUBQ.W	#1,.1
	BEQ.S	.2
	RTS
.2:	MOVE.L	D0,-(A7)
	MOVE.W	#25,.1
	MOVE.L	CURLABNAME(PC),D0
	LSL.L	#2,D0
	ADD.L	LABM+8(PC),D0
	MOVE.L	D0,LABM
	BSR	REALLOC6
	MOVE.L	(A7)+,D0
	RTS
.1:	DC.W	10

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The Error, Message And DosSupport Part			;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;

      ERROR:				; D0=ERRORNR.
	BSR	PREPMACROERROR
	MOVE.W	#5,CURSPOT
	MOVE.L	A0,SAVEDREGS
	MOVE.L	A3,SAVEDREGS+4
	MOVE.L	D0,D7
	BSR	SHOWIDENT
	MOVE.L	#ERTEXT,D2
	MOVE.L	#ERTEXTEND-ERTEXT,D3
	BSR.W	WRITECON		; WRITE 'ERROR: '
	MOVE.W	D7,D0
	ASL.W	#2,D0
	LEA	ERRORTAB(PC),A0
	MOVE.L	0(A0,D0.W),D2		; FIND ERSTRING
	MOVE.L	D2,A0
.5:	TST.B	(A0)+
	BNE	.5
	SUBQ.L	#1,A0
	MOVE.L	A0,D3
	SUB.L	D2,D3
	BSR.W	WRITECON		; WRITE 'YO SYNTAX SUCKS'
	BSR.W	WRITELN
	MOVE.W	LINENUM2(PC),D4
	BNE.S	.6
	MOVE.W	LINENUM,D4
	CMP.W	#-1,D4
	BEQ.S	.4
.6:	MOVE.W	D4,RETERROR
	MOVE.L	ECODE(PC),A0
	MOVE.W	D4,D2
	BEQ.S	.1
	BMI.S	.1
	SUBQ.W	#1,D2
	MOVEQ	#10,D0
.L:	CMP.B	(A0)+,D0		; FIND LINE
	BNE.S	.L
	DBRA	D2,.L
.1:
	BSR	RECONSTRUCT		; !!!!

	MOVE.L	A0,D0			; BACKUP A0
.1B:	CMPI.B	#0,(A0)			; find eol
	BEQ.S	.2
	CMPI.B	#10,(A0)+
	BNE.S	.1B
.3:	CLR.B	-(A0)
	MOVE.L	A0,D3
	SUB.L	D0,D3
	LEA	ERARGS(PC),A1
	MOVE.L	D0,4(A1)
	LEA	ERLINE(PC),A0
	ADDQ.W	#1,D4
	EXT.L	D4
	MOVE.L	D4,(A1)
	BSR.W	WRITEFORMAT
.4:	MOVE.L	ERROROBJ(PC),D0
	BEQ.S	.X
	LEA	ERARGS(PC),A1		; WRITE 'WITH: '
	MOVE.L	D0,(A1)
	LEA	EROBJLINE(PC),A0
	BSR	WRITEFORMAT
.X:	BSR	PREPWRITEMACROLINE
	RTS
.2:	ADDQ.L	#1,A0
	BRA.S	.3

      RECONSTRUCT:			; GETS START LINE IN A0, RETURNS NEW
	MOVE.L	A0,LINEOFF		; ADR. IN A0, TRASHES NOTHING
	MOVEM.L	D0-D4/A1-A4,-(A7)
	MOVE.W	ERRWHERE(PC),D0
	BEQ	.EXIT
	CMP.W	#1,D0
	BEQ.S	.LA0
	BSR	CONSTRUCT
	TST.L	D0
	BEQ.S	.GOTP
	BRA	.EXIT
.LA0:	MOVE.L	SAVEDREGS(PC),ERPOINT	; ERROR IS IN LEX
.GOTP:	MOVE.L	ERPOINT(PC),D0
	MOVE.L	ECODE,D1
	SUB.L	D0,D1
	NEG.L	D1
	MOVE.L	D1,BYTEOFF
	MOVE.L	LINEOFF(PC),A0
	MOVE.L	ERBUF(PC),A1
	MOVEQ	#0,D1			; 0=SEARCH,1=ON,2=AFTER ERPOS
.1:	CMP.L	A0,D0
	BNE.S	.2
	LEA	.ON(PC),A2		; START OF ERPOS
.3:	MOVE.B	(A2)+,(A1)+
	BNE.S	.3
	SUBQ.L	#1,A1
	MOVEQ	#1,D1
.2:	MOVE.B	(A0)+,D2		; READ BYTE
	BEQ.S	.NL			; NL ?
	CMP.B	#10,D2
	BEQ.S	.NL			; NL ?
	MOVE.B	D2,(A1)+
	CMP.W	#1,D1
	BNE.S	.1
	MOVEQ	#2,D1			; END OF ERPOS
	CMP.B	#9,-1(A1)
	BNE.S	.NT
	MOVE.B	#" ",-1(A1)		; A TAB? --> EXTRA SPACE
	MOVE.B	#9,(A1)+
.NT:	LEA	.OFF(PC),A2
.5:	MOVE.B	(A2)+,(A1)+
	BNE.S	.5
	SUBQ.L	#1,A1
	BRA.S	.1
.NL:	CMP.W	#1,D1
	BMI.S	.NL0
	BEQ.S	.NL1
	CLR.B	(A1)+			; END OF STRING + ER
	MOVE.L	ERBUF(PC),LINEOFF
	BRA.S	.EXIT
.NL0:	MOVE.L	ERBUF(PC),A1		; NEXT STRING
	BRA.S	.1
.NL1:	MOVE.B	#" ",(A1)+		; END OF STRING
	LEA	.OFF(PC),A2
.4:	MOVE.B	(A2)+,(A1)+
	BNE.S	.4
	MOVE.L	ERBUF(PC),LINEOFF
.EXIT:	MOVEM.L	(A7)+,D0-D4/A1-A4
	MOVE.L	LINEOFF(PC),A0
	RTS
.ON:	DC.B	27,"[43;32m",0
.OFF:	DC.B	27,"[0m",0

LINEOFF:	DC.L	0
ERRWHERE:	DC.W	0		; 0=?, 1=A0.ASC, 2==A3.INT
INTERMED:	DC.L	0
ERPOINT:	DC.L	0
SAVEDREGS:	DC.L	0,0		; A0,A3
XTRALINES:	DC.W	0
ERBUF:		DC.L	ESTACKBUF
BYTEOFF:	DC.L	0

      CONSTRUCT:
	MOVE.L	SAVEDREGS+4(PC),D3	; D3=INTERIM ERPOINT
	BTST	#0,D3
	BEQ.S	.EVEN
	ADDQ.L	#1,D3
.EVEN:	MOVE.L	INTERMED(PC),A3		; A3=INTERIM START
	MOVE.L	LINEOFF(PC),A0		; A0=ASCII START
.LOOP:	CMP.L	D3,A3
	BPL	.EXIT
.EAT:	MOVE.B	(A0)+,D0		; COLLECT WHITESPACE
	BEQ	.ERR
	CMP.B	#" ",D0
	BEQ.S	.EAT
	CMP.B	#9,D0
	BEQ.S	.EAT
	CMP.B	#10,D0
	BEQ.S	.EAT
	CMP.B	#"-",D0
	BEQ.S	.SCOM
	CMP.B	#"/",D0
	BNE.S	.TOKEN
	CMP.B	#"*",(A0)
	BNE.S	.TOKEN
	ADDQ.L	#1,A0
	MOVEQ	#1,D1			; COMMENT COUNT
	MOV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RETURNOUT,D2
	BSR.S	WRITECON
	RTS

      WRITEFORMAT:			; A0=STRING, A1=DATA
	MOVE.L	#PRINTBUF,A3		; USES D0-D3/A0-A3/A6
	LEA	.1(PC),A2		; TRASH DIRNAME BUF....
	MOVE.L	A3,D2
	MOVE.L	4.W,A6
	JSR	-522(A6)
	MOVE.L	D2,A0
.2:	TST.B	(A0)+
	BNE.S	.2
	SUBQ.L	#1,A0
	MOVE.L	A0,D3
	SUB.L	D2,D3
	BSR	WRITECON
	RTS
.1:	MOVE.B	D0,(A3)+
	RTS

      WRITELINENUM:
	MOVE.W	LINENUM(PC),D7
	CMP.W	LINEWRITE(PC),D7
	BPL.S	.1
	RTS
.1:	BTST	#7,CODEPREFS+2
	BNE.S	.11
	MOVEM.L	D0-D3/A0-A3,-(A7)
	LEA	.2(PC),A0
	LEA	.3(PC),A1
	MOVE.W	LINEWRITE(PC),D0
	EXT.L	D0
	MOVE.L	D0,(A1)
	BSR	WRITEFORMAT
	ADD.W	#100,LINEWRITE
	MOVEM.L	(A7)+,D0-D3/A0-A3
.11:	RTS
.2:	DC.B	'%ld',13,0
	EVEN
.3:	DC.L	0

      NOERROR:
	ADDQ.W	#1,ASSLINE
	BTST	#4,CODEPREFS+3
	BNE.S	.X
	BTST	#3,CODEPREFS+3
	BEQ.S	.3
	BCLR	#0,WARNINGS+3
.3:	MOVE.L	WARNINGS(PC),D7
	MOVEQ	#0,D6			; BITCOUNT
	LEA	WARNINGTAB(PC),A2
.L:	CMP.W	#32,D6
	BEQ.S	.X
	BTST	D6,D7
	BEQ.S	.1
	MOVEQ	#9,D3
	MOVE.L	#WARNINGMESSY,D2
	BSR	WRITECON
	MOVE.L	D6,D5
	LSL.L	#2,D5
	MOVE.L	WARNINGTAB(PC,D5.L),D2
	MOVE.L	D2,A0

;.2:	TST.B	(A0)+
;	BNE.S	.2
;	SUBQ.L	#1,A0
;	MOVE.L	A0,D3
;	SUB.L	D2,D3
;	BSR	WRITECON

	MOVEM.L	D0-D3/A0-A3,-(A7)
	LEA	ASSLINE(PC),A1
	BSR	WRITEFORMAT
	MOVEM.L	(A7)+,D0-D3/A0-A3

	BSR	WRITELN

.1:	ADDQ.L	#1,D6
	BRA.S	.L
.X:	BTST	#7,CODEPREFS+2
	BNE.S	.11
	MOVE.L	#NOERMESSAGE,D2
	MOVE.L	#NEMEND-NOERMESSAGE,D3
	BSR	WRITECON
	BSR	WRITELN
.11:	RTS

      WARNINGMESSY:
	DC.B	"WARNING: ",0		; 9

      WARNINGTAB:
	DC.L	.1,.2,.3,.4,.5,.6,.7,.8,.9

.1:	DC.B	"A4/A5 used in inline assembly",0
.2:	DC.B	"keep an eye on your stacksize",0
.3:	DC.B	"stack is definitely too small",0
.4:	DC.B	'suspicious use of "=" in void expression(s). (line %d)',0
.5:	DC.B	"module changed OPT settings",0
.6:	DC.B	"variable used as function",0
.7:	DC.B	"code outside PROCs",0
.8:	DC.B	" ",0
.9:	DC.B	" ",0
	EVEN

PORTCOOKIE	= $DEADBEEF

      CACHENAME:	DC.B	"EmoduleCache",0,0
      PORTADR:		DC.L	0	; MUST BE NIL FOR NO_CACHE
      CACHENAMESTART:	DC.L	0
      CACHENAMEEND:	DC.L	0

      FLUSHMODULE:			; D0=MODPTR
	MOVEM.L	D1/D2/D3/A0-A3/A6,-(A7)
	MOVE.L	D0,D1			; D1=MODNAME
	MOVE.L	D1,A0
.SL:	MOVE.B	(A0)+,D2		; CHOMP OFF PATH
	CMP.B	#":",D2
	BEQ.S	.SP
	CMP.B	#"/",D2
	BEQ.S	.SP
	TST.B	D2
	BNE.S	.SL
	MOVE.L	PORTADR(PC),D0
	BEQ.S	.X
	MOVE.L	D0,A0
	LEA	38(A0),A0		; A1=PREV, A0=CUR
.L:	MOVE.L	A0,A1
	MOVE.L	(A0),A0
	MOVE.L	A0,D0
	BEQ.S	.X
	MOVE.L	8(A0),D2
	MOVE.L	D2,A2
.SL2:	MOVE.B	(A2)+,D3		; CHOMP OFF PATH HERE TOO
	CMP.B	#":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D0,A3			; TEMP
	ADD.L	#50,D0
	ADD.L	D3,D0
	MOVE.L	D0,D2
	MOVEQ	#0,D1
	MOVE.L	4.W,A6
	JSR	-198(A6)
	TST.L	D0
	BEQ.S	.EXX
	MOVE.L	A3,D1
	MOVE.L	D0,A0
	MOVE.L	PORTADR(PC),A3		; LINK INTO LIST
	MOVE.L	38(A3),(A0)
	MOVE.L	A0,38(A3)
	MOVE.L	D2,4(A0)		; SET MEM-LEN
	MOVE.L	D3,12(A0)
	LEA	32(A0),A3
	MOVE.L	A3,8(A0)		; SET NAME
.L:	MOVE.B	(A2)+,D2
	CMP.B	#"A",D2			; LOWERCASE'M
	BMI.S	.C
	CMP.B	#"Z"+1,D2
	BPL.S	.C
	ADD.B	#32,D2
.C:	MOVE.B	D2,(A3)+
	BNE.S	.L
	MOVE.L	A3,D3
	BTST	#0,D3
	BEQ.S	.S
	ADDQ.L	#1,A3
.S:	MOVE.L	A3,16(A0)
	MOVE.L	D1,20(A0)
	MOVE.L	A3,D0
.EXX:	MOVEM.L	(A7)+,D1-D3/A0-A3/A6
	RTS

      GETCACHE:
	BTST	#1,CODEPREFS+1		; IF OPT=-c THEN DON'T USE CACHE
	BEQ.S	.1
	RTS
.1:	MOVE.L	4.W,A6
	JSR	-$84(A6)		; FORBID
	LEA	CACHENAME(PC),A1
	JSR	-390(A6)		; FINDPORT
	TST.L	D0
	BNE.S	.FOUND
	MOVEQ	#1,D1			; get ourselves mem for port
	SWAP	D1
	MOVEQ	#100,D0
	MOVE.L	4.W,A6
	JSR	-198(A6)
	TST.L	D0
	BEQ.S	.FAIL
	MOVE.L	D0,A5			; A5=MESSAGEPORT
	LEA	CACHENAME(PC),A0
	LEA	50(A5),A1
	MOVE.L	A1,D0
.L:	MOVE.B	(A0)+,(A1)+
	BNE.S	.L
	MOVE.L	D0,10(A5)
	MOVE.B	#4,8(A5)		; this is a msgport
	MOVE.B	#1,9(A5)		; pri = 1
	MOVE.B	#2,14(A5)		; pa_ignore
	MOVE.L	#PORTCOOKIE,34(A5)
	MOVE.L	A5,A1
	JSR	-354(A6)
	BRA.S	.PORT
.FOUND:	MOVE.L	D0,A5
.PORT:	MOVE.L	#DEBUGDATA,42(A5)
	TST.W	46(A5)
	BNE.S	.FAIL
	CMP.L	#PORTCOOKIE,34(A5)	; HERE WE HAVE VALID PORT IN A5
	BNE.S	.FAIL
	MOVE.L	A5,PORTADR
	MOVE.W	#1,46(A5)
.FAIL:	JSR	-$8A(A6)		; PERMIT
	RTS

      UNLOCKCACHE:
	MOVE.L	4.W,A6
	JSR	-$84(A6)		; FORBID
	MOVE.L	PORTADR(PC),D0
	BEQ.S	.1
	MOVE.L	D0,A0
	CLR.W	46(A0)
.1:	JSR	-$8A(A6)		; PERMIT
	RTS

;     RESCHECK:				; PRESERVES ALL REGS IF OK
;	TST.W	.1
;	BNE.S	.X
;	MOVE.W	#-1,.1
;	RTS
;.1:	DC.W	0
;.X:	MOVE.L	INITSTACK,A7		; EMERGENCY EXIT
;	MOVEQ	#20,D0
;	RTS

;;INIT

      INITALL:
;	BSR.S	RESCHECK
	MOVE.W	#6,CURSPOT
	MOVE.L	D0,ARGLEN		; SAVE THESE 1ST
	MOVE.L	A0,ARGADR
	MOVE.L	4.W,A6
	MOVE.W	20(A6),KICKVERS

	LEA	INITDOS,A1
	MOVEQ	#0,D0
	JSR	-552(A6)		; OPEN DOS
	MOVE.L	D0,DOSBASE
	BEQ	LEAVEFAST

	MOVE.L	D0,A6
	JSR	-60(A6)			; GET STDIO
	MOVE.L	D0,STOUT
	TST.L	D0
	BEQ	NOSTDOUT

;	here start with cl-arg-parse

	CMP.W	#37,KICKVERS
	BPL	READARGS

	MOVE.L	ARGLEN(PC),D0
	MOVE.L	ARGADR(PC),A0

	CLR.W	MAXREGALLOC
	MOVE.L	CODEPREFS(PC),D5
	CMP.B	#'-',(A0)
	BNE	.1
	SUBQ.L	#1,D0
	ADDQ.L	#1,A0
	MOVEQ	#0,D2
.2:	MOVE.B	(A0)+,D2
	SU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N, A1=ENDOFSTR
      BACKRA:

	CMP.B	#"e",-1(A1)
	BEQ.S	.4
	CMP.B	#"E",-1(A1)
	BNE.S	.3
.4:	CMP.B	#".",-2(A1)
	BNE.S	.3
	MOVE.L	ARGLEN(PC),D2
	SUBQ.L	#2,D2
	BMI.S	.3
	MOVE.L	D2,ARGLEN
	SUBQ.L	#2,A1

.3:	MOVE.B	#0,(A1)+
	MOVE.W	#0,CONOUT
	BSR.W	SHOWIDENT
	BRA.S	GOTOUT
      NOSTDOUT:				; WE'VE GOT NO STDIO
      	MOVEQ	#0,D0
      	MOVE.L	D0,ARGLEN		; SIMULATE NO ARGS
      	SWAP	D0
      	MOVE.B	D0,NAMEBUF
	BSR	OPENCON			; WE NEED A CON: AS STDIO
	BSR.S	SHOWIDENT
	MOVE.W	#-1,CONOUT
	BSET	#2,CODEPREFS+1
      GOTOUT:				; WE GOT STDIO, SO START PRINTING
	BSR	TOFRONT			; PUT WBTOFRONT
	BSR	INSTALLHANDLER
	MOVE.W	CONOUT(PC),D0
	CMP.W	#0,D0
	BNE.S	ERNOARGS
	BSR	OPENFILE
	RTS
      ERNOARGS:
	RTS

      SHOWIDENT:
	TST.W	.2
	BNE.S	.1
	BTST	#7,CODEPREFS+2
	BNE.S	.1
	MOVE.L	#TITLE,D2
	MOVE.L	#TITLEEND-TITLE,D3
	BSR	WRITECON		; SHOW OUR REAL IDENTITY
	MOVE.W	#-1,.2
.1:	RTS
.2:	DC.W	0

      ISOPENMATH:
	TST.L	MATHBASE
	BNE.S	.1
	;MOVEM.L	D0-D1/A0-A1,-(A7)
	LEA	INITMATH,A1
	MOVEQ	#0,D0
	MOVE.L	4.W,A6
	JSR	-552(A6)		; OPEN MATH
	MOVE.L	D0,MATHBASE
	;MOVEM.L	(A7)+,D0-D1/A0-A1
	TST.L	MATHBASE
	BEQ	ERROR58
.1:	RTS

      READARGS:
	MOVE.L	DOSBASE,A6
	MOVE.L	#TEMPLATE,D1
	MOVE.L	#.SRC,D2
	MOVE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ARS,MAXREGALLOC
.12:	MOVE.L	.ABUF(PC),D0
	BEQ.S	.13
	MOVE.L	D0,A0
	MOVE.L	(A0),D0
	CMP.L	#1,D0
	BMI.S	.13
	CMP.L	#1001,D0
	BPL.S	.13
	MULU	#400,D0			; SEE PARSE "-"
	LSL.L	#8,D0
	ADD.L	D0,BUFADD
.13:
	MOVE.L	D6,CODEPREFS

	MOVE.L	D7,D1
	JSR	-$35A(A6)
	MOVE.L	D5,A1
	BRA	BACKRA

.SRC:	DC.L	0
.REG:	DC.L	0
.LARGE:	DC.L	0
.SYM:	DC.L	0
.NOWRN:	DC.L	0
.QUIET:	DC.L	0
.ASM:	DC.L	0
.ERRL:	DC.L	0
.ERRB:	DC.L	0
.SBUF:	DC.L	0
.ABUF:	DC.L	0
.ICA:	DC.L	0
.HOLD:	DC.L	0
.WB:	DC.L	0
.LINED:	DC.L	0
.OPTI:	DC.L	0
.DBG:	DC.L	0
.NIL:	DC.L	0

	TEMPLATE:	DC.B	'SOURCE/A,REG=NUMREGALLOC/N/K,LARGE/S,'
			DC.B	'SYM=SYMBOLHUNK/S,NOWARN/S,'
			DC.B	'QUIET/S,ASM/S,ERRLINE/S,ERRBYTE/S,'
			DC.B	'SHOWBUF/S,ADDBUF/N/K,IGNORECACHE/S,'
			DC.B	'HOLD/S,WB/S,LINEDEBUG/S,OPTI/S,'
			DC.B	'DEBUG/S,NILCHECK/S',0
			EVEN
	KICKVERS:	DC.W	0
	ARGLEN:		DC.L	0	; =0 IF NO ARGS
	ARGADR:		DC.L	0
	HANDLE:		DC.L	0
	LINEWRITE:	DC.W	0
	DOSBASE:	DC.L	0
	MATHBASE:	DC.L	0
	KILLFLAG:	DC.W	0	; IF -1 THEN KILL EXE
	STOUT:		DC.L	0
	CONOUT:		DC.W	0	; FLAG: true->STDOUT=CON:,asmone
	CDLOCK:		DC.L	0
	GOTLOCK:	DC.W	0
	RETERROR:	DC.W	-1
	ASSLINE:	DC.W	0	; LINENUM OF LAST A=1
	ERARGS:		DC.L	0,0,0,0,0
	RETURNOUT:	DC.B	10
	ERTEXT:		DC.B	'ERROR: '
	ERTEXTEND:
	ERLINE:		DC.B	'LINE %ld: %s',10,0
	EROBJLINE:	DC.B	'WITH: %s',10,0
			DC.B	'$VER:'
	TITLE:		DC.B	'Amiga',160,'E',160,'Compiler'
			DC.B	'/Assembler/Linker/PP',160,'v3.3a',160
			IF	DEMOVERS=0
			DC.B	'registered'
			ELSE
			DC.B	'demo'
			ENDIF
			DC.B	160,'(c)',160,'''91-97',160,'Wouter',10
	TITLEEND:	DC.B	0
			EVEN

      SPLITNAME:
	MOVE.L	#NAMEBUF,A0
	MOVE.L	A0,A1		; A1=BEGBUF
	LOWER	A0,D0
.L:	CMPA.L	A0,A1
	BEQ.S	.D
	MOVEQ	#0,D0
	MOVE.B	-(A0),D0
	CMP.W	#":",D0
	BEQ.S	.DM
	CMP.W	#"/",D0
	BEQ.S	.DM
	BRA.S	.L
.DM:	ADDQ.L	#1,A0		; A0=MIDBUF
.D:	MOVE.L	#SRCDIRBUF,A2	; A2=DIRBUF
	MOVE.L	A2,A4
	MOVE.L	A1,A3
.L1:	CMPA.L	A3,A0
	BEQ.S	.E1
	MOVE.B	(A3)+,(A4)+
	BRA.S	.L1
.E1:	CLR.B	(A4)+
	MOVE.L	A0,A3
	MOVE.L	A1,A4
.L2:	MOVE.B	(A3)+,(A4)+
	BNE.S	.L2
	MOVE.L	ARGLEN(PC),D0
	ADD.L	A1,D0
	SUB.L	A0,D0
	MOVE.L	D0,ARGLEN
	TST.B	(A2)
	BEQ.S	.1
	MOVE.L	DOSBASE(PC),A6
	MOVE.L	A2,D1
	MOVEQ	#-2,D2
	JSR	-$54(A6)	; LOCK
	BEQ.S	.1
	MOVE.L	#FIB,A2
	MOVE.L	A2,D2
	MOVE.L	D0,D1
	MOVE.L	D0,D3
	JSR	-$66(A6)
	TST.L	4(A2)		; IS IT A DIR?
	BMI.S	.2
	MOVE.L	D3,D1
	JSR	-$7E(A6)	; CURRENTDIR
	MOVE.L	D0,CDLOCK
	MOVE.W	#-1,GOTLOCK
.1:	RTS
.2:	MOVE.L	D3,D1
	JSR	-$5A(A6)	; UNLOCK
	RTS

      CLOSELOCK:
	TST.W	GOTLOCK
	BEQ.S	.1
	MOVE.L	DOSBASE(PC),A6
	MOVE.L	CDLOCK(PC),D1
	JSR	-$7E(A6)	; CURRENTDIR
	MOVE.L	D0,D1
	JSR	-$5A(A6)	; UNLOCK
.1:	RTS

      OPENFILE:
	BSR	SPLITNAME
	MOVE.W	#7,CURSPOT
	MOVE.L	#NAMEBUF,A2		; FIX '.E'
	ADD.L	ARGLEN(PC),A2		; A2=MIDARG
	MOVE.B	#'.',(A2)
	MOVE.B	#'e',1(A2)
	MOVE.B	#0,2(A2)
	MOVE.L	#NAMEBUF,D0
	BSR.W	FILELENGTH		; GET FILELENGTH
	CMP.L	#1,D0
	BMI	ERROR16
	MOVE.L	D0,D7			; D7=SIZE (-4)
	ADDQ.L	#4,D0			; FIX MEM
	BSR	NEW
	TST.L	D0
	BEQ	ERROR38
	MOVE.L	D0,D6			; D6=ADR
	MOVE.L	DOSBASE(PC),A6		; OPEN FILE
	MOVE.L	#NAMEBUF,D1
	MOVE.L	#1005,D2
	JSR	-30(A6)
	MOVE.B	#0,(A2)
	MOVE.L	D0,HANDLE
	BEQ	ERROR16
	MOVE.L	D6,D4			; READ DATA
	MOVE.L	D7,D3
	MOVE.L	D4,D2
	MOVE.L	HANDLE(PC),D1
	MOVE.L	DOSBASE(PC),A6
	ADDQ.L	#1,D4
	JSR	-42(A6)
	MOVE.L	D0,D4
	MOVE.L	DOSBASE(PC),A6		; CLOSE IT
	MOVE.L	HANDLE(PC),D1
	JSR	-36(A6)
	CMP.L	D4,D7
	BNE	ERROR16
	ADD.L	D6,D4
	MOVE.L	D4,ENDECODE		; SET POINTERS
	MOVE.L	D4,A0
	MOVE.B	#10,(A0)+
	MOVE.B	#10,(A0)+
	MOVE.L	D6,D4
	MOVE.L	D4,CURECODE
	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,D5
.L:	LEA	.MES(PC),A0
	LEA	ERARGS(PC),A1
	MOVE.L	(A5)+,A4
	MOVE.L	(A5)+,(A1)		; bufname
	MOVE.L	(A4),D0
	SUB.L	8(A4),D0
	MOVE.L	D0,4(A1)		; used
	MOVE.L	12(A4),D1
	MOVE.L	D1,12(A1)		; maxbuf
	LSR.L	#8,D0
	LSR.L	#8,D1
	MULU	#100,D0
	DIVU	D1,D0
	AND.L	#$FFFF,D0
	ADDQ.L	#1,D0
	MOVE.L	D0,8(A1)		; percentage
	MOVE.L	(A5)+,D0
	LSL.L	#2,D0
	MOVE.L	.T(PC,D0.L),16(A1)	; MAX/DYN/EXP
	BSR	WRITEFORMAT
	DBRA	D5,.L
	RTS
.MES:	DC.B	'%s buffer used %ld (%ld%%) of %ld (%s).',10,0
	EVEN
.T:	DC.L	.1,.2,.3
.1:	DC.B	'fixed',0
.2:	DC.B	'reallocatable',0
.3:	DC.B	'expandable',0
	EVEN

      WRITEEXE:
	MOVE.W	#8,CURSPOT
	TST.L	ARGLEN
	BNE.S	.1
	RTS
.1:	TSTMOD
	BNE	WRITEMODULE
	MOVE.L	#NAMEBUF,D1
	MOVE.L	LIBINFO(PC),D0
	BEQ.S	.NL
	MOVE.L	D0,A0
	MOVE.L	(A0),D1
.NL:	MOVE.L	#1006,D2
	MOVE.L	DOSBASE(PC),A6
	JSR	-30(A6)
	MOVE.L	D0,HANDLE
	BEQ	ERROR17

	MOVE.L	CODEAMOUNT(PC),D4
	LSR.L	#2,D4
	MOVE.L	D4,CODESIZE
	MOVE.L	D4,CODESIZE2

	MOVE.L	#HUNK,D2
	MOVEQ	#32,D3
	BSR	WRITEFILE

	MOVE.L	ACODE(PC),D2
	MOVE.L	CURACODE(PC),D3
	SUB.L	D2,D3
	BSR	WRITEFILE

	MOVE.L	LINEBUF(PC),D2
	BEQ.S	.2
	MOVE.L	LINEBUFCUR(PC),D3
	CMP.L	LINEBUFCURSTART(PC),D3	; ONLY IF LINEDEBUGSIZE<>0
	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MACROS

	MOVE.L	#.2,D2			; WRITE END
	MOVEQ	#2,D3
	BSR	WRITEFILE

	MOVE.L	DOSBASE(PC),A6
	MOVE.L	HANDLE(PC),D1
	JSR	-36(A6)

	MOVE.L	#NAMEBUF,D0		; FLUSH THE MODULE
	MOVE.L	D0,A0
	LOWER	A0,D1

	BSR	FLUSHMODULE

	RTS
.1:	DC.L	"EMOD"			; HEADER
.2:	DC.W	0			; END


      WRITEFILE:			; D2=ADR,D3=LEN
	MOVE.L	HANDLE(PC),D1
	MOVE.L	DOSBASE(PC),A6
	JSR	-48(A6)
	RTS

      CODEAMOUNT:	DC.L	0

      HUNK:
	DC.L	1011			; hunkheader
	DC.L	0,1,0,0 		; endofnames,1hunk,firsthunkno,lasthn
      CODESIZE:
	DC.L	0			; CODESIZE/4 hunklentab
	DC.L	1001			; hunkcode
      CODESIZE2:
	DC.L	0			; CODESIZE/4
      ENDHUNK:
	DC.L	1010			; last


      WRITEEVARONLY:
	MOVE.L	#ESTACKBUF,A4		; A4=BUF,D4=BEGIN
	MOVE.L	A4,D4
	MOVE.L	#$3F1,(A4)+		; HUNK_DEBUG
	CLR.L	(A4)+			; HUNKLEN
	CLR.L	(A4)+
	MOVE.L	#"EVAR",(A4)+		; "EVAR"
	LEA	DBLIST(PC),A5		; A5=LIST
	TST.L	(A5)
	BEQ.W	.OUT
.L:	MOVE.L	(A5),D0
	BEQ.S	.X
	MOVE.L	D0,A5
	MOVEQ	#0,D3			; D3=WLEN
	CMP.W	#4,4(A5)
	BNE.S	.1
	MOVE.W	6(A5),D3
	LSR.W	#1,D3
	ADDQ.L	#1,D3
	BRA.S	.2
.1:	MOVE.W	8(A5),D3
	ADDQ.L	#2,D3
.2:	LEA	4(A5),A0
.CL:	MOVE.W	(A0)+,(A4)+
	DBRA	D3,.CL
	CHESTB	A4,D0,3,ERROR37

	CMP.W	#4,4(A5)
	BNE.S	.NSELF
	CMP.W	#5,(A0)
	BNE.S	.NSELF
	MOVE.L	(A0)+,(A4)+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0
	BCLR	#0,D0
	MOVE.L	D0,A5
	SUB.L	A1,D0
	MOVE.W	D0,-2(A1)
	MOVE.L	M_PROC(A0),A1		; (A1=PROC)
	MOVE.W	(A1),(A5)+		; NARGS:INT
	
	MOVE.L	6(A1),D0		; LISTLEN:INT, LIST:LONGS
	BEQ.S	.DZERO
	MOVE.L	D0,A2
	MOVE.W	(A2)+,D0
	MOVE.W	D0,(A5)+
	BEQ.S	.DDONE
	SUBQ.W	#1,D0
.DEFAL:	MOVE.L	(A2)+,(A5)+
	DBRA	D0,.DEFAL
	BRA.S	.DDONE
.DZERO:	CLR.W	(A5)+
.DDONE:
	BRA.S	.MEL
.MEX:	MOVE.W	#-1,(A5)+		; END -> TYP+FL = -1

	LEA	OACC(A3),A0
.AL:	MOVE.L	(A0),D0			; LISTOF CODE:OFF, TYP:INT
	BEQ.S	.AX
	MOVE.L	D0,A0
	MOVE.W	8(A0),(A5)+
	MOVE.L	4(A0),D0
	SUB.L	ACODE(PC),D0
	MOVE.L	D0,(A5)+
	BRA.S	.AL
.AX:	MOVE.W	#-1,(A5)+		; END -> -1:INT

.ECL:	
	BRA	.L

      WRITESYSINFOS:
	MOVE.L	#ESTACKBUF,D2
	MOVE.L	D2,A5			; D5,A5=BUF
	MOVE.W	#5,(A5)+
	MOVE.L	MINSTACK(PC),(A5)+
	MOVE.W	OSVERSION(PC),(A5)+
	MOVE.L	CODEPREFS(PC),(A5)+
	MOVE.L	ECPU(PC),(A5)+		; CPU+FPU
	MOVE.W	ASMCPU(PC),(A5)+
	MOVE.W	#CURVERSION,(A5)+
	CLR.L	(A5)+
	MOVEQ	#24,D3			; HEAD+22
	BSR	WRITEFILE
	RTS

      WRITECONSTINFOS:
	MOVE.L	#ESTACKBUF,D5
	MOVE.L	D5,A5			; D5,A5=BUF
	MOVE.W	#1,(A5)+
	CLR.L	(A5)+			; SKIPSIZE
	MOVE.L	#CONSTHASH,A3
	MOVEQ	#0,D7			; #OF CONST WRITTEN
	LEA	1024(A3),A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
	TST.L	D4
	BNE.S	.10
	MOVE.L	A6,A5
	BRA.S	.11
.10:	CLR.W	(A5)+
.11:	BRA.W	.L

.EX:	CLR.W	(A5)+
	TST.L	D1
	BEQ.S	.LEAVE
	MOVE.L	D5,D2
	MOVE.L	A5,D3
	SUB.L	D2,D3
	MOVE.L	D5,A0
	MOVE.L	D3,D0
	SUBQ.L	#6,D0			; CHUNKSIZE-HEAD(2)-SKIP(4)
	MOVE.L	D0,2(A0)
	BSR	WRITEFILE
.LEAVE:	RTS

      KILLEXE:
	TST.W	KILLFLAG
	BEQ.S	.1
	MOVE.L	DOSBASE(PC),A6
	MOVE.L	#NAMEBUF,D1
	TSTMOD
	BEQ.S	.2
	MOVE.L	D1,A0
.3:	TST.B	(A0)+
	BNE.S	.3
	MOVE.B	#".",-1(A0)
	MOVE.B	#"m",(A0)
	CLR.B	1(A0)
.2:	JSR	-72(A6)
.1:	RTS

      CLEANUPALL:
	BSR	CLOSECON
	BSR	CLOSELOCK
	BSR	FREEBUFFERS
	BSR	SETOLDHANDLER
	BSR	UNLOCKCACHE
	MOVE.L	4,A6
	MOVE.L	DOSBASE(PC),A1
	JSR	-414(A6)
	TST.L	MATHBASE
	BEQ.S	.1
	MOVE.L	MATHBASE(PC),A1
	JSR	-414(A6)
.1:	RTS

      OPENCON:
	MOVE.L	#CONNAME,D1
	MOVE.L	#1006,D2
	MOVE.L	DOSBASE(PC),A6
	JSR	-30(A6)
	MOVE.L	D0,STOUT
	BEQ	LEAVEFAST		; NO CON: --> DEEP TROUBLE
	RTS

      HOLDCON:
	MOVEM.L	D0-D7/A0-A6,-(A7)
	BTST	#2,CODEPREFS+1
	BEQ.S	.2
	BSR	READCON			; MUST BE READABLE
.2:	MOVEM.L	(A7)+,D0-D7/A0-A6
	RTS

      CLOSECON:
	BSR	HOLDCON
	TST.W	CONOUT
	BEQ.S	.1			; NO CON: SO DON'T CLOSE IT
	MOVE.L	STOUT(PC),D1
	MOVE.L	DOSBASE(PC),A6
	JSR	-36(A6)
.1:	RTS

      READCON:
	MOVE.L	WORK(PC),D2
	MOVE.L	#10,D3
      READSTRING:			; D2=ADR, D3=LEN
	MOVE.L	STOUT(PC),D1
	MOVE.L	DOSBASE(PC),A6
	JSR	-42(A6)
	RTS

      CONNAME:
	DC.B	'CON:40/40/560/80/Amiga E Compiler Output',0
	EVEN

      FIXRETVALUE:
	MOVEQ	#0,D0
	MOVE.W	RETERROR(PC),D1
	BMI.S	.1
	MOVEQ	#5,D0
	BTST	#3,CODEPREFS+2
	BEQ.S	.2
	MOVE.L	D1,D0
	EXT.L	D0
	ADDQ.L	#1,D0
	BRA.S	.1
.2:	BTST	#5,CODEPREFS+3
	BEQ.S	.1
	MOVE.L	BYTEOFF(PC),D0
.1:	RTS

      LEAVEERROR:
	BSR	ERROR
	BSR	KILLEXE
      LEAVEOTHERERROR:
	BSR	CLEANUPALL
      LEAVEFAST:
	MOVE.L	INITSTACK(PC),A7
	BSR.S	FIXRETVALUE
	RTS


      INSTALLHANDLER:
	;rts
	;TST.W	CONOUT			; DON'T INSTALL IF IN ASMONE
	;BNE.S	.1
	MOVE.L	4.W,A6
	MOVE.L	276(A6),A0
	MOVE.L	50(A0),OLDTRAP
	MOVE.L	#TRAPHANDLER,50(A0)
	;DIVU	#0,D0
.1:	RTS

      SETOLDHANDLER:
	MOVE.L	4.W,A6
	MOVE.L	276(A6),A0
	MOVE.L	OLDTRAP,D0
	BEQ.S	.1
	MOVE.L	D0,50(A0)
.1:	RTS

      TRAPHANDLER:
	MOVE.L	(A7)+,D0
	MOVE.W	D0,GURUNUM
	MOVEQ	#3,D1
	CMP.L	D1,D0			; BUS/ADR ER?
	BGT.S	.2
	MOVE.L	4.W,A6
	BTST	#0,297(A6)		; 68010+ ?
	BNE.S	.2
	ADDQ.L	#8,A7
.2:	MOVE.L	2(A7),CRASHPC
	MOVE.L	#.3,2(A7)
	RTE
.3:	MOVE.W	GURUNUM(PC),D0
	MOVEQ	#31,D1
	BCLR	D1,D0
	CMP.L	#50,D0
	BMI.S	.1
	MOVEQ	#1,D0
.1:	MOVE.W	D0,GURUNUM
	MOVE.L	CRASHPC(PC),D0
	SUB.L	#S,D0
	BMI.S	.4
	CMP.L	#100000,D0		; MAX EXE SIZE EC
	BMI.S	.5
.4:	MOVEQ	#0,D0
.5:	MOVE.L	D0,CRASHPC
	BSR	CHECKCOOKIES
      DAMAGEDCOOKIES:			; ENTRY FOR OWN-GEN ERRORS
	MOVE.W	LINENUM(PC),LINENUMC
	LEA	INTERNALMESSY(PC),A0
	LEA	CURSPOT(PC),A1
	TST.W	IEEEPROBLEM
	BNE.S	IEEEWARN
	BSR	WRITEFORMAT
	BRA	LEAVEOTHERERROR
      IEEEWARN:
	MOVE.L	#IEEEMESSY,D2
	MOVEQ	#IEEEEND-IEEEMESSY,D3
	BSR	WRITECON
	BRA	LEAVEOTHERERROR


      OLDTRAP:	DC.L	0

      CURSPOT:	DC.W	0
      GURUNUM:	DC.W	0
      LINENUMC:	DC.W	0
      BUFSPOT:	DC.W	0
      CRASHPC:	DC.L	0


      INTERNALMESSY:	DC.B	"EC INTERNAL ERROR [%d,%d,%d,%d,$%lx] (please report!)",10,0
			EVEN
      IEEEMESSY:	DC.B	"PROBLEM: your `mathieeesingbas.library' is"
      			DC.B	" not properly patched (see docs)",10
      IEEEEND:		EVEN


;;ERROR

      ERRORTAB:
	DC.L	.0,.1,.2,.3,.4,.5,.6,.7,.8
	DC.L	.9,.10,.11,.12,.13,.14,.15,.16
	DC.L	.17,.18,.19,.20,.21,.22,.23,.24
	DC.L	.25,.26,.27,.28,.29,.30,.31,.32
	DC.L	.33,.34,.35,.36,.37,.38,.39,.40
	DC.L	.41,.42,.43,.44,.45,.46,.47,.48
	DC.L	.49,.50,.51,.52,.53,.54,.55,.56
	DC.L	.57,.58,.59,.60,.61,.62,.63,.64
	DC.L	.65,.66,.67,.68,.69,.70,.71,.72

.0:	DC.B	'syntax error',0
.1:	DC.B	'unknown keyword/const',0
.2:	DC.B	'":=" expected',0
.3:	DC.B	'unexpected characters in line',0
.4:	DC.B	'label expected',0
.5:	DC.B	'"," expected',0
.6:	DC.B	'variable expected',0
.7:	DC.B	'value does not fit in 32 bit',0
.8:	DC.B	'missing apostrophe/quote',0
.9:	DC.B	'incoherent programstructure',0
.10:	DC.B	'illegal commandline option',0
.11:	DC.B	'division and multiplication 16bit only',0
.12:	DC.B	'superfluous items in expression/statement',0
.13:	DC.B	'procedure "main" not available',0
.14:	DC.B	'double declaration of label',0
.15:	DC.B	'unsafe use of "*" or "/"',0
.16:	DC.B	"reading sourcefile didn`t succeed",0
.17:	DC.B	"writing executable/module didn`t succeed",0
.18:	DC.B	'bad args (try: EC ?)',0
.19:	DC.B	'unknown/illegal addressing mode',0
.20:	DC.B	'unmatched parentheses',0
.21:	DC.B	'double declaration',0
.22:	DC.B	'unknown identifier',0
.23:	DC.B	'incorrect # of args or use of ()',0
.24:	DC.B	'unknown e/library function',0
.25:	DC.B	'illegal function call',0
.26:	DC.B	'unknown format code following "\"',0
.27:	DC.B	'/* not properly nested comment structure */',0
.28:	DC.B	'could not load binary',0
.29:	DC.B	'"}" expected',0
.30:	DC.B	'immediate value expected',0
.31:	DC.B	'incorrect size of value',0
.32:	DC.B	'no E code allowed in assembler mode',0
.33:	DC.B	'illegal/inappropriate type',0
.34:	DC.B	'"]" expected',0
.35:	DC.B	'statement out of local/global scope',0
.36:	DC.B	'could not read module correctly',0
.37:	DC.B	'workspace full!',0
.38:	DC.B	'not enough memory while (re-)allocating',0
.39:	DC.B	'incorrect object definition',0
.40:	DC.B	'illegal use of/reference to object',0
.41:	DC.B	'incomplete if-then-else expression',0
.42:	DC.B	'unknown object identifier',0
.43:	DC.B	'double declaration of object identifier',0
.44:	DC.B	'reference(s) out of 32k range: switch to LARGE model',0
.45:	DC.B	'reference(s) out of 256 byte range',0
.46:	DC.B	'too sizy expression',0
.47:	DC.B	'incomplete exception handler definition',0
.48:	DC.B	'not allowed in a module',0
.49:	DC.B	'allowed in modules only',0
.50:	DC.B	"this doesn't make sense",0
.51:	DC.B	'you need a newer version of EC for this :-)',0
.52:	DC.B	'no matching "["',0
.53:	DC.B	'this instruction needs a better CPU/FPU (see OPT)',0
.54:	DC.B	"object doesn't understand this method",0
.55:	DC.B	"method doesn't have same #of args as method of baseclass",0
.56:	DC.B	'too many register variables in this function',0
.57:	DC.B	"Linker can't find all symbols",0
.58:	DC.B	'could not open "mathieeesingbas.library"',0
.59:	DC.B	'illegal destructor definition',0
.60:	DC.B	'implicit initialisation of private members',0
.61:	DC.B	'double method declaration',0
.62:	DC.B	'object referenced by other object not found',0
.63:	DC.B	'unknown preprocessor keyword',0
.64:	DC.B	'illegal macro definition',0
.65:	DC.B	'incoherent #ifdef/#ifndef nesting',0
.66:	DC.B	'macro redefinition',0
.67:	DC.B	'syntax error in #ifdef/#ifndef/#endif',0
.68:	DC.B	'macro(s) nested too deep',0
.69:	DC.B	'method definition out of object/module scope',0
.70:	DC.B	'library definition problem',0
.71:	DC.B	'object not known at this point',0
.72:	DC.B	'',0
	EVEN

      NOERMESSAGE:
	DC.B	'no errors'
      NEMEND:
	EVEN


ERROR0:		MOVEQ	#0,D0
		BRA	LEAVEERROR
ERROR1:		MOVEQ	#1,D0
		BRA	LEAVEERROR
ERROR2:		MOVEQ	#2,D0
		BRA	LEAVEERROR
ERROR3:		MOVEQ	#3,D0
		BRA	LEAVEERROR
ERROR4:		MOVEQ	#4,D0
		BRA	LEAVEERROR
ERROR5:		MOVEQ	#5,D0
		BRA	LEAVEERROR
ERROR6:		MOVEQ	#6,D0
		BRA	LEAVEERROR
ERROR7:		MOVEQ	#7,D0
		BRA	LEAVEERROR
ERROR8:		MOVEQ	#8,D0
		BRA	LEAVEERROR
ERROR9:		MOVEQ	#9,D0
		BRA	LEAVEERROR
ERROR10:	MOVEQ	#10,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR11:	MOVEQ	#11,D0
		BRA	LEAVEERROR
ERROR12:	MOVEQ	#12,D0
		BRA	LEAVEERROR
ERROR13:	MOVEQ	#13,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR14:	MOVEQ	#14,D0
		BRA	LEAVEERROR
ERROR15:	MOVEQ	#15,D0
		BRA	LEAVEERROR
ERROR16:	MOVEQ	#16,D0
		CLR.W	ERRWHERE
		MOVE.L	#NAMEBUF,ERROROBJ
		BRA	LEAVEERROR
ERROR17:	MOVEQ	#17,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR18:	MOVEQ	#18,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR19:	MOVEQ	#19,D0
		BRA	LEAVEERROR
ERROR20:	MOVEQ	#20,D0
		BRA	LEAVEERROR
ERROR21:	MOVEQ	#21,D0
		BRA	LEAVEERROR
ERROR22:	MOVEQ	#22,D0
		BRA	LEAVEERROR
ERROR23:	MOVEQ	#23,D0
		BRA	LEAVEERROR
ERROR24:	MOVEQ	#24,D0
		BRA	LEAVEERROR
ERROR25:	MOVEQ	#25,D0
		BRA	LEAVEERROR
ERROR26:	MOVEQ	#26,D0
		BRA	LEAVEERROR
ERROR27:	MOVEQ	#27,D0
		BRA	LEAVEERROR
ERROR28:	MOVEQ	#28,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR29:	MOVEQ	#29,D0
		BRA	LEAVEERROR
ERROR30:	MOVEQ	#30,D0
		BRA	LEAVEERROR
ERROR31:	MOVEQ	#31,D0
		BRA	LEAVEERROR
ERROR32:	MOVEQ	#32,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR33:	MOVEQ	#33,D0
		BRA	LEAVEERROR
ERROR34:	MOVEQ	#34,D0
		BRA	LEAVEERROR
ERROR35:	MOVEQ	#35,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR36:	MOVEQ	#36,D0
		BRA	LEAVEERROR
ERROR37:	MOVEQ	#37,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR38:	MOVEQ	#38,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR39:	MOVEQ	#39,D0
		BRA	LEAVEERROR
ERROR40:	MOVEQ	#40,D0
		BRA	LEAVEERROR
ERROR41:	MOVEQ	#41,D0
		BRA	LEAVEERROR
ERROR42:	MOVEQ	#42,D0
		BRA	LEAVEERROR
ERROR43:	MOVEQ	#43,D0
		BRA	LEAVEERROR
ERROR44:	MOVEQ	#44,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR45:	MOVEQ	#45,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR46:	MOVEQ	#46,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR47:	MOVEQ	#47,D0
		BRA	LEAVEERROR
ERROR48:	MOVEQ	#48,D0
		BRA	LEAVEERROR
ERROR49:	MOVEQ	#49,D0
		BRA	LEAVEERROR
ERROR50:	MOVEQ	#50,D0
		BRA	LEAVEERROR
ERROR51:	MOVEQ	#51,D0
		BRA	LEAVEERROR
ERROR52:	MOVEQ	#52,D0
		BRA	LEAVEERROR
ERROR53:	MOVEQ	#53,D0
		BRA	LEAVEERROR
ERROR54:	MOVEQ	#54,D0
		BRA	LEAVEERROR
ERROR55:	MOVEQ	#55,D0
		BRA	LEAVEERROR
ERROR56:	MOVEQ	#56,D0
		BRA	LEAVEERROR
ERROR57:	MOVEQ	#57,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR58:	MOVEQ	#58,D0
		CLR.W	ERRWHERE
		BRA	LEAVEERROR
ERROR59:	MOVEQ	#59,D0
		BRA	LEAVEERROR
ERROR60:	MOVEQ	#60,D0
		BRA	LEAVEERROR
ERROR61:	MOVEQ	#61,D0
		BRA	LEAVEERROR
ERROR62:	MOVEQ	#62,D0
		BRA	LEAVEERROR
ERROR63:	MOVEQ	#63,D0
		BRA	LEAVEERROR
ERROR64:	MOVEQ	#64,D0
		BRA	LEAVEERROR
ERROR65:	MOVEQ	#65,D0
		BRA	LEAVEERROR
ERROR66:	MOVEQ	#66,D0
		BRA	LEAVEERROR
ERROR67:	MOVEQ	#67,D0
		BRA	LEAVEERROR
ERROR68:	MOVEQ	#68,D0
		BRA	LEAVEERROR
ERROR69:	MOVEQ	#69,D0
		BRA	LEAVEERROR
ERROR70:	MOVEQ	#70,D0
		BRA	LEAVEERROR
ERROR71:	MOVEQ	#71,D0
		BRA	LEAVEERROR
ERROR72:	MOVEQ	#72,D0
		BRA	LEAVEERROR


; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The COMPILER Part !!!!!!				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


; compile main vars

	COMPILEPROC:	DC.L	0
	PROCMASK:	DC.W	0	; ONE .L
	PROCMASKREV:	DC.W	0	;
	SCOPE:		DC.W	0	; <>0 --> LOCAL
	CURLABNAME:	DC.L	FOFF
	LABPRES:	DC.L	0
	LABPRES2:	DC.L	0
	VAROFFSET:	DC.W	0
	VARNO:		DC.W	0
	PROCF:		DC.W	0
	FLAG:		DC.W	0
	CURIDENTREC:	DC.L	0	; IDENTPTR STRUCT
	NRLOC:		DC.W	0	; LINK
	NRARG:		DC.W	0	; RTD
	TYPELAB:	DC.W	0	; 0-3
	COMPMESSY:	DC.B	'parsing and compiling ...',10
	ENDCOMPMESSY:	EVEN

      PASS1:
	MOVE.W	#-1,EXPORTFLAG
	BTST	#6,CODEPREFS+2
	BNE.S	.EA
	CLR.W	EXPORTFLAG
.EA:	MOVE.W	#9,CURSPOT
	BTST	#7,CODEPREFS+2
	BNE.S	.1
	MOVE.L	#COMPMESSY,D2
	MOVE.L	#ENDCOMPMESSY-COMPMESSY,D3
	BSR	WRITECON
.1:	CLR.W	LINEWRITE
	CLR.W	LINENUM			
	LEA	CURINTERIM(PC),A0
	MOVE.L	8(A0),(A0)
	MOVE.L	CURINTERIM(PC),A0
      COMPILELINE:
	MOVE.L	CURACODE(PC),A4
	MOVE.L	ESTACK(PC),A5
	MOVE.L	CURINTERIM(PC),A3
	MOVEQ	#5,D0
	BSR	ADDLABEL
	MOVE.W	#2,ERRWHERE
      COMPILELOOP:
	BSR	WRITELINENUM		; TRASHES D7

	IF	DEMOVERS=1

CSUM:	MOVE.L	A4,D7			
	SUB.L	ACODE(PC),D7
	CMP.L	#DEMOSIZE,D7
	BPL	ERROR37
CSUME:
	ENDIF

	MOVE.W	(A3)+,D7
	CMP.W	#-1,D7
	BEQ.S	COMPILEOUTS
	CMP.W	#21,D7
	BNE	ERROR12
	MOVE.W	(A3)+,D7
	MOVE.L	A3,INTERMED
	TST.L	LINEBUF
	BEQ.S	.1
	CMP.W	LINENUM(PC),D7
	BEQ.S	.1
	MOVE.W	D7,LINENUM
	BSR	ADDLINEDBG
.1:	MOVE.W	D7,LINENUM
	MOVE.W	(A3)+,D7
	BSR	DOINSMAIN
	MOVE.L	A4,CURACODE
	BSR	CHECK3
	BRA.S	COMPILELOOP
      COMPILEOUTS:
	TST.W	PROCF
	BNE	ERROR9
	MOVE.L	A5,ESTACK
	MOVE.L	A3,CURINTERIM
	MOVE.W	#-1,LINENUM
	BSR	LINKDATA
	MOVE.L	A4,CURACODE
	RTS	

      LINKDATA:
	LEA	STRINGLINK,A6
.L:	MOVE.L	(A6),A6
	MOVE.L	A6,D0
	BEQ.S	.X
	MOVEQ	#0,D0
	MOVE.W	4(A6),D0
	BSR	ADDLABEL

	LEA	6(A6),A5
.L2:	MOVE.L	(A5)+,A3
	MOVE.W	-2(A3),D0
	MOVE.L	A4,A0
	LSL.W	#1,D0
	ADD.W	D0,A0
	MOVE.L	A0,CURACODE
	BSR	CHECK3
	MOVE.W	-4(A3),D0
	BEQ.S	.NC
	SUBQ.W	#1,D0
.CL:	MOVE.B	(A3)+,(A4)+
	DBRA	D0,.CL			; WAS A BNE LOOP!
.NC:	MOVE.L	(A5),D7
	MOVE.L	D7,A5
	BNE.S	.L2
	CLR.B	(A4)+
	
	BRA.S	.L
.X:	MOVE.L	A4,D0
	BTST	#0,D0
	BEQ.S	.1
	CLR.B	(A4)+
.1:	RTS


      DOINSMAIN:			; FIRST INTERIM IN D7
	CMP.W	#IOFF+59,D7
	BEQ.S	.1
.2:	BSR	DOINS
	TST.W	(A3)+
	BNE	ERROR12
.3:	BTST	#6,CODEPREFS+2
	BEQ.S	.EA
	RTS
.EA:	CLR.W	EXPORTFLAG
	RTS
.1:	MOVE.W	#-1,EXPORTFLAG
	MOVE.W	(A3)+,D7
	BEQ.S	.3
	BRA.S	.2

      EXPORTFLAG:	DC.W	0
      FLTFLAG:		DC.W	0
      DEFFLAG:		DC.W	0
      HANDLEFLAG:	DC.W	0

      DOINS:
	TST.W	SCOPE
	BEQ.S	.2
	TST.W	DEFFLAG
	BNE.S	.DH
.DHB:	CMP.W	#$100,D7		; in procs part
	BPL	DOASM
	CMP.W	#IDENT,D7		; BECOMES+LABEL:
	BEQ	DOLAB
	CMP.W	#32,D7
	BEQ	PTRCOMPLEX
	BTST	#3,CODEPREFS+3
	BEQ.S	.1
	CMP.W	#IOFF+20,D7
	BMI	ERROR32
	CMP.W	#IOFF+23,D7
	BPL	ERROR32
.1:	CMP.W	#IOFF,D7
	BPL	DOJOB
	BRA	DOEXP
.2:	CMP.W	#IOFF+16,D7		; in global part
	BEQ	DOJOB
	CMP.W	#IOFF,D7
	BEQ	DOJOB
	CMP.W	#IOFF+48,D7
	BEQ	DOJOB
	BRA	ERROR35
.DH:	CMP.W	#IOFF+17,D7
	BEQ.S	.DHB
	CLR.W	DEFFLAG			; FIRST STATEMENT AFTER DEF'S
	TST.W	HANDLEFLAG
	BEQ	.DHB
	BSR	HANDLEPROCREALLY
	BRA	.DHB
      DOINSOUT:
	RTS

      DOEXP:
	TST.W	PROCF
	BNE.S	.1
	BSET	#6,WARNINGS+3		; CODE OUTSIDE PROCS
.1:	MOVE.W	#1,EXPSTAT
	MOVE.W	D7,-(A3)
	BSR	EXP
	CLR.W	EXPSTAT
	BRA.S	DOINSOUT

      EXPSTAT:	DC.W	0

      DOASM:
	BSR	ASM_COMPILE		; WITH D7
	BRA.S	DOINSOUT

      DOJOB:
	BSR.S	DOKEYWORD
	BRA	DOINSOUT

      STOPJOB:				; END JOBCODE PROCESSING
	LEA	.1(PC),A2
	RTS
.1:	DC.W	0

      DOKEYWORD:
	SUB.W	#IOFF,D7
	ASL.W	#2,D7
	LEA	INSJOBTAB(PC),A2
	MOVE.L	0(A2,D7.W),A2
      JOBLOOP:
	MOVE.W	(A2)+,D7
	TST.W	D7
	BEQ.S	JOBOUT
	ASL.W	#2,D7
	MOVE.L	JOBROUTTAB(PC,D7.W),A0
	JMP	(A0)
      JOBOUT:
	RTS

      JOBROUTTAB:
	DC.L	JOBOUT,GETPARAMLABEL,JOBEXP,GETPARAMVAR,GETCOMMA   ; 0
	DC.L	SAVESTIDENT,FORWARDREFERENCE,CHECKSTIDENT	   ; 5
	DC.L	MAKEBRANCH,COPY2,COPY4,COPYN,COPY6,COPY8	   ; 8
	DC.L	COPY10,REMEMBERLAB,EXPORNILL,PROCFLAGON		   ; 14
	DC.L	PROCFLAGOFF,CHECK2LAB,REMINDCURPOS,POPLAB	   ; 18
	DC.L	INSERTVAROFF,PUSHVAR,POPVAR,PUSHLAB		   ; 22
	DC.L	PUSHLAB2,POPLAB2,NEWLAB2,MAKEBRANCH2		   ; 26
	DC.L	SETFLAG,SKIPFLAG,CLEARFLAG,SKIPDEFLOCAL,GETNRLOC   ; 30
	DC.L	INSERTVAROFFDEST,GETBRACKLEFT,GETBRACKRIGHT	   ; 35
	DC.L	DOINCBIN,DOLONG,DOINT,DOCHAR,JOBINS,EXPECT	   ; 38
	DC.L	SERROR,EXPECT2,JOBSKIP,EXPECTASSIGN,EXPECTTO	   ; 44
	DC.L	DOMIDFOR,ENDGLOBVAR,ELSEMAKELAB,ELSEUSELAB	   ; 49
	DC.L	ELSEDEFLAB,ELSEWAISTELAB,DOOBJECT,OPTIIF	   ; 53
	DC.L	DOELSECH,DORETURN,MAKEBRANCHL,JOBINSIF,JOBEXPIF	   ; 57
	DC.L	JOBFORSTEP,HANDLEPROC,DOEXCEPT,CLOSEHANDLER	   ; 62
	DC.L	PUSHTYPE,POPTYPE,RTSRTD,DONEW,EXPECTRETURNIS	   ; 66
	DC.L	SELECTOF,EXPECTOFOBJECT,SAVEREGSPROC,DOEND	   ; 71
	DC.L	FILLEXIT,DOSUPER,JOBOUT,JOBOUT			   ; 75

      DOBECOMESMETHOD:
	CMP.W	#42,6(A3)
	BEQ	DOEXP
      DOBECOMES:
	MOVE.L	(A3)+,A1
	CMP.W	#ASSGN,(A3)
	BNE	COMPLEXBECOMES
	MOVE.B	4(A1),D2
	BEQ	ERROR22
	CMP.B	#LAB,D2
	BEQ	ERROR6
	ADDQ.L	#2,A3

;	MOVEQ	#0,D7
;	CMP.W	#IDENT,(A3)		; CHECK IF a:=a+<exp>
;	BNE.S	.NOPT
;	CMPA.W	2(A3),A1
;	BNE.S	.NOPT
;	CMP.W	#7,6(A3)
;	BEQ.S	.OPT
;	CMP.W	#8,6(A3)
;	BNE.S	.NOPT
;.OPT:	ADDQ.L	#6,A3
;	MOVE.W	(A3)+,D7		; FROM HERE D7.W, 0=MOVETO, 7=ADDTO, 8=SUBFROM
;
;.NOPT:

	MOVE.L	A1,EAIDENT
	MOVE.W	#17,EAREQUEST
	BSR	EAEXP
	TST.L	D0
	BNE.W	.OPT
	MOVE.W	.1(PC),(A4)+
	BSR	GVA1D2_9
.OPT:	BRA	DOINSOUT
.1:	MOVE.L	D0,2(A5)

      PTRCOMPLEX:			; uses a0,d0
	SUBQ.L	#2,A3
	MOVE.L	A3,A0
	BRA.S	COMPLEXST
      COMPLEXBECOMES:
	LEA	-6(A3),A0
      COMPLEXST:
	MOVE.L	A0,-(A7)		; complexstart -->STACK (D7)
	BSR	EATLEXP
	BSR	EXP
	MOVE.L	(A7)+,D7
	MOVE.L	A3,-(A7)		; complexend -->STACK
	MOVE.L	D7,A3
	MOVEQ	#2,D0
	BSR	EADDRESSMODI
	CMP.W	#ASSGN,(A3)+
	BNE	ERROR2
	MOVE.L	(A7)+,A3
	BRA	DOINSOUT


      NOASSIGN:
	MOVE.L	A0,A3			; FROM COMPLEXST
	BSR	EXP
	BRA	DOINSOUT

      EATLEXP:				; uses d0
	MOVE.W	(A3)+,D0
	BEQ	.3
	CMP.W	#IDENT,D0
	BEQ.S	.1
	CMP.W	#ASSGN,D0
	BEQ.S	.2
	CMP.W	#39,D0
	BEQ.S	.1
	CMP.W	#31,D0
	BEQ.S	.1
	CMP.W	#11,D0
	BEQ.S	.4
	CMP.W	#32,D0
	BMI.S	.B
	CMP.W	#36,D0
	BMI.S	EATLEXP
.B:	CMP.W	#41,D0
	BEQ.S	EATLEXP
	CMP.W	#42,D0
	BEQ.S	.MET
	CMP.W	#29,D0
	BNE.S	.3			; was ERROR0!!!
	ADD.L	(A3),A3
	BRA.S	EATLEXP
.2:	RTS
.1:	ADDQ.L	#4,A3
	BRA.S	EATLEXP
.4:	BSET	#3,WARNINGS+3		; a.complex=1 a statement
	MOVE.W	LINENUM,ASSLINE
.3:	ADDQ.L	#8,A7
	BRA.S	NOASSIGN
.MET:	ADDQ.L	#4,A7
	MOVE.L	(A7)+,A3
	ADDQ.L	#2,A3
	BRA	DOEXP

      DOMULTIPLE:
	SUBQ.L	#2,A3
	MOVE.L	A3,-(A7)
.L:	CMP.W	#IDENT,(A3)+		; SKIP VARS
	BNE	ERROR6
	ADDQ.L	#4,A3
	CMP.W	#COM,(A3)+
	BEQ.S	.L
	CMP.W	#ASSGN,-2(A3)
	BNE	ERROR2
	BSR	EXP
	MOVE.L	(A7)+,D0
	MOVE.L	A3,-(A7)
	MOVE.L	D0,A3
	MOVEQ	#0,D0			; REGISTER COUNT
.L2:	CMP.W	#8,D0			; NO MORE THAN 8 VARS
	BEQ	ERROR0
	ADDQ.L	#2,A3			; FILL VARS WITH D0..DX
	MOVE.L	(A3)+,A0
	LEA	.1(PC),A1
	MOVE.B	4(A0),D2
	BEQ	ERROR22
	CMP.B	#LAB,D2
	BEQ	ERROR6
	MOVE.W	(A1),D1
	OR.W	D0,D1
	MOVE.W	D1,(A4)+
	BSR	GVA0D7_9
	ADDQ.L	#1,D0
	CMP.W	#COM,(A3)+
	BEQ	.L2
	MOVE.L	(A7)+,A3
	BRA	DOINSOUT
.1:	MOVE.L	D0,2(A5)
	

      DOLAB:
	BTST	#3,CODEPREFS+3
	BNE.S	.1
.2:	MOVE.W	4(A3),D0
	CMP.W	#ASSGN,D0
	BEQ	DOBECOMES
	CMP.W	#29,D0
	BEQ	DOBECOMES
	CMP.W	#35,D0
	BEQ	DOBECOMESMETHOD
	CMP.W	#41,D0
	BEQ	DOBECOMES
	CMP.W	#COM,D0
	BEQ	DOMULTIPLE
	CMP.W	#11,D0
	BNE.S	.3
	BSET	#3,WARNINGS+3		; a=1 a statement
	MOVE.W	LINENUM,ASSLINE
.3:	CMP.W	#19,D0
	BNE	DOEXP
	SUBQ.L	#2,A3
	BSR	CHLAB
	TST.W	(A3)+
	TST.W	(A3)			; INTR. FOLLOWS OR WHAT?
	BEQ	DOINSOUT
	BSR	DOINSREC
	BRA	DOINSOUT
.1:	CMP.W	#19,4(A3)
	BNE	ERROR32
	BRA.S	.2

;;COMPILE


;	NOTEZBIEN:	DEZE MOGEN NIET MEER REGISTERS VERSTOREN!

      ADDLABEL:				; D0 LABEL (A4 IS ADR. LABEL)
	MOVE.L	LABM+8(PC),A0		; THRASHES A0/D0!
	LSL.L	#2,D0
	AND.L	#$3FFFF,D0
	MOVE.L	A4,0(A0,D0.L)
	RTS

      NEWOP:	DC.W	0		; 0=NO32, X=NEWOP

      ADDBRANCH:			; D0 LABEL (A4 IS ADR. NA OP.)
	MOVE.L	A4,D1
	SUBQ.L	#2,D1			; +TRASH: D1/A0, -TRASH: D0 !

	IF DEMOVERS=0

	TST.W	NEWOP
	BEQ.S	.NL
	BTST	#2,CODEPREFS+3
	BEQ.S	.NL
	MOVE.L	#$30000,-2(A4)
	ADDQ.L	#2,A4
	MOVE.W	D7,-(A7)
	MOVE.W	NEWOP(PC),D7
	BEQ.S	.NNO
	MOVE.W	D7,-6(A4)
.NNO:	MOVE.W	(A7)+,D7
.NL:
	ENDIF

	GETM	A0
	MOVE.L	BRANCHLIST(PC),(A0)
	MOVE.L	A0,BRANCHLIST
	ADDQ.L	#4,A0
	MOVE.L	D1,(A0)+
	MOVE.W	D0,(A0)+
	DONEM	A0
	RTS

      ADDBRANCHRELOC:			; D0 LABEL (A4 IS ADR. VOOR REL.LONG.)
	MOVE.L	A4,D1			; +TRASH: D1/A0, -TRASH: D0 !
	MOVE.L	#$30000,(A4)+
	GETM	A0
	MOVE.L	BRANCHLIST(PC),(A0)
	MOVE.L	A0,BRANCHLIST
	ADDQ.L	#4,A0
	MOVE.L	D1,(A0)+
	MOVE.W	D0,(A0)+
	DONEM	A0
	RTS

      BRANCHLIST:	DC.L	0

      GETPARAMLABEL:			; 1
	CMP.W	#IDENT,(A3)+
	BNE	ERROR4
	MOVE.L	(A3)+,A0
	MOVE.W	10(A0),LABPRES+2
	CMP.B	#LAB,4(A0)
	BNE	ERROR4
	BTST	#4,5(A0)
	BNE	ERROR4
	BRA	JOBLOOP

      JOBEXP:				; 2
	BSR	EXP
	BRA	JOBLOOP

      GETPARAMVAR:			; 3
	MOVE.W	(A3)+,D6
	CMP.W	#IDENT,D6
	BNE	ERROR6
	MOVE.L	(A3)+,A0
	MOVE.L	A0,CURIDENTREC
	MOVE.W	10(A0),VAROFFSET
	MOVE.B	4(A0),D0
	BEQ	ERROR22
	MOVE.W	D0,TYPELAB
	CMP.B	#LAB,D0
	BEQ	ERROR6
	BRA	JOBLOOP

      GETCOMMA:				; 4
	MOVE.W	(A3)+,D6
	CMP.B	#COM,D6
	BNE	ERROR5
	BRA	JOBLOOP

      NEWLABEL:				; => D0 LAB
	MOVE.L	CURLABNAME(PC),D0
	ADDQ.L	#1,CURLABNAME
	BSR	CHECKLABBUF
	RTS

      SAVESTIDENT:			; 5
	MOVE.W	(A2)+,(A5)+
	BRA	JOBLOOP

      CHECKSTIDENT:			; 7
	MOVE.W	-(A5),D0
	CMP.W	(A2)+,D0
	BNE	ERROR9
	BRA	JOBLOOP

      FORWARDREFERENCE:			; 6
	BSR.S	NEWLABEL
	MOVE.L	D0,(A5)+
	MOVE.L	D0,LABPRES
	BRA	JOBLOOP

      REMINDCURPOS:			; 20
	BSR.S	NEWLABEL
	MOVE.L	D0,(A5)+
	BSR	ADDLABEL
	BRA	JOBLOOP

      MAKEBRANCH:			; 8
	MOVE.L	LABPRES,D0
	CLR.W	NEWOP
	BSR	ADDBRANCH
	BRA	JOBLOOP

      REMEMBERLAB:			; 15
	MOVE.L	-(A5),D0
	BSR	ADDLABEL
	BRA	JOBLOOP

      POPLAB:				; 21
	MOVE.L	-(A5),LABPRES
	BRA	JOBLOOP

      COPY2:				; 9
	MOVE.W	(A2)+,(A4)+
	BRA	JOBLOOP

      COPY4:				; 10
	MOVE.L	(A2)+,(A4)+
	BRA	JOBLOOP

      COPY6:				; 12
	MOVE.L	(A2)+,(A4)+
	MOVE.W	(A2)+,(A4)+
	BRA	JOBLOOP

      COPY8:				; 13
	MOVE.L	(A2)+,(A4)+
	MOVE.L	(A2)+,(A4)+
	BRA	JOBLOOP

      COPY10:				; 14
	MOVE.L	(A2)+,(A4)+
	MOVE.L	(A2)+,(A4)+
	MOVE.W	(A2)+,(A4)+
	BRA	JOBLOOP

      COPYN:				; 11
	MOVE.W	(A2)+,D0
      COPYNLOOP:
	MOVE.W	(A2)+,(A4)+
	DBRA	D0,COPYNLOOP
	BRA	JOBLOOP


; central important vars:
;------------------------

CURINTERIM:	DC.L 0			; [1] ADR. OF CURRENT INTERIM
TOKENEND:	DC.L 0,0,0,10000,50*KB
CURLIBASC:
CURACODE:	DC.L 0,0		; [3] ADR. OF CURRENT OBJPART
ACODE:		DC.L 0			;     ADR. OF OBJECTCODE
		DC.L 0,MAXSTACK+1000,MINIMUM_ACODE
HEAP:		DC.L 0			; [5] ADR. OF CURRENT HEAPSPACE
		DC.L 0,0,0,2000,10*KB
LABM:		DC.L 0,0,0,0,5000,15*KB	; [6]



ECODE:		DC.L EXAMPLE		; ADR. OF E-CODE
CURECODE:	DC.L EXAMPLE		; ADR. OF CURRENT ELINE
ENDECODE:	DC.L EXAMPLEEND
EBUF:		DC.L 0			; <>0 --> DEALLOC
EBUFSIZE:	DC.L 0
GENERALSIZE:	DC.L 0

INITSTACK:	DC.L 0
ESTACK:		DC.L ESTACKBUF		; ADR. OF COMPILESTACK
WORK:		DC.L WORKBUF		; ADR. OF WORKBUFFER
DIRNAMEX:	DC.L DIRNAME
MODLEFT:	DC.L 0

LINENUM:	DC.W -1
LINENUM2:	DC.W 0
LINENUMZ:	DC.L 0
ERROROBJ:	DC.L 0			; IDENTNAME THAT CAUSED ERROR 
REALBRANCH:	DC.L 0			; OFFSET ADR
STARTINTERIM:	DC.L 0

LOADEDVERSION:	DC.W 0

CHECKHEAP:	DC.W 10
OPERSIZE:	DC.W 4			; MUST BE KEPT AT 4 (FOR GLOBALS)

LIBINFO:	DC.L	0

;----------------------------


      EXPORNILL:			; 16
	TST.W	(A3)
	BEQ.S	MAKEMOVEQ
	CMP.W	#$400,(A3)
	BEQ	MAKED0
	CMP.W	#IOFF+18,(A3)
	BEQ.S	MAKEMOVEQ
	BSR	EXP
	CMP.W	#COM,(A3)
	BNE	JOBLOOP
	CLR.W	.C
.L:	MOVE.W	.P(PC),(A4)+
	ADDQ.L	#2,A3
	BSR	EXP
	ADDQ.W	#1,.C
	CMP.W	#COM,(A3)
	BEQ.S	.L
	MOVE.W	.C(PC),D0
	CMP.W	#MAXMULTRET,D0
	BPL	ERROR0
	MOVE.W	.M(PC),D1
	MOVE.W	D0,D2
	MOVEQ	#9,D3
	LSL.W	D3,D2
	OR.W	D2,D1
	MOVE.W	D1,(A4)+
.L2:	SUBQ.W	#1,D0
	MOVE.W	.R(PC),D1
	MOVE.W	D0,D2
	LSL.W	D3,D2
	OR.W	D2,D1
	MOVE.W	D1,(A4)+
	TST.W	D0
	BNE.S	.L2
	BRA	JOBLOOP
.P:	MOVE.L	D0,-(A7)
.C:	DC.W	0
.M:	MOVE.L	D0,D0
.R:	MOVE.L	(A7)+,D0
      MAKEMOVEQ:
	MOVE.W	EXPSTART(PC),(A4)+
	BRA	JOBLOOP
      MAKED0:
	ADDQ.L	#2,A3
	BRA	JOBLOOP

      PROCFLAGON:			; 17
	TST.W	PROCF
	BNE	ERROR9
	BSR.W	NEWLABEL
	MOVE.L	D0,PROCEND
	MOVE.L	A4,PROCSTARTADR
	MOVEQ	#-1,D1
	MOVE.W	D1,PROCF
	MOVE.W	D1,DEFFLAG
	CLR.W	HANDLEFLAG
	MOVE.L	CURIDENTREC(PC),A0	; NOW GET NR OF LOC VARS
	MOVE.L	6(A0),A0
	MOVE.L	A0,COMPILEPROC
	CLR.L	PROCMASK		; + REV
	MOVE.W	4(A0),NRLOC
	BTST	#0,2(A0)
	BEQ.S	.1
	MOVE.W	(A0),NRARG
	BRA.S	.2
.1:	CLR.W	NRARG
.2:	CLR.L	XTRASTACK
.3:	BRA	JOBLOOP


	INITCODE:	BSR	GLOBSTACK
	PROCRTS:	RTS
	GLOBSTACK:	DC.L	0	; TOTAL GLOBAL
	XTRASTACK:	DC.L	0
	MINSTACK:	DC.L	0	; ALL LOCAL ADDED
	CLEARXTRA:	ADD.L	#40,A7
	PROCEND:	DC.L	0
	PROCSTARTADR:	DC.L	0

      PROCFLAGOFF:			; 18
	TST.W	PROCF
	BEQ	ERROR9
	MOVE.L	PROCEND(PC),D0
	BSR	ADDLABEL
	MOVE.L	A4,D0
	SUB.L	PROCSTARTADR(PC),D0
	CMP.L	#32000,D0
	BPL	ERROR46
	CLR.W	PROCF
	MOVE.L	XTRASTACK(PC),D0
	ADD.L	D0,MINSTACK

	TST.L	D0
	BEQ.S	.2
	MOVE.W	CLEARXTRA(PC),(A4)+
	MOVE.L	D0,(A4)+
.2:
	TST.W	PROCMASKREV
	BEQ.S	.1
	RESTR	PROCMASKREV
.1:
	TST.W	HANDLEFLAG
	BEQ.S	.1B
	MOVE.L	.3(PC),(A4)+
.1B:
	BRA	JOBLOOP
.3:	MOVEM.L	(A7)+,D3-D7

      CHECK2LAB:			; 19
	BSR.S	CHLAB
	BRA	JOBLOOP

      CHLAB:
	MOVE.W	(A3)+,D6
	CMP.W	#IDENT,D6
	BNE	ERROR4
	MOVE.L	(A3)+,D0
	MOVE.L	D0,CURIDENTREC
	MOVE.L	D0,A0
	CMP.B	#LAB,4(A0)
	BNE	ERROR4

	TST.W	EXPORTFLAG
	BEQ.S	.1
	BSET	#2,5(A0)		; EXPORT
.1:
	MOVE.L	6(A0),A1		; FOR MAIN
	MOVE.L	(A0),A0
	CMP.B	#'m',(A0)
	BEQ.S	MAINFOUND
      MAINBACK:
	CMP.L	#FOFF,D0
	BMI.S	.1
	MOVE.L	D0,A1
	MOVEQ	#0,D0
	MOVE.W	10(A1),D0
.1:	BSR	ADDLABEL
	RTS

      MAINF:	DC.W	0

      MAINFOUND:
	CMP.B	#'a',1(A0)
	BNE.S	MAINBACK
	CMP.B	#'i',2(A0)
	BNE.S	MAINBACK
	CMP.B	#'n',3(A0)
	BNE.S	MAINBACK
	CMP.B	#0,4(A0)
	BNE.S	MAINBACK
	TST.W	(A1)
	BNE	ERROR23
	MOVEQ	#1,D0			; MAINLABCODE
	TST.W	MAINF
	BNE	ERROR14
	MOVE.W	D0,MAINF
	TSTMOD
	BEQ.S	MAINBACK
	BRA	ERROR48

      INSERTVAROFF:			; 22
	SUBQ.L	#2,A4
	MOVE.L	CURIDENTREC(PC),A0
	BSR	GVA0D2_0
	BRA	JOBLOOP

      INSERTVAROFFDEST:			; 35
	SUBQ.L	#2,A4
	MOVE.L	CURIDENTREC(PC),A0
	BSR	GVA0D2_9
	BRA	JOBLOOP

      PUSHVAR:				; 23
	MOVE.L	CURIDENTREC(PC),(A5)+
	BRA	JOBLOOP

      POPVAR:				; 24
	MOVEA.L	-(A5),A0
	MOVE.L	A0,CURIDENTREC
	MOVE.B	4(A0),TYPELAB
	MOVE.W	10(A0),VAROFFSET
	BRA	JOBLOOP

      PUSHLAB:				; 25
	MOVE.L	LABPRES(PC),(A5)+
	BRA	JOBLOOP

      PUSHLAB2:				; 26
	MOVE.L	LABPRES2(PC),(A5)+
	BRA	JOBLOOP

      POPLAB2:				; 27
	MOVE.L	-(A5),LABPRES2
	BRA	JOBLOOP

      NEWLAB2:				; 28
	BSR	NEWLABEL
	MOVE.L	D0,(A5)+
	MOVE.L	D0,LABPRES2
	BRA	JOBLOOP

      MAKEBRANCH2:			; 29
	MOVE.L	LABPRES2(PC),D0
	CLR.W	NEWOP
	BSR	ADDBRANCH
	BRA	JOBLOOP

      SETFLAG:				; 30
	MOVE.W	#-1,FLAG
	BRA	JOBLOOP

      SKIPFLAG:				; 31
	MOVE.W	(A2)+,D0
	TST.W	FLAG
	BNE.S	SKIPOUT
      SKIPLOOP:
	TST.W	(A2)+			; NOP
	DBRA	D0,SKIPLOOP
      SKIPOUT:
	BRA	JOBLOOP

      CLEARFLAG:			; 32
	MOVE.W	#0,FLAG
	BRA	JOBLOOP			; was: "OUT"

MAXINT=$7FF0

LDEF:	MACRO
	TSTMOD
	BEQ.S	*+12
	CMP.W	#3,-2(A2)
	BEQ	ERROR48
	ENDM

; following code has HEAP in use!!!!!

	DBLIST:	DC.L	0		; linked
	DBTAIL:	DC.L	0
	DBBEG:	DC.L	0
	DBCUR:	DC.L	0		; =end after one, ISDEBUG FLAG


      SKIPDEFLOCAL:			; 33
	MOVEQ	#0,D6			; D6=DEFARGS COUNT
	MOVE.W	(A2)+,D5		; 1=PROC,2=LOCAL,3=DEF

	CLR.L	DBCUR
	BTST	#6,CODEPREFS+1
	BEQ.W	.NDB			; NOW __DEBUG__ SPECIFIC
	CMP.W	#1,D5
	BNE.W	.NN

	GETM	A0
	MOVE.L	DBTAIL(PC),D0
	BNE.S	.LA
	MOVE.L	A0,DBLIST
	BRA.S	.LN
.LA:	MOVE.L	D0,A1
	MOVE.L	A0,(A1)
.LN:	MOVE.L	A0,DBTAIL
	MOVE.L	A0,D2
	CLR.L	(A0)+			; NEXT
	MOVE.W	#4,(A0)+		; COPY NAME FUN OR METHOD
	MOVE.L	COMPILEPROC(PC),A1
	MOVE.L	A1,D1
	CLR.W	(A0)+
	MOVE.L	A0,A6
	MOVE.L	10(A1),D0
	BEQ.S	.NM
	MOVE.L	D0,A1
	MOVE.L	OASCII(A1),A1
.COL:	MOVE.B	(A1)+,(A0)+
	BNE.S	.COL
	MOVE.B	#":",-1(A0)
.NM:	MOVE.L	D1,A1
	MOVE.L	14(A1),A1
	MOVE.L	(A1),A1
.CIL:	MOVE.B	(A1)+,(A0)+
	BNE.S	.CIL
	MOVE.L	A0,D0
	BTST	#0,D0
	BEQ.S	.NA
	CLR.B	(A0)+
.NA:	MOVE.L	A0,D0
	SUB.L	A6,D0
	MOVE.W	D0,-2(A6)

	MOVE.L	D1,A1			; THIS BIT ADDS A "5" SELF EXTENSION
	MOVE.L	18(A1),D0
	BEQ.S	.NSELF
	MOVE.L 	#$50004,(A0)+
	MOVE.W	LINENUM(PC),(A0)+
	MOVE.L	D0,A1
	MOVE.W	10(A1),(A0)+
.NSELF:
	CLR.W	(A0)+			; TO BE ABLE TO DETECT A 5
	DONEM	A0
	
.NN:	GETM	A0			; START REGULAR VAR DEBUG, 10 BYTES
	MOVE.L	A0,DBBEG
	CLR.L	(A0)+
	MOVE.W	D5,(A0)+
	MOVE.W	LINENUM(PC),(A0)+
	CLR.W	(A0)+
	MOVE.L	A0,DBCUR

.NDB:	TST.W	SCOPE
	BNE.S	.S
	CMP.W	#3,D5			; must be DEF
	BNE	ERROR35
	BRA.S	.B
.S:	CMP.W	#3,D5			; musn't be DEF (LOCAL)
	BEQ	ERROR35
	TST.W	PROCF
	BEQ	ERROR35
	TST.W	DEFFLAG
	BEQ	ERROR35			; NO LOCAL DEFS AFTER 1ST STAT.
.B:	MOVEQ	#0,D0			; D0=XTRA ARRAY STACKSPACE
	CMP.W	#18,(A3)
	BE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; 36
	MOVE.W	(A3)+,D6
	CMP.W	#17,D6
	BNE	ERROR23
	BRA	JOBLOOP

      GETBRACKRIGHT:			; 37
	MOVE.W	(A3)+,D6
	CMP.W	#18,D6
	BNE	ERROR23
	BRA	JOBLOOP

      DOINCBIN:				; 38
	LEA	CURACODE(PC),A0
	MOVE.L	8(A0),D3
	ADD.L	12(A0),D3
	SUB.L	A4,D3
	SUBQ.L	#8,D3			; MAXREADSIZE
	CMP.L	#3000,D3
	BMI	ERROR37

	CMP.W	#STR,(A3)+		; D0-D6/ A3/A6
	BNE	ERROR0
	ADDQ.L	#2,A3
	MOVE.W	(A3)+,D6		; D6=WORDLENSTR
	MOVE.L	DOSBASE(PC),A6
	MOVE.L	A3,D1
	MOVE.L	#1005,D2
	JSR	-30(A6)
	TST.L	D0
	BEQ	ERROR28
	MOVE.L	D0,D5			; D5=HANDLE

	MOVE.L	D5,D1
	MOVE.L	A4,D2
	JSR	-42(A6)			; READ
	MOVE.L	D0,D4			; D4=READLEN
	MOVE.L	D5,D1
	JSR	-36(A6)			; CLOSE
	CMP.L	#2,D4
	BMI	ERROR28
	SUB.L	D4,D3
	CMP.L	#3000,D3
	BMI	ERROR37
	ADD.L	D4,A4
	BTST	#0,D4
	BEQ.S	.1
	MOVE.B	#0,(A4)+
.1:
	LSL.W	#1,D6
	EXT.L	D6
	ADD.L	D6,A3
	BRA	JOBLOOP

      DOLONG:				; 39
.2:	CMP.W	#VALUE,(A3)+
	BEQ.S	.3
	CMP.W	#8,-2(A3)
	BNE	ERROR30
	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	NEG.L	(A3)
.3:	MOVE.L	(A3)+,(A4)+
	CMP.W	#COM,(A3)
	BNE.S	.1
	ADDQ.L	#2,A3
	BRA.S	.2
.1:	BRA	JOBLOOP

      DOINT:				; 40
.2:	CMP.W	#VALUE,(A3)+
	BEQ.S	.3
	CMP.W	#8,-2(A3)
	BNE	ERROR30
	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	NEG.L	(A3)
.3:	MOVE.L	(A3)+,D0
	MOVE.W	D0,(A4)+
	CMP.W	#COM,(A3)
	BNE.S	.1
	ADDQ.L	#2,A3
	BRA.S	.2
.1:	BRA	JOBLOOP

      DOCHAR:				; 41
.2:	CMP.W	#VALUE,(A3)+
	BEQ.S	.7
	CMP.W	#8,-2(A3)
	BNE.S	.3			; NO VALUE? --> STRING
	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	NEG.L	(A3)
.7:	MOVE.L	(A3)+,D0
	MOVE.B	D0,(A4)+
.5:	CMP.W	#COM,(A3)
	BNE.S	.1
	ADDQ.L	#2,A3
	BRA.S	.2
.1:	MOVE.L	A4,D0
	BTST	#0,D0
	BEQ.S	.6
	MOVE.B	#0,(A4)+
.6:	BRA	JOBLOOP
.3:	CMP.W	#STR,-2(A3)
	BNE	ERROR30
	MOVE.W	(A3)+,D1		; =REAL LEN
	MOVE.W	(A3)+,D0		; =WORD LEN
	SUBQ.L	#1,D1
.4:	MOVE.B	(A3)+,(A4)+
	DBRA	D1,.4
	ADDQ.L	#1,A3
	MOVE.L	A3,D0
	BTST	#0,D0
	BEQ.S	.5
	ADDQ.L	#1,A3
	BRA.S	.5

      JOBINS:				; 42
	MOVE.L	A5,-(A7)
	BSR.S	DOINSREC
	CMPA.L	(A7)+,A5
	BNE	ERROR9
	BRA	JOBLOOP

      DOINSREC:
	MOVE.W	(A3)+,D7
	BEQ	ERROR0
	CMP.W	#-1,D7
	BEQ	ERROR0
	MOVE.L	A2,-(A7)
	BSR	DOINS
	MOVE.L	(A7)+,A2
	RTS

      EXPECT:				; 43 IF FOLLOWING CODE IS PRESENT, CONTINUE
	MOVE.W	(A3),D0			;    WITH JOB, ELSE STOP.
	CMP.W	(A2)+,D0	
	BEQ.S	.1			;    CONTINUE, EAT 1
.2:	TST.W	(A2)+
	BNE.S	.2			;    STOP, EAT ALL
	SUBQ.L	#2,A2	
	BRA	JOBLOOP
.1:	ADDQ.L	#2,A3
	BRA	JOBLOOP

      SERROR:
	BRA	ERROR0			; 44

      EXPECT2:				; 45 IF FOLLOWING CODE IS PRESENT, CONTINUE
	MOVE.W	(A3),D0			;    WITH JOB, ELSE FIND PAST ZERO.
	CMP.W	(A2)+,D0	
	BEQ.S	.1			;    CONTINUE, EAT 1
.2:	TST.W	(A2)+
	BNE.S	.2			;    STOP, EAT ALL TO NEXT ZERO
	BRA	JOBLOOP
.1:	ADDQ.L	#2,A3
	BRA	JOBLOOP

      JOBSKIP:				; 46
	ADDQ.L	#2,A2
	BRA	JOBLOOP

      EXPECTASSIGN:			; 47
	CMP.W	#ASSGN,(A3)+
	BNE	ERROR2
	BRA	JOBLOOP

      EXPECTTO:				; 48 CHOMEUR
	BRA	JOBLOOP

      DOMIDFOR:				; 49
	CMP.W	#IOFF+39,(A3)+		; MUST BE "TO"
	BNE	ERROR0
	BSR	EXP			; AND MAKE NICE EXP FOR D0

	MOVEQ	#1,D7			; D7=STEP
	CMP.W	#IOFF+40,(A3)		; ANY "STEP" ?
	BNE.S	.NS
	ADDQ.L	#2,A3
	CMP.W	#8,(A3)
	BNE.S	.NM
	NEG.L	4(A3)
	ADDQ.L	#2,A3
.NM:	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	MOVE.L	(A3)+,D7
.NS:
.1:	MOVE.W	.M2(PC),(A4)+
	MOVE.L	CURIDENTREC(PC),A0
	BSR	GVA0D1_0
	BSR.W	NEWLABEL
	MOVE.L	D0,(A5)+
	MOVE.L	D0,LABPRES
	TST.L	D7
	BMI.S	.5
	MOVE.L	.M3(PC),(A4)+
	BRA.S	.6
.5:	MOVE.L	.M5(PC),(A4)+
.6:	MOVE.L	LABPRES(PC),D0
	CLR.W	NEWOP
	BSR	ADDBRANCH
	MOVE.L	D7,(A5)+		; STEP ON COMPILESTACK
	MOVE.L	CURIDENTREC,(A5)+
	BRA	JOBLOOP
.M2:	CMP.L	2(A5),D0
.M3:	BMI	.6
.M5:	BGT	.6

      ENDGLOBVAR:			; 50
	TST.W	S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R.L	(A0)
.1:	RTS

	ENDIF
	

      INHERITOBJECT:			; A1=OBJECTHEAD, A2=MEMBERTAIL
	MOVEM.L	D0-D2/A0/A4-A6,-(A7)	; A3=SUPERCLASS INTERIM
	CMP.W	#31,(A3)+
	BNE	ERROR39
	MOVE.L	(A3)+,A0		; A0=SUPER
	MOVE.L	A0,OSUPER(A1)
	CMPA.L	A0,A1
	BEQ	ERROR50
	MOVE.W	ODESTR(A0),ODESTR(A1)
.NID:	TST.W	OID(A0)
	BEQ	ERROR39
	MOVE.W	OSIZE(A0),D1		; SET D1=OFFSET
	EXT.L	D1
	LEA	OMEMB+4(A0),A0		; A0=SUPERMEMBERLIST
.L:	MOVE.L	-(A0),A0
	MOVE.L	A0,D0
	BEQ.S	DONE1
	GETM	A4
	CLR.L	(A4)+
	MOVE.L	(A0)+,(A4)+
	MOVE.W	(A0)+,(A4)+
	MOVE.W	OBJCOUNT(PC),(A4)+
	ADDQ.L	#2,A0
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	LEA	-16(A0),A0
	LEA	-16(A4),A5
	MOVE.L	A5,(A2)
	LEA	ONEXT(A5),A2
	CLR.L	(A2)
	DONEM	A4
	BRA.S	.L
DONE1:	MOVE.L	D1,SUPERSIZE		; STACK NEW OSIZE FROM SUPER
	MOVE.L	OSUPER(A1),A0
	LEA	OMETHOD(A0),A0		; A0=SUPER.METHODS
	MOVE.L	OMETHOD(A1),D1		; D1=HEAD OWN.METHODS
	CLR.L	OMETHOD(A1)		; REMAKE FROM SCRATCH
.L2:	MOVE.L	(A0),D0			; M_NEXT
	BEQ	.DONE2
	MOVE.L	D0,A0
	MOVE.L	M_NAME(A0),D0		; D0=NAME
	TST.L	D1
	BEQ.S	.INH
	MOVE.L	D1,A4			; A4=SEARCH IN OWN METHODS
	MOVEQ	#0,D1
.L3:	MOVE.L	D0,A5
	MOVE.L	M_NAME(A4),A6
.L4:	CMPM.B	(A5)+,(A6)+		; STRCMP
	BNE.S	.C
	TST.B	-1(A6)
	BNE.S	.L4
	MOVE.L	(A4),A5			; LINK IN OVERRIDING METHOD
	MOVE.L	OMETHOD(A1),(A4)
	MOVE.L	A4,OMETHOD(A1)
	MOVE.W	M_OFF(A0),M_OFF(A4)	; SAME OFFSET
	MOVE.L	M_PROC(A0),A6
	MOVE.W	(A6),D2
	MOVE.L	M_PROC(A4),A6
	CMP.W	(A6),D2
	BEQ.S	.ASAME
	BSET	#1,M_FLAGS(A4)
.ASAME:	MOVE.L	A5,D2
	BEQ.S	.L2
	MOVE.L	A5,A6			; IF THERE'S PART OF OWNMETHODS
.L5:	TST.L	(A5)			; LEFT, RELINK IT.
	BEQ.S	.DD
	MOVE.L	(A5),A5
	BRA.S	.L5
.DD:	MOVE.L	D1,(A5)
	MOVE.L	A6,D1
	BRA.S	.L2
.C:	MOVE.L	(A4),-(A7)		; PICK NEXT OWN METHOD
	MOVE.L	D1,(A4)			; RELINK D1
	MOVE.L	A4,D1
	MOVE.L	(A7),A4
	TST.L	(A7)+
	BNE.S	.L3
.INH:	GETM	A4
	MOVE.L	OMETHOD(A1),(A4)
	MOVE.L	A4,OMETHOD(A1)
	ADDQ.L	#4,A4
	MOVE.L	M_PROC(A0),(A4)+
	MOVE.W	M_TYPE(A0),(A4)+
	BSET	#0,-1(A4)		; INHERITED
	MOVE.W	M_OFF(A0),(A4)+
	MOVE.L	M_NAME(A0),(A4)+
	DONEM	A4
	BRA	.L2
.DONE2:	MOVE.L	OSUPER(A1),A0		; ADD NEW METHODS (D1)
	MOVE.W	ODEL(A0),D0		; D0 = DELEGATESIZE
	MOVE.W	ODELOFF(A0),ODELOFF(A1)
	BSR.S	NEWMETHODS
	MOVEM.L	(A7)+,D0-D2/A0/A4-A6
	MOVE.L	SUPERSIZE,D1
	RTS

      NOINHERIT:
	MOVEM.L	D0-D2/A0/A4/A6,-(A7)
	CLR.W	ODEL(A1)
	MOVE.L	OMETHOD(A1),D1
	BEQ.S	.1
	CLR.L	OMETHOD(A1)
	MOVEQ	#4,D0
	BSR	NEWMETHODS
.1:	MOVEM.L	(A7)+,D0-D2/A0/A4/A6
	RTS
	
      NEWMETHODS:
	TST.L	D1
	BEQ.S	.DONE3

	TST.W	D0
	BNE.S	.SAFE
	MOVEQ	#4,D0			; INHERITANCE FROM METHOD-LESS OBJECT
.SAFE:	
	MOVE.L	D1,A4
.L6:	MOVE.L	(A4),D2			; NEW METHODS WITH OTHER M_OFF
	MOVE.L	OMETHOD(A1),(A4)
	MOVE.L	A4,OMETHOD(A1)
	MOVE.W	D0,M_OFF(A4)

	MOVE.L	M_NAME(A4),A6
	CMP.B	#'e',(A6)+
	BNE.S	.NEND
	CMP.B	#'n',(A6)+
	BNE.S	.NEND
	CMP.B	#'d',(A6)+
	BNE.S	.NEND
	TST.B	(A6)
	BNE.S	.NEND
	MOVE.L	M_PROC(A4),A0
	TST.W	(A0)			; .end() NO ARGS
	BNE	ERROR59
	BSET	#2,M_FLAGS(A4)
	MOVE.W	D0,ODESTR(A1)
.NEND:
	ADDQ.W	#4,D0
	MOVE.L	D2,A4
	TST.L	D2
	BNE.S	.L6
.DONE3:	MOVE.W	D0,ODEL(A1)
	RTS

      CREATEDELEGATEMEM:		; A1=OBJECTHEAD, A2=MEMBERTAIL
	MOVEM.L	A4-A5,-(A7)
	GETM	A4
	CLR.L	(A4)+			; .NEXT
	MOVE.W	D1,(A4)+		; .OFFSET
	MOVE.W	D1,ODELOFF(A1)
	ADDQ.W	#4,D1			; SET D1=OFFSET
	MOVE.W	#$0100,(A4)+		; .FLAGS
	MOVE.W	#4,(A4)+		; .SIZE
	MOVE.W	OBJCOUNT(PC),(A4)+	; .ID
	CLR.L	(A4)+			; .ASCII (PRIVATE)
	LEA	-12(A4),A5
	MOVE.L	A5,(A2)
	LEA	ONEXT(A5),A2
	CLR.L	(A2)
	DONEM	A4
	MOVEM.L	(A7)+,A4-A5
	RTS

      SUPERSIZE:	DC.L	0
      OBJCOUNT:		DC.W	0
      OBJPRIV:		DC.W	0	; 0=PUB / 1=PRIV

      CHECKPR:	MACRO			; \1=TR.DX
	MOVE.W	(A3),\1
	CMP.W	#IOFF+64,\1
	BNE.S	*+12
	CLR.W	OBJPRIV
	ADDQ.L	#2,A3
	BRA.S	*+18
	CMP.W	#IOFF+65,\1
	BNE.S	*+12
	MOVE.W	#1,OBJPRIV
	ADDQ.L	#2,A3
	ENDM

      FINDDOUBLEMEMBER:			; A0=MEMBER, A1=OBJH, USE D0, SAVE ALL
	MOVEM.L	A3-A5,-(A7)
	LEA	OMEMB+4(A1),A3
.L:	MOVE.L	ONEXT(A3),A3
	MOVE.L	A3,D0
	BEQ.S	.X
	CMP.L	A3,A0
	BEQ.S	.L
	MOVE.L	OASCII(A0),A4
	MOVE.L	OASCII(A3),A5		; ASCII
	MOVE.L	A5,D0
	BEQ.S	.L
.L2:	CMPM.B	(A5)+,(A4)+
	BNE.S	.L
	TST.B	-1(A5)
	BNE.S	.L2
	BRA	ERROR43
.X:	MOVEM.L	(A7)+,A3-A5
	RTS

      DOOBJECT:				; 55
	MOVE.L	A2,-(A7)
	CLR.W	OBJPRIV
	ADDQ.W	#1,OBJCOUNT
	MOVEQ	#0,D1			; D1=OFFSET !
	CMP.W	#31,(A3)+
	BNE	ERROR39
	MOVE.L	(A3)+,A1		; A1=OBJECT HEAD
	TST.W	OID(A1)
	BNE	ERROR43			; DOUBLE DECL OBJ
	MOVE.W	OBJCOUNT(PC),OID(A1)
	LEA	OMEMB(A1),A2		; A2=TAIL MEMLIST
	CLR.B	OFLAGS(A1)
	TST.W	EXPORTFLAG
	BEQ.S	.NE
	BSET	#0,OFLAGS(A1)		; EXPORT OBJECT
.NE:	TST.W	(A3)
	BEQ.S	.NOINH
	CHECKPR	D0
	TST.W	(A3)
	BEQ.S	.NOINH
	CMP.W	#IOFF+45,(A3)+		; OF <SUPERCLASS>
	BNE	ERROR39
	BSR	INHERITOBJECT		; WANTS A1,A2, SAVES ALL
	CHECKPR	D0
	BRA.S	.NOI
.NOINH:	BSR	NO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
	BRA	JOBLOOP
.3:	TST.L	D0

.4:	CMP.B	#$20,-6(A4)		; if "move.l x(a5),d0"
	BNE.S	.5B			; then del "tst.l d0"
	MOVE.B	-5(A4),D7
	CMP.B	#$2D,D7
	BEQ.S	.6
	CMP.B	#$2C,D7
	BNE.S	.5
.6:	MOVE.W	-4(A4),D1
	BPL.S	.5
	SUBQ.L	#2,A4
.5:	RTS
.5B:	MOVE.W	-4(A4),D7
	AND.W	#%1111111111111000,D7
	CMP.W	#$2000,D7
	BNE.S	.5
	SUBQ.L	#2,A4
	RTS

      DOELSECH:				; 57
	MOVE.W	#1,ELSECHECK
	BRA	JOBLOOP

      DORETURN:				; 58
	TST.L	HANDLERPEA
	BEQ.S	.2
	TST.L	ENDPEA
	BNE.S	.2
	LEA	.3(PC),A0
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
.2:	TST.W	PROCF
	BEQ	ERROR9
	MOVE.L	.1(PC),(A4)+
	MOVE.L	PROCEND(PC),D0
	CLR.W	NEWOP
	BSR	ADDBRANCH
	BRA	JOBLOOP
.1:	BRA	DORETURN
.3:	MOVE.L	(A7)+,-88(A4)		; (A5) ; ook: EXCEPT/Raise()
	MOVE.L	(A7)+,-76(A4)		; PUT PREVIOUS HANDLER BACK (CODE)
	MOVE.L	(A7)+,-80(A4)		; (STACK)

      MAKEBRANCHL:			; 59, like 8
	MOVE.L	LABPRES,D0
	MOVE.W	.1(PC),NEWOP
	BSR	ADDBRANCH
	BRA	JOBLOOP
.1:	JMP	.1

      JOBINSIF:				; 60
	TST.W	EXPRECC
	BNE.S	.1
	BSR.W	DOINSREC
	BRA	JOBLOOP
.1:	BSR	EXP
	BRA	JOBLOOP

      JOBEXPIF:				; 61
	MOVE.L	LABPRES(PC),-(A7)
	BSR	EXP
	MOVE.L	(A7)+,LABPRES
	BRA	JOBLOOP

      JOBFORSTEP:			; 62
	MOVE.L	-(A5),A1		; A1=IDENTREC
	MOVE.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A0)+,(A4)+
	MOVE.L	A4,HANDLERPEA
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	RTS
.1:	MOVE.L	-80(A4),-(A7)		; STACK
	MOVE.L	-76(A4),-(A7)		; CODE
	MOVE.L	-88(A4),-(A7)		; 
	MOVE.L	A7,-80(A4)
	LEA	.1(PC),A0		; TOTAL SIZE=5*.L, OFF=14
	MOVE.L	A0,-76(A4)
	MOVE.L	A5,-88(A4)

	HANDLERPEA:	DC.L	0
	ENDPEA:		DC.L	0

      DOEXCEPT:				; 64
	MOVEQ	#0,D1			; D1=DOFLAG
	CMP.W	#IOFF+28,(A3)
	BNE.S	.1
	MOVEQ	#1,D1
	ADDQ.L	#2,A3
.1:	LEA	EREST(PC),A0
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	TST.L	D1
	BEQ.S	.2
	ADDQ.L	#4,A0			; TAKE THE CLR INSTEAD OF BRA
.2:	MOVE.L	(A0)+,(A4)+
	MOVE.L	A4,ENDPEA
	MOVE.L	HANDLERPEA,D0
	BEQ	ERROR47
	MOVE.L	D0,A0
	SUB.L	A4,D0
	NEG.L	D0
	ADDQ.L	#2,D0
	MOVE.W	D0,-2(A0)
	BRA	JOBLOOP
EREST:	MOVE.L	(A7)+,-88(A4)		; (A5) ; ook: RETURN/Raise()
	MOVE.L	(A7)+,-76(A4)		; PUT PREVIOUS HANDLER BACK (CODE)
	MOVE.L	(A7)+,-80(A4)		; (STACK)
	BRA	EREST			; TO ENDPROC
	CLR.L	-84(A4)

      CLOSEHANDLER:			; 65
	TST.L	HANDLERPEA
	BEQ.S	.1
	MOVE.L	ENDPEA,D0
	BEQ	ERROR47
	MOVE.L	D0,A0
	CMP.W	#-84,-2(A0)		; CLR INSTEAD OF BRA
	BEQ.S	.1
	SUB.L	A4,D0
	NEG.L	D0
	ADDQ.L	#2,D0
	MOVE.W	D0,-2(A0)
.1:	BRA	JOBLOOP

      P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5)
	BNE.S	.CCCN
	SUBQ.L	#2,A3
	BRA.S	.CCCO
.CCCN:	BSR	DOINSMAIN
	MOVE.L	A4,CURACODE
	JSR	CHECK3
	BRA.S	.CCCL
.CCCO:	MOVEM.L	(A7)+,D5-D7/A6
	ENDM

BLOCK2:	MACRO				; note: same as BLOCK, without 3x check
	MOVEM.L	D5-D7/A6,-(A7)
	BEGL1
.CCCL:	BSR	WRITELINENUM		; TRASHES D7
	BEGL2
	MOVE.W	(A3)+,D7
	CMP.W	\2,D7
	BEQ	.CCCC
	BRA.S	.CCCN
.CCCC:	CMP.W	\1,-2(A5)
	BNE.S	.CCCN
	SUBQ.L	#2,A3
	BRA.S	.CCCO
.CCCN:	BSR	DOINSMAIN
	MOVE.L	A4,CURACODE
	JSR	CHECK3
	BRA.S	.CCCL
.CCCO:	MOVEM.L	(A7)+,D5-D7/A6
	ENDM

RANGC:	MACRO				; \1=DX
	TST.L	\1
	BMI	ERROR31
	CMP.L	D7,\1
	BPL	ERROR31
	ENDM

PUTRA:	MACRO				; \1=DX,\2=TRASH.DX
	MOVE.L	\1,\2
	LSL.L	#1,\2
	TST.W	0(A6,\2.L)
	BNE	ERROR50
	MOVE.W	D0,0(A6,\2.L)
	ENDM

      SELECTOF:				; 71
	CMP.W	#VALUE,(A3)
	BNE	JOBLOOP
	ADDQ.L	#2,A3
	MOVE.L	(A3)+,D7		; D7=RANGE
	CMP.L	#1,D7
	BMI	ERROR31
	CMP.L	#1024,D7
	BPL	ERROR31
	CMP.W	#IOFF+45,(A3)+
	BNE	ERROR0
	MOVE.L	D7,-(A7)
	BSR	EXP
	MOVE.L	(A7)+,D7
	BSR	NEWLABEL
	MOVE.L	D0,D5			; D5=ENDLABEL
	BSR	NEWLABEL
	MOVE.L	D0,D6			; D6=DEFAULTLABEL
	MOVE.L	.C1(PC),(A4)+
	CLR.W	(A4)+
	CLR.W	NEWOP
	BSR	ADDBRANCH
	MOVE.W	.C2(PC),(A4)+
	MOVE.L	D7,(A4)+
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E:	MOVE.W	.NUKE2(PC),(A4)+
	BSR	GVA0D1_0
	MOVE.W	.NUKE3(PC),(A4)+
	MOVE.W	D0,(A4)+
	RTS
.NUKE:	CLR.L	2(A5)
.NUKE2:	MOVE.L	2(A5),A0
.NUKE3:	CLR.L	4(A0)

DESTR:	MOVE.W	ODESTR(A6),D2		; GETS OBJ=A6, OSIZE=D0
	BMI.W	.XX			; D2=ENDOFF
	MOVE.W	.7(PC),(A4)+
	BSR.S	.GEND
	MOVE.W	.6A(PC),(A4)+
	MOVE.W	D2,(A4)+
	MOVE.W	.6B(PC),(A4)+
.XX:	TST.W	ODEL(A6)
	BEQ.S	.XXX
	MOVE.W	.GS(PC),(A4)+
	BSR.S	.GEND
	MOVE.W	.GS2(PC),(A4)+
	MOVEQ	#-1,D0			; SIGNAL SIZE ALREADY on (A7)
.XXX:	RTS
.GS:	MOVE.L	(A7),A0
.GS2:	MOVE.L	(A1),-(A7)
.7:	MOVEA.L	D0,A0
.6:	MOVE.L	(A0),A1
.6X:	MOVE.L	2(A0),A1
.6A:	MOVE.L	4(A1),A1
.6B:	JSR	(A1)
.GEND:	TST.W	ODELOFF(A6)
	BMI	ERROR71
	BHI	.U
	MOVE.W	.6(PC),(A4)+
	RTS
.U:	MOVE.W	.6X(PC),(A4)+
	MOVE.W	ODELOFF(A6),(A4)+
	RTS

; GETS BRANCH TO FILL AT -2(A4)

      FILLEXIT:				; 75
	MOVE.W	-2(A5),D0
	CMP.W	#3,D0
	BNE.S	.1
	MOVE.L	-10(A5),D0
	BRA.S	.D
.1:	CMP.W	#4,D0
	BNE	ERROR9
	MOVE.L	-14(A5),D0
.D:	BCHG	#0,-4(A4)		; negate CC
	CLR.W	NEWOP
	BSR	ADDBRANCH
	BRA	JOBLOOP

      DOSUPER:				; 76
	BSR	SUPEREXP
	BRA	JOBLOOP


;;JOB

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	Instruction JobCode And Data Part			;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;

      DUM:
      INSJOBTAB:
	DC.L	.PROC,.ENDPROC,.IF,.ENDIF,.VOID,.WHILE,.ENDWHILE
	DC.L	.FOR,.ENDFOR,.SELECT,.CASE,.DEFAULT,.ENDSELECT
	DC.L	.REPEAT,.UNTIL,.JUMP,.DEF,.LOCAL,.ELSE,.INCBIN
	DC.L	.LONG,.INT,.CHAR,.INC,.DEC,.THEN,.LOOP,.ENDLOOP
	DC.L	.ERROR,.ERROR,.ERROR,.ERROR,.ERROR,.ERROR,.ERROR
	DC.L	.EXIT,.ERROR,.ERROR,.ERROR,.ERROR,.ERROR,.ERROR
	DC.L	.ERROR,.ERROR,.ERROR,.ERROR,.ELSEIF,.ERROR,.OBJECT
	DC.L	.ERROR,.ERROR,.RETURN,.ERROR,.ERROR,.ERROR,.ERROR
	DC.L	.ERROR,.EXCEPT,.ERROR,.ERROR,.ERROR,.END,.ERROR
	DC.L	.NEW,.ERROR,.ERROR,.SUPER,.ERROR,.ERROR


.PROC:		DC.W	50,19,17,36,33,1,37,10
		LINK	A5,#-27*4
		DC.W	34,73,72,63,5,1,70,7,1,65,16,18,9
		UNLK	A5
		DC.W	68,0
.ENDPROC:	DC.W	7,1,65,16,18,9
		UNLK	A5
		DC.W	68,0
.RETURN:	DC.W	16,58,0
.EXIT:		DC.W	61,56
		TST.L	D0
		BEQ	DUM
		DC.W	75,0
.IF:		DC.W	51,6,61,56
		TST.L	D0
		BEQ	DUM
		DC.W	8,5,2,43,IOFF+25,60,45,IOFF+18,7,2,28,10
		BRA	DUM
		DC.W	57,29,27,15,26,5,2,60,46,0,7,2,15,54,0
.ELSE:		DC.W	7,2,28,10
		BRA	DUM
		DC.W	29,27,15,26,5,2,0
.ELSEIF:	DC.W	7,2,28,10
		BRA	DUM
		DC.W	27,15,52,26,2,12
		TST.L	D0
		BEQ	DUM
		DC.W	29,5,2,0
.ENDIF:		DC.W	7,2,15,53,0
.VOID:		DC.W	2,0
.WHILE:		DC.W	6,20,61,56
		TST.L	D0
		BEQ	DUM
		DC.W	8,5,3,43,IOFF+28,42,7,3,21,10
		BRA	DUM
		DC.W	8,15,0
.ENDWHILE:	DC.W	7,3,21,10
		BRA	DUM
		DC.W	8,15,0
.FOR:		DC.W	3,47,2,10
		MOVE.L	D0,2(A5)
		DC.W	35
		DC.W	20,49,5,4,43,IOFF+28,42,7,4,62,10
		BRA	DUM
		DC.W	15,21,8,0
.ENDFOR:	DC.W	7,4,62,10
		BRA	DUM
		DC.W	15,21,8,0
.SELECT:	DC.W	71,3,23,6,28,32,66,5,5,0
.CASE:		DC.W	7,5,67,27,31,3,10
		BRA	DUM
		DC.W	29,30,15,2,24,10
		CMP.L	2(A5),D0
		DC.W	22,10
		BNE	DUM
		DC.W	23,6,8,26,66,5,5,0
.DEFAULT:	DC.W	7,5,67,27,10
		BRA	DUM
		DC.W	29,15,24,23,6,26,66,5,5,0
.ENDSELECT:	DC.W	7,5,67,15,15,24,0
.REPEAT:	DC.W	20,5,6,0
.UNTIL:		DC.W	7,6,21,61,56
		TST.L	D0
		BEQ	DUM
		DC.W	8,0
.JUMP:		DC.W	1,10
		BRA	DUM
		DC.W	59,0
.DEF:		DC.W	33,3,0
.LOCAL:		DC.W	33,2,0
.INCBIN:	DC.W	38,0
.LONG:		DC.W	39,0
.INT:		DC.W	40,0
.CHAR:		DC.W	41,0
.DEC:		DC.W	3,10
		SUBQ.L	#1,-4(A5)
		DC.W	22,0
.INC:		DC.W	3,10
		ADDQ.L	#1,-4(A5)
		DC.W	22,0
.THEN:		DC.W	44,0
.LOOP:		DC.W	20,5,7,0
.ENDLOOP:	DC.W	7,7,21,10
		BRA	DUM
		DC.W	8,0
.ERROR:		DC.W	44,0
.OBJECT:	DC.W	55,0
.EXCEPT:	DC.W	7,1,64,5,1,0
.NEW:		DC.W	69,0
.END:		DC.W	74,0
.SUPER:		DC.W	76,0


;;ADDRESS

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The Calculate-Addresses-For-BRAnches Part		;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


      CALCADR:
	MOVE.W	#10,CURSPOT
	MOVE.L	ACODE(PC),D2
	MOVE.L	CURACODE(PC),A4		; A4=CODE
	MOVE.L	A4,D4
	BTST	#1,D4
	BEQ.S	.1
	CLR.W	(A4)+
	MOVE.L	A4,D4
.1:	SUB.L	D2,D4
	MOVE.L	D4,CODEAMOUNT		; CLEANOFF AND SET CODESIZE
	MOVE.L	D2,D7			; D7=START CODE

	TSTMOD
	BNE.S	.NM
	TST.W	MAINF
	BEQ	ERROR13
.NM:	LEA	BRANCHLIST(PC),A5	; A5=BRANCHES
	MOVE.L	LABM+8(PC),A6		; A6=LABELS
	MOVE.L	CURLABNAME(PC),D0
	LSL.L	#2,D0
	ADD.L	A6,D0
	MOVE.L	D0,LABM			; SET USED
	BSR	PUTRELOC
      BRLOOP:
	MOVE.L	(A5),A5
	MOVE.L	A5,D0
	BEQ.S	BROUT
	MOVE.L	4(A5),A0		; BRAnch spot
	MOVEQ	#0,D0
	MOVE.W	8(A5),D0
	BEQ.S	BROUT
	LSL.L	#2,D0
	MOVE.L	0(A6,D0.L),D2		; BRAnch to
	BTST	#0,1(A0)		; IF BIT=1 --> .B OR .L RELOC
	BNE.S	OTHERRELOC
	SUB.L	A0,D2
	CMP.L	#$7FF0,D2
	BPL	ERROR44
	CMP.L	#-$7FF0,D2
	BMI	ERROR44
	MOVE.W	D2,(A0)
	BRA.S	BRLOOP
      BROUT:
	MOVE.L	NUMRELOC,D0
	BEQ.S	.1
	CLR.L	(A4)+
	MOVE.L	NUMRELADR,A0
	MOVE.L	D0,(A0)
.1:	BSR	BUILDSYMHUNK
	MOVE.L	A4,CURACODE		; SET BACK.
	RTS
      OTHERRELOC:
	BTST	#1,1(A0)
	BNE.S	LONG
	BTST	#2,1(A0)		; 8 bit pcrel
	BEQ.S	.1
	SUBQ.L	#2,D2
.1:	SUB.L	A0,D2
	BEQ	ERROR45
	CMP.L	#120,D2
	BPL	ERROR45
	CMP.L	#-120,D2
	BMI	ERROR45
	MOVE.B	D2,1(A0)		; PTR A0 = RELOCEND-2
	BRA	BRLOOP
      LONG:
	BSR	INCRELOC
	TST.W	2(A0)			; SEE IF THERE'S EFUNCNUM
	BNE.S	.2
	SUB.L	D7,D2
	MOVE.L	D2,(A0)
	SUB.L	D7,A0
	MOVE.L	A0,(A4)+
	BRA	BRLOOP
.2:	SUB.L	D7,A0			; EFUNC CALL, BIT #32 SET.
	MOVE.L	A0,D0
	MOVEQ	#31,D2
	BSET	D2,D0
	MOVE.L	D0,(A4)+
	BRA	BRLOOP

      INCRELOC:
	TST.L	NUMRELOC		; 32BIT RELOC
	BNE.S	.1
	MOVE.L	#$3EC,(A4)+
	MOVE.L	A4,NUMRELADR
	ADDQ.L	#4,A4
	MOVE.L	A4,RELOCTABSTART
	CLR.L	(A4)+
.1:	ADDQ.L	#1,NUMRELOC
	RTS

NUMRELOC:	DC.L	0
NUMRELADR:	DC.L	0

; LAST RELOC BYTE:
; <xx0> BIT #0 CLR -->                PCREL RELOC16
; <001>        SET --> BIT #1 CLR --> PCREL RELOC8
; <101>        SET --> BIT #1 CLR --> PCREL RELOC8 + ADJUST
; <x11>                       SET --> ABS   RELOC32 (ENTRY IN RELOCTAB)

      DIVRELOC:	DC.L	0

      ADDDIVRELOC:			; ADR=D0
	MOVE.L	A0,-(A7)
	GETM	A0
	MOVE.L	DIVRELOC(PC),(A0)
	MOVE.L	A0,DIVRELOC
	ADDQ.L	#4,A0
	MOVE.L	D0,(A0)+
	DONEM	A0
	MOVE.L	(A7)+,A0
	RTS

      PUTRELOC:
	MOVEM.L	A0-A3/A6/D0-D7,-(A7)	; EXPECTS CODE IN A4
	LEA	CODELIST(PC),A0		; A0=CODEREM
 	MOVE.L	LABM+8,A2		; A2=LABELS
.L:	MOVE.L	(A0),A0
	MOVE.L	A0,D0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L-ID
	LSL.L	#2,D1
	MOVE.L	0(A0,D1.L),D1
	SUB.L	D3,D1
	MOVE.L	D1,(A4)+
	ADDQ.L	#1,D0
	BRA	.LOOP
ESYMS:
	MOVE.L	#EFUNCBYTE,A3
	MOVE.W	#NREFUNC,D2
	SUBQ.W	#1,D2
	MOVE.L	#EFUNCTAB,D7
	MOVEQ	#0,D6
.3:	TST.B	(A3)+
	BEQ.S	.4
	MOVE.L	D7,A1
	MOVE.L	D6,D5
	LSL.L	#4,D5
	ADD.L	D5,A1			; (a1)=ptr ascii

	TST.L	D0			; FIRST SYM, START HUNK
	BNE.S	.NF
	MOVE.L	#$3F0,(A4)+
.NF:	CLR.L	(A4)+
	MOVE.L	A4,A6			; A6=BACKPATCH
	MOVE.L	(A1),A2			; A2=ASCII
.CL:	MOVE.B	(A2)+,(A4)+
	BNE.S	.CL
	MOVE.L	A4,D4
	BTST	#0,D4
	BEQ.S	.1
	ADDQ.L	#1,D4
.1:	BTST	#1,D4
	BEQ.S	.2
	ADDQ.L	#2,D4
.2:	MOVE.L	D4,A4
	SUB.L	A6,D4
	LSR.L	#2,D4
	MOVE.W	D4,-2(A6)
	MOVE.L	D6,D1
	ADD.L	#10,D1
	LSL.L	#2,D1
	MOVE.L	0(A0,D1.L),D1
	SUB.L	D3,D1
	MOVE.L	D1,(A4)+

.4:	ADDQ.L	#1,D6
	DBRA	D2,.3

	TST.L	D0
	BEQ.S	NOSYM
	CLR.L	(A4)+
NOSYM:	MOVEM.L	(A7)+,D0-D7/A0-A3/A5/A6
	RTS

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The Expression Calculation Part				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


; ea specific version of EXP: optimizes some superfluous code away
;
; HANDLED ARE:
;
; MOVE.L #VAL,D0		6	1
; LEA X(PC),A0; MOVE.L A0,D0	6	'bla'
; MOVE.L X(A5),D0		4	a
; MOVEQ #VAL,D0			2	1
; MOVE.L Dx,D0			2	a
;
; RESULT IN D0:		0	NO OPTI DONE
;			1	OPTI DONE, BUT DON'T MOVE (MAY USE A0 TOO)
;			<ADR>	OPTI DONE, <ADR>..A4 IS CODE

      EAEXP:
	MOVEM.L	A1/D3/D4,-(A7)
	MOVE.L	A4,A1
	BSR	EXP
	MOVE.L	A4,D3
	SUB.L	A1,D3
	CMP.L	#7,D3
	BPL	.X
	CMP.L	#2,D3
	BNE.S	.1

; MOVEQ

	CMP.B	#%01110000,(A1)
	BNE	.M
	MOVE.W	EAREQUEST(PC),D3
	CMP.W	#17,D3
	BPL	.X
	CMP.W	#16,D3
	BEQ.S	.3
	CMP.W	#8,D3
	BPL.S	.5
	LSL.W	#1,D3
	OR.B	D3,(A1)			; ** MOVEQ #1,Dx
	BRA	.OK
.3:	MOVE.B	1(A1),D4
	EXT.W	D4
	MOVE.W	D4,(A4)+		; ** PEA 1.W
	MOVE.W	.4(PC),(A1)
	BRA	.OK
.4:	PEA	1.W
.5:	MOVE.B	1(A1),D4
	EXT.W	D4
	MOVE.W	D4,(A4)+		; ** MOVE.W 1,Ax
	MOVE.W	.6(PC),D4
	LSL.W	#8,D3
	LSL.W	#1,D3
	OR.W	D3,D4
	MOVE.W	D4,(A1)
	BRA	.OK
.6:	MOVE.W	#1,A0
.1:	CMP.L	#4,D3
	BNE.S	.2


; VAR
	MOVE.W	(A1),D3
	BCLR	#0,D3
	CMP.W	#%0010000000101100,D3
	BNE	.X

	BSR.W	DOOPT			; ** MOVE.L 2(A5),Rx/-(A7)/2(A5)
	BRA	.OK

; MOVE.L Dx,D0

.M:	MOVE.W	(A1),D3
	AND.W	#%1111111111111000,D3
	CMP.W	#%0010000000000000,D3
	BNE	.X
	BSR	DOOPT			; ** MOVE.L Dx,Rx/-(A7)/2(A5)
	BRA	.OK


.2:	CMP.W	#%0100000111111010,(A1)
	BEQ.S	.7

; MOVE.L

	CMP.W	#%0010000000111100,(A1)
	BNE.S	.X
	M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(A5)
	MOVE.L	A2,D4
	MOVE.L	A6,D0
	LEA	-2(A4),A2
	CMPA.L	A2,A1
	BEQ	GRUNT
	MOVE.W	(A2),-(A7)
	MOVE.W	(A1),(A2)
	MOVE.L	EAIDENT(PC),A6
	BSR	GVA6D3_9
	MOVE.W	(A2),(A1)
	MOVE.W	(A7)+,(A2)
	MOVE.L	D0,A6
	MOVE.L	D4,A2
	RTS
GRUNT:	MOVE.L	EAIDENT(PC),A6
	BSR	GVA6D3_9
	MOVE.L	D0,A6
	MOVE.L	D4,A2
	RTS



      EAREQUEST:	DC.W	0	; 0-15=REG, 16=STACK, 17,25=VAR
      EAIDENT:		DC.L	0

      TINYEXP:				; GENERATES CODE FOR D0, JUST VALUES
	MOVE.W	(A3)+,D0		; TRASHES JUST D0
	CMP.W 	#VALUE,D0
	BEQ.S	.1
	CMP.W	#43,D0
	BEQ.S	.1
	CMP.W	#8,D0
	BNE	ERROR30
	CMP.W	#43,(A3)
	BEQ.S	.NF
	CMP.W	#VALUE,(A3)+
	BNE	ERROR30
	MOVE.L	(A3)+,D0
	NEG.L	D0
	BRA.S	.2
.1:	MOVE.L	(A3)+,D0
.2:	CMP.L	#128,D0
	BPL.S	.3
	CMP.L	#-128,D0
	BMI.S	.3
	MOVE.B	.4(PC),(A4)+
	MOVE.B	D0,(A4)+
	RTS
.3:	MOVE.W	.5(PC),(A4)+
	MOVE.L	D0,(A4)+
	RTS
.4:	MOVEQ	#1,D0
.5:	MOVE.L	#1,D0
.NF:	ADDQ.L	#2,A3
	MOVEM.L	D0-D1/A0-A1/A6,-(A7)
	BSR	ISOPENMATH
	MOVE.L	MATHBASE(PC),A6
	MOVE.L	(A3),D0
	JSR	-60(A6)			; SPNEG
	MOVE.L	D0,(A3)
	MOVEM.L	(A7)+,D0-D1/A0-A1/A6
	BRA.S	.1


      FINDMEMBER:	; *** FIND O.MEMBER, D1=TRASH,a1=first->REAL,a6=obj
	MOVE.W	OID(A6),D1
	CMP.W	OID(A1),D1
	BE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OVE.L	D3,D4
	MULU	D5,D4
	ADD.L	D4,D1
	BSR	GEND2

; FROM HERE D3=-1(D2 ALREADY CALC.), >0(RELA0)

.CONT:	;MOVE.L	#1,.SPEC		; TO BE SURE
	TST.B	.TDRF
	BNE.S	.NXA5
	MOVE.W	.OPC(PC),(A4)+		; MOVE.L X(A5),A0
	BSR	GVA0D4_0
.NXA5:	BTST	#1,CODEPREFS+3
	BEQ.S	.NNCH
	BSR	NILCHECK
.NNCH:	MOVEQ	#0,D4
	CMP.L	D4,A1
	BEQ.S	.16
	MOVE.W	4(A1),D4		; D4=READSIZE
	BTST	#1,OFLAGS(A1)
	BEQ.S	.17 ;16B			; was 17! (caused uninit .spec)
	MOVE.L	OPTRTYPE(A1),.SPEC
	BRA.S	.17
.16:	MOVE.L	D5,D4
.16B:	MOVE.L	#1,.SPEC
.17:	

	CLR.B	.TDRF
	CMP.W	#35,(A3)		; "." (SLOW)
	BEQ.S	.DD
	CMP.W	#41,(A3)		; "::"
	BEQ.S	.DD
	CMP.W	#29,(A3)		; "["
	BNE.S	.NDD
.DD:	MOVE.B	#1,.TDRF		; THROUGH-DEREF x.y.z
	MOVE.B	D0,.ORIGD0
	MOVE.W	#3,D0			; TDR MODE
	TST.L	D4
	BEQ.S	.DD1
	CMP.W	#4,D4
	BNE	ERROR40
	BRA.S	.DD2
.DD1:	ADDQ.W	#4,D0
.DD2:	TST.W	D2
	BNE	ERROR40
	BRA.S	.18

.NDD:


	TST.W	D4
	BNE.S	.NP
	CMP.W	#2,D0
	BEQ	ERROR40
	ADD.W	#4,D0			; SET TO GET POINTER TO SUBSTRUCT
	BRA.S	.18
.NP:	BSR	.MOVEQ
.18:	CMP.L	#$10000,D0
	BPL.S	.23
	TST.L	D3
	BPL.W	.40

; *** indexed version

	LSL.W	#2,D0
	MOVE.L	.20(PC,D0.W),(A4)+
	LSR.W	#2,D0
	BSR	.EXTL
	CMP.W	#2,D4
	BEQ	.21
	BPL.S	.22
	TST.W	D4
	BEQ	.DO			; SKIP MOVE.X SET
	BCLR	#5,-4(A4)
	BRA	.21
.22:	BCLR	#4,-4(A4)
	BRA	.21

.20:	MOVE.W	0(A0,D2.L),D0		; LONG
	MOVE.W	0(A0,D2.L),D1
	MOVE.W	D0,0(A0,D2.L)
	MOVE.W	0(A0,D2.L),A0
	LEA	0(A0,D2.L),A0
	LEA	0(A0,D2.L),A0
	LEA	0(A0,D2.L),A0
	LEA	0(A0,D2.L),A0

; *** simple version

.23:	LSL.W	#1,D0
	MOVE.W	.24(PC,D0.W),(A4)+	
	LSR.W	#1,D0
	BSR	.EXTL
	CMP.W	#2,D4
	BEQ.W	.21
	BPL.S	.25
	TST.W	D4
	BEQ.S	.DO			; SKIP MOVE.X SET
	BCLR	#5,-2(A4)
	BRA.S	.21
.25:	BCLR	#4,-2(A4)
	BRA.S	.21

.24:	MOVE.W	(A0),D0
	MOVE.W	(A0),D1
	MOVE.W	D0,(A0)
	MOVE.W	(A0),A0
	LEA	(A0),A0
	LEA	(A0),A0
	LEA	(A0),A0
	LEA	(A0),A0

; *** relative(a0) version

.40:	LSL.W	#2,D0
	MOVE.W	.42(PC,D0.W),(A4)+
	LSR.W	#2,D0
	MOVE.W	D3,(A4)+
	BSR	.EXTL
	CMP.W	#2,D4
	BEQ.S	.21
	BPL.S	.41
	TST.W	D4
	BEQ.S	.DO			; SKIP MOVE.X SET
	BCLR	#5,-4(A4)
	BRA.S	.21
.41:	BCLR	#4,-4(A4)
	BRA.S	.21

.42:	MOVE.W	2(A0),D0
	MOVE.W	2(A0),D1
	MOVE.W	D0,2(A0)
	MOVE.W	2(A0),A0
	LEA	2(A0),A0
	LEA	2(A0),A0
	LEA	2(A0),A0
	LEA	2(A0),A0

; LAST PARTS:

.DO:	SUB.W	#4,D0			; DO ADDITIONAL MOVE
	TST.B	.TDRF
	BNE.S	.DLOOP
	LSL.W	#1,D0
	MOVE.W	.MA0(PC,D0.W),(A4)+
	LSR.W	#1,D0
	
.21:	TST.B	.TDRF
	BNE.S	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:	ADD.L	#1,D2


XIT:	MOVEM.L	(A7)+,D3-D5/A1
	RTS


; WERE NOT TO DISTURB ANY REGS, NOT EVEN IN GENERATED CODE (D1?)
; (IN CODE): PTR TO CHECK IS IN A0

      NILCHECK:
	MOVEM.L	D0/D1/A0/A6,-(A7)
	MOVE.L	.CH(PC),(A4)+
	MOVE.L	A4,A6			; A6=BRANCH BACKPATCH
	MOVE.L	.ARGS(PC),(A4)+
	MOVE.L	.ARGS+4(PC),(A4)+
	MOVE.W	LINENUM(PC),D0
	ADDQ.W	#1,D0
	MOVE.W	D0,(A4)+
	MOVEQ	#90+10,D0		; D0=FASTNEW
	MOVE.B	#-1,EFUNCBYTE+90	; fastnew=91
	MOVE.L	.4(PC),(A4)+		; GEN CALL
	TSTMOD
	BNE.S	.MOD
	MOVE.W	.5(PC),NEWOP
	BSR	ADDBRANCH
	BRA.S	.CC
.MOD:	SUBQ.L	#4,A4
	MOVE.W	.5(PC),(A4)+
	BSR	ADDBRANCHRELOC
	MOVE.W	D0,-2(A4)
.CC:	MOVE.W	.SB(PC),(A4)+
	MOVE.L	A4,D0
	SUB.L	A6,D0
	MOVE.B	D0,-(A6)
	MOVEM.L	(A7)+,D0/D1/A0/A6
	RTS
.CH:	MOVE.L	A0,D1
	BNE.S	.CH
.ARGS:	MOVE.L	#"NIL",-(A7)
	PEA	$10.W
.SB:	ADDQ.L	#8,A7
.5:	JSR	.CH
.4:	BSR.W	.CH
	

;;EXP
      EXPRECC:	DC.W	0		; RECURSION DEPTH OF EXP()

      EXP:				; GENERATES EXP FOR D0
	MOVEM.L	D3-D5/A1/A2,-(A7)	; WE DO HEAVY RECURSION
	MOVE.W	FLTFLAG(PC),-(A7)
	CLR.W	FLTFLAG
	ADDQ.W	#1,EXPRECC
	MOVEQ	#6,D4			;
	MOVEQ	#-1,D5			; MUST BE = EXPBUT
	LEA	EXPMOVE(PC),A1		;
      EXPLOOP:
	MOVE.W	(A3)+,D0
	BEQ	EXPOUT
	CMP.W	#COM,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,A0
	MOVE.W	(A0),D6
	EXT.L	D6
.TTD:	CMP.W	#30,(A3)
	BEQ.S	.NLO
.NLL:	TST.L	D7
	BEQ.S	.NOBJ
	TST.L	D2
	BEQ	ERROR46
	MOVE.L	D2,A0
	;MOVE.L	OASCII(A0),D1		; PRIVATE MEMBER IN OBJECT
	;BEQ	ERROR60
	;BTST	#0,OFLAGS(A0)
	;BNE	ERROR60
	MOVE.W	OSIZE(A0),D1		; ARRAY IN OBJECT
	BEQ	ERROR40
.NOBJ:	MOVEM.L	D1/D2/D6/D7/A6,-(A7)
	BSR	EXP
	MOVEM.L	(A7)+,D1/D2/D6/D7/A6
	MOVE.W	.LOAD(PC),(A4)+
	MOVE.B	.TAB(PC,D1.W),D0
	EXT.W	D0
	MOVE.W	.STORE(PC,D0.W),(A4)+
	MOVE.W	D6,(A4)+
	TST.L	D7
	BNE.S	.TOBJ
	ADD.L	D2,D6
	BRA.S	.NLO
.STORE:	MOVE.B	D0,2(A6)
	MOVE.W	D0,2(A6)
	MOVE.L	D0,2(A6)
.TAB:	DC.B	8,0,4,0,8,0
.TOBJ:	MOVE.L	D2,A0
	MOVE.L	-(A0),A0
	MOVE.L	A0,D2			; stop if last in memberchain
	BEQ.S	.TEND
	MOVE.W	(A0),D6
	EXT.L	D6
	BRA.S	.NLO
.TEND:	CMP.W	#30,(A3)+
	BNE	ERROR0
	BRA.S	.TC
.NLO:	CMP.W	#COM,(A3)+		; end of loop
	BEQ.S	.NLL
	CMP.W	#30,-2(A3)		; expect an "]"
	BNE	ERROR0
.TC:	TST.L	D7
	BNE.S	.SK1A			; only if its a list, NO OBJ, SIZE=4
	CMP.W	#4,D2
	BNE.S	.SK1
	CMP.W	#19,(A3)		; IF ":" THEN IT WASN'T A LIST
	BEQ.S	.SK1
	MOVE.L	.SL(PC),(A4)+
	MOVE.L	D6,D0
	LSR.L	#2,D0
	SUBQ.L	#1,D0
	MOVE.W	D0,(A4)+
	MOVE.W	D0,(A4)+
	MOVE.W	.SL2(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L	#800,D2
	BPL	ERROR46
	BRA	EXPLOOP


      EXPSTRINGCODE:
	LEA	EXPSTRINGCODE2(PC),A0	; 6-2 BYTES
	MOVE.L	A0,D1
      EXPSTRINGCODE2:
	LEA	EXPSTRINGCODE(PC),A0	; 6-2 BYTES
	MOVE.L	A0,D0
      LONGLEA:
	LEA	EXPSTRINGCODE,A0

      MAKESTRLEN:
	MOVE.L	#0,-36(A4)
      MAKESTRLEN2:
	MOVEQ	#0,D0
	MOVE.L	D0,-36(A4)

      D0EXT:	EXT.L	D0

      EXPREC:
	CMP.W	#1,D5
	BEQ	ERROR0
	BSR.W	SD0
	BSR.W	EXP
	BSR.W	RD0
	ADDQ.L	#2,A3
	MOVEQ	#1,D5
	BRA	EXPLOOP

      EXPCONSNIL:
	MOVEQ	#1,D5
	MOVEQ	#0,D1
	BRA	VALUENTRY

      EXPCONS:
	CMP.W	#1,D5
	BEQ	ERROR0
	BSR.W	SD0
	CLR.W	-(A7)
.L:	MOVE.W	#16,EAREQUEST
	BSR	EAEXP
	TST.L	D0
	BNE.S	.OPT
	MOVE.W	.4(PC),(A4)+
.OPT:	ADDQ.W	#4,(A7)
	CMP.W	#COM,(A3)+
	BEQ.S	.L
	CMP.W	#46,-(A3)
	BNE.S	.NC
	ADDQ.L	#2,A3
	MOVE.W	#16,EAREQUEST
	BSR	EAEXP
	TST.L	D0
	BNE.S	.OPT2
	MOVE.W	.4(PC),(A4)+
.OPT2:	BRA.S	.D
.NC:	MOVE.W	.5(PC),(A4)+
.D:	CMP.W	#12,(A3)+
	BNE	ERROR0
	MOVE.W	.6(PC),(A4)+
	MOVE.W	(A7),D0
	SUBQ.W	#4,D0
	MOVE.W	D0,(A4)+
	MOVE.L	#120+10,D0		; D0=CONS
	MOVE.B	#-1,EFUNCBYTE+120	; _Cons=121
	MOVE.L	.4B(PC),(A4)+		; GEN CALL
	TSTMOD
	BNE.S	.MOD
	MOVE.W	.5B(PC),NEWOP
	BSR	ADDBRANCH
	BRA.S	.CC
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
      CLOSEFLT:
	CMP.W	#-1,D5			; NO MOVE
	BEQ.S	CLFLTB
	CMP.L	#EXPCMP,A1		; NO AND/OR
	BMI.S	CLFLTB
	MOVE.L	D0,-(A7)
	BSR	MAKEFLTOPER
	TST.W	D0
	BNE.S	.2			; SEE IF SPCMP
	MOVE.W	D3,(A4)+
	MOVE.L	EXTL(PC),(A4)+
.2:	MOVE.L	(A7)+,D0
	RTS

RD0:	CMP.W	#-1,D5
	BEQ.S	.1
	MOVE.L	EXPRCODE2(PC),(A4)+
	BSR	CLOSEEXP
.1:	RTS

SD0:	CMP.W	#-1,D5
	BEQ.S	.1
	MOVE.W	EXPRCODE1(PC),(A4)+
.1:	RTS

      EXPIMMLIST:			; D3-D5/A1/A3-A5
	ADDQ.L	#4,A3			; SKIP ]OFFSET
	CMP.W	#-1,D5
	BNE	ERROR0
	CMP.W	#30,(A3)
	BEQ	.2
	MOVE.L	A5,A0			; A0=BACKUP
	CLR.W	(A5)+
	MOVEQ	#0,D7			; D7=COUNT
.1:	MOVE.W	(A3),D1
	CMP.W	#8,D1			; *** read list from a3
	BEQ	.VALM
	CMP.W	#VALUE,D1
	BEQ	.VAL
	CMP.W	#IOFF+50,D1		; SIZEOF
	BEQ	.VAL
	CMP.W	#STR,D1
	BEQ	.STRI
.VALMB:	MOVEM.L	D7/A0,-(A7)
	BSR.W	EXP			; *** gen exp code
	MOVE.L	A4,CURACODE		;
	JSR	CHECK3			; CHECKA4
	MOVEM.L	(A7)+,D7/A0
	MOVE.W	EXPRCODE1(PC),(A4)+
	MOVE.W	#2,(A5)+		; 1=VAL, 2=EXP, 3=STR, 0=END
.R:	ADDQ.L	#1,D7

	CHESTB	A5,D1,10,ERROR46

	CMP.W	#COM,(A3)+
	BEQ.S	.1
	CMP.W	#30,-2(A3)
	BNE	ERROR34
	CLR.W	(A5)+
	LEA	.8(PC),A2
	MOVE.L	(A2)+,(A4)+
	MOVE.L	(A2)+,(A4)+
	MOVE.L	(A2)+,(A4)+
	MOVE.L	A4,A2			; A2 -->BRANCH
	MOVE.L	A5,D6			; D6=NEWBUF ON STACK!
	MOVE.L	A0,A5

	MOVE.L	D6,A6			; FREE BUF
	MOVE.L	#$00040000,(A6)
	CMP.W	#19,(A3)		; FREE: _D6_,D0-D2,_A6_
	BNE	.TLO
	ADDQ.L	#2,A3			; *** read object
	MOVE.W	(A3)+,D0
	CMP.W	#IOFF+20,D0		; LONG
	BEQ	.TLO
	CMP.W	#IOFF+21,D0		; INT
	BNE.S	.TL2
	MOVE.L	#$00020000,(A6)
	BRA	.TLO
.TL2:	CMP.W	#IOFF+22,D0		; CHAR
	BNE.S	.TL3
	MOVE.L	#$00010000,(A6)
	BRA.S	.TLO
.TL3:	CMP.W	#31,D0
	BNE	ERROR33

	MOVEM.L	D3/D4/A0-A1,-(A7)
	MOVEQ	#0,D3			; D3(TEMP)=GLOBAL OFFSET
	MOVE.L	(A3)+,A0		; A0(TEMP)=OBJ
	CMP.W	#-1,OSIZE(A0)
	BEQ	ERROR40
	TST.W	(A0)
	BNE	ERROR60
	MOVE.W	OID(A0),D0		; D0(TEMP)=OBJ.ID
	LEA	OMEMB+4(A0),A0		; A0(TEMP)=MEMBERS LIST
.TLL:	MOVE.L	ONEXT(A0),A0
	MOVE.L	A0,D1
	BEQ.S	.TLLO
	MOVE.W	OSIZE(A0),D4		; SIZE->D4
	BEQ	ERROR40			; ARRAY IN OBJ
	;TST.L	OASCII(A0)
	;BEQ	ERROR40			; PRIVATE MEMBER IN OBJ
	ADD.W	D4,D3
	BTST	#0,D3
	BEQ.S	.SX
	CMP.W	#1,D4
	BEQ.S	.SX
	MOVE.W	#-1,(A6)+		; -1 = EVEN
	ADDQ.W	#1,D3
.SX:	SUB.W	D4,D3
	CMP.W	OOFF(A0),D3
	BNE	ERROR60
	ADD.W	D4,D3
	MOVE.W	D4,(A6)+
	BRA.S	.TLL
.TLLO:	BTST	#0,D3
	BEQ.S	.S3
	MOVE.W	#-1,(A6)+
;	ADDQ.W	#1,D3
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VE.W	D3,(A4)+
	MOVE.L	EXTL(PC),(A4)+
	BRA	EXPLOOP

.1:
      BLAARGH:
	BSET	#3,CODEPREFS+1		; USE MATHIEEESINGBAS
	MOVE.W	.2(PC),(A4)+		; SPCMP
	BSR	GVA0D0D5_0
	MOVEQ	#1,D5
	MOVE.L	.3(PC),(A4)+
	MOVE.L	.3+4(PC),(A4)+
	MOVE.W	D3,(A4)+
	MOVE.L	EXTL(PC),(A4)+
	BRA	EXPLOOP
.2:	MOVE.L	2(A5),D1
.3:	MOVE.L	-56(A4),A6
	JSR	-42(A6)

      EXPVARC:
	CMP.W	#41,D0
	BEQ.S	.3
	CMP.W	#36,D0
	BPL	EXPVARCBACK
.3:	TST.B	4(A0)
	BEQ	ERROR22
	CMP.B	#LAB,4(A0)
	BEQ	ERROR6
	CMP.W	#42,2(A3)
	BEQ.S	.2
	MOVEQ	#1,D0
	SUBQ.L	#6,A3
	BSR	EADDRESSMODI
	CMP.W	#-1,D5
	BEQ.S	.1
	BSR	CLOSEEXP
.1:	MOVEQ	#1,D5
	BRA	EXPLOOP
.2:	CMP.W	#35,D0
	BNE.S	.3
	TST.B	4(A0)
	BEQ	ERROR22
	ADDQ.L	#2,A3
	MOVE.L	A0,METHODIDENT		; DO METHOD CALL HERE!
	BSR	SD0
	CLR.L	METHODSPEC
	BSR.S	EXPCALLMETHOD
	BSR	RD0
	MOVEQ	#1,D5
	BRA	EXPLOOP

	METHODIDENT:	DC.L	0
	METHODSPEC:	DC.L	0
	METHODFREEZ:	DC.L	0	; FROZEN CALL WITH THIS OBJECT

; WANTS   OBJ=A6,NAME=D0
; TRASHES A0
; RETURNS D1=METHOD | NIL

      FINDMETHOD:
	LEA	OMETHOD(A6),A6
	MOVE.L	A6,D1
.L:	MOVE.L	D1,A6
	MOVE.L	(A6),D1
	BEQ	.ERR
	MOVE.L	D1,A6
	MOVE.L	M_NAME(A6),A0
	MOVE.L	D0,A6
.CL:	CMPM.B	(A0)+,(A6)+
	BNE.S	.L
	TST.B	-1(A0)
	BNE.S	.CL
.ERR:	RTS

      EXPCALLMETHOD:			; IDENTENTRY IN METHODIDENT,
	CMP.W	#42,(A3)+		; A3 JUST PAST "."
	BNE	ERROR40
	MOVE.L	METHODSPEC(PC),D0
	BNE.S	.NS1
	MOVE.L	METHODIDENT(PC),A6
	MOVE.L	(A6),D0
.NS1:	CMP.L	#5,D0
	BMI	ERROR40
	MOVE.L	D0,A6			; A6=OBJECT
	MOVE.L	(A3)+,D0		; D0=NAME
	BSR	FINDMETHOD
	TST.L	D1
	BEQ	.ERR
	MOVE.L	METHODSPEC(PC),-(A7)
	BEQ.S	.MS4
	MOVE.W	.SA0(PC),(A4)+
.MS4:	MOVE.L	METHODFREEZ(PC),-(A7)
	MOVE.L	D1,-(A7)		; STACK: S.L, F.L, M.L, I.L, COUNT.W
	CMP.W	#17,(A3)+
	BNE	ERROR23
	MOVE.L	METHODIDENT,-(A7)
	CLR.W	-(A7)
	CMP.W	#18,(A3)
	BEQ.S	.2
.3:	MOVE.W	#16,EAREQUEST
	BSR	EAEXP
	TST.L	D0
	BNE.S	.OPT
	MOVE.W	.4(PC),(A4)+
.OPT:	ADDQ.W	#4,(A7)
	CMP.W	#COM,(A3)+
	BEQ.S	.3
	SUBQ.L	#2,A3
.2:	CMP.W	#18,(A3)+		; OUT
	BNE	ERROR23

	MOVEQ	#0,D0
	MOVE.W	(A7)+,D0		; D0=ARGCOUNT
	MOVE.L	4(A7),A6
	MOVE.L	M_PROC(A6),A6
	BSR	DODEFARGS

	MOVE.L	(A7)+,A0		; A0.L=IDENT
	MOVE.L	(A7)+,A6		; A6.L=METHOD
	MOVE.L	(A7)+,METHODFREEZ
	MOVE.L	(A7)+,METHODSPEC
	BNE.W	.MS2
	MOVE.W	.7(PC),(A4)+
	BSR	GVA0D1_0
	MOVE.L	(A0),A0			; A0=OBJ
	BRA.S	.MS3
.MS2:	MOVE.L	METHODSPEC(PC),A0
	MOVE.W	.GA0(PC),(A4)+
	MOVE.W	D0,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BRA.S	.3
.4:	BRA	EXPOUT

      EXPLOG:
	CMP.W	#IOFF+31,D0
	BPL	ANDORNOTBACK
	CMP.W	#1,D5
	BNE	ERROR0
;	TST.W	FLTFLAG
;	BNE	ERROR0	; NO AND/OR FLOAT
	MOVEQ	#0,D5
	MOVEQ	#6,D4
	SUB.W	#IOFF+29,D0
	MULU	#12,D0
	EXT.L	D0
	ADD.L	#EXPAND,D0
	MOVE.L	D0,A1
	BRA	EXPLOOP

      EXPEQ:
	SEQ	D0			; =	11
	SGT	D0			; >	12
	SLT	D0			; <	13
	SGE	D0			; >=	14
	SLE	D0			; <=	15
	SNE	D0			; <>	16

	EXPSTART:	MOVEQ	#0,D0

      EXPAND:
	AND.L	#0,D0
	AND.L	2(A5),D0
	AND.L	D1,D0
      EXPOR:
	OR.L	#0,D0
	OR.L	2(A5),D0
	OR.L	D1,D0
      EXPCMP:
	CMP.L	#0,D0
	CMP.L	2(A5),D0
	CMP.L	D1,D0
      EXPPLUS:				; NO CHANGES TO THESE 8 !
	ADD.L	#0,D0			; EACH 12
	ADD.L	2(A5),D0
	ADD.L	D1,D0
      EXPMINUS:
	SUB.L	#0,D0
	SUB.L	2(A5),D0
	SUB.L	D1,D0
      EXPMUL:
	MULS	#0,D0
	MULS	2(A5),D0
	MULS	D1,D0
	DC.W	0
      EXPDIV:
	DIVS	#0,D0
	DIVS	2(A5),D0
	DIVS	D1,D0
      EXPMOVE:
	MOVE.L	#0,D0
	MOVE.L	2(A5),D0
	MOVE.L	D1,D0

	EXPADDQ:	ADDQ.L	#8,D0
	EXPSUBQ:	SUBQ.L	#8,D0


      EXPOWNFUNC:			; A0=IDENTENTRY
	BTST	#4,5(A0)
	BNE	ERROR4
	CMP.B	#LAB,4(A0)
	BNE	EXPVARPROCCALL
	MOVE.L	6(A0),A6		; A6=PROC!!
	MOVE.L	A6,D6
	BEQ	ERROR25
	CMP.W	#17,(A3)+
	BNE	ERROR23
	BSR	SD0
	MOVEQ	#0,D0			; #OF ARGS
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RECSAVE = 8

      EXPLIBCALL:
	CMP.W	#1,D5
	BEQ	ERROR0
	LEA	EXPLCHECK(PC),A0	; HERE WE CHECK LOOPED CALLS!
	TST.W	(A0)
	BEQ.S	.1			; NO NEED TO
	MOVEQ	#NUMRECSAVE-1,D0
.2:	MOVE.L	(A0)+,-(A7)		; SHOVE NUMRECSAVE LONGS UP STACK
	DBRA	D0,.2
.1:	SUB.L	A6,A6			; NEED OF REGS
	MOVE.W	(A3)+,EXPLBASE
	MOVE.W	(A3)+,EXPLOFF
	MOVE.L	(A3)+,A2
	MOVE.W	(A3)+,D2
	MOVE.W	(A3)+,EXPLEXCEPT
	MOVE.W	D2,EXPLMASK
	MOVEQ	#0,D0			; D0=# OF REGS
	LEA	EXPLREGS(PC),A0
	MOVE.W	D5,-(A7)		; SAVE D5
      EXPLLOOP:
	MOVEQ	#0,D1
	MOVE.B	(A2)+,D1		; D1=REG#
	CMP.W	#16,D1
	BPL.S	EXPLNEXT
	ADDQ.L	#1,D0
	MOVEQ	#13,D6
	MOVEQ	#0,D7			; D7=POS
	CMP.W	#12,D1
	BMI	.1			; A4/A5 CALL
	ADDQ.L	#1,A6
.1:	MOVEQ	#13,D5
	SUB.W	D6,D5
	CMP.W	D1,D5
	BEQ.S	.X
	BTST	D5,D2
	BEQ.S	.2
	ADDQ.L	#1,D7
.2:	DBRA	D6,.1
.X:	MOVE.B	D7,(A0)+
	BRA.S	EXPLLOOP
      EXPLNEXT:
	MOVE.W	(A7)+,D5		; RESTORE D5
	MOVE.B	#-1,(A0)+
	MOVE.W	D0,EXPLNUM
	CMP.W	#17,(A3)+		; CHECK INCOMING (
	BNE	ERROR23
	BSR	SD0
	TST.W	EXPLNUM
        BEQ.S	EXPLNOARGS
        BSR.S	EXPLIBARG
        BRA.S	EXPLFIN
      EXPLNOARGS:
	BSR.W	EXPLIBJSR
      EXPLFIN:

	MOVE.W	EXPLEXCEPT(PC),D7	; USE D7/A6
	BMI.S	.NR
	MULU	#10,D7
	MOVE.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)+
	MOVE.W	EXPLBASE(PC),D0
	BSR	DOOFF
	MOVE.W	D0,(A4)+
	MOVE.W	EXPJSR(PC),(A4)+
	MOVE.W	EXPLOFF(PC),(A4)+
	RTS
.3:	INTERN	100

      EXPLIBJSR:			; IN CASE OF Func()
	MOVE.W	EXPGETBASE(PC),(A4)+
	MOVE.W	EXPLBASE(PC),D0
	BSR	DOOFF
	MOVE.W	D0,(A4)+
	MOVE.W	EXPJSR(PC),(A4)+
	MOVE.W	EXPLOFF(PC),(A4)+
	RTS

      EXPJSR:		JSR	-30(A6)
      EXPGETBASE:	MOVE.L	-40(A4),A6
      EXPGETSTACK:	LEA	4(A7),A7
      EXPMOVEM:		MOVEM.L	(A7)+,D0/A0
      EXPTOSTACK:	MOVE.L	D0,4(A7)
      SAVE45:		MOVEM.L	A4/A5,-(A7)
      RETRIEVE45:	MOVEM.L	(A7)+,A4/A5

      EXPLCHECK:	DC.W	0	; NOTE: THESE DATA=NUMRECSAVE LONGS!
      EXPLBASE:		DC.W	0
      EXPLOFF:		DC.W	0
      EXPLMASK:		DC.W	0
      EXPLNUM:		DC.W	0
      EXPLEXCEPT:	DC.W	0
      EXPLOPTI:		DC.W	0
      EXPLRSM:		DC.W	0
      EXPLREGS:		DC.L	0,0,0,0

      EXPEFUNC:
	CMP.W	#1,D5
	BEQ	ERROR0
	MOVE.L	(A3)+,A0		; A0=FUNCTABENTRY
	MOVEQ	#0,D0			; D0=COUNT ARGS
	MOVEQ	#-100,D2
	TST.L	8(A0)			; WRITEF/PRINTF?
	BPL.S	.3
	MOVE.L	8(A0),D2
	SUBQ.L	#1,D2
	ASL.L	#2,D2
.3:	CMP.W	#17,(A3)+
	BNE	ERROR23
	BSR	SD0
	SUBA.L	A6,A6			; NO BACKPATCH SOFAR

.1:	CMP.W	#18,(A3)
	BEQ.S	.2
	ADDQ.L	#4,D2
	BMI.S	.4
	TST.L	D2
	BNE.S	.1C
	MOVE.L	A4,A6			; A6=BACKPATCH
	MOVE.L	.LEA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,,,,,,,,,,,,,,,, ;


      MMODE:	DC.W	0		; =D1
      THISMOD:	DC.L	0

      MINIMUMMODULE:
	MOVEQ	#2,D1			; MODULE IN MAIN FROM OTHER MODULE
	BRA.S	MODULESTART
      MODULEJOBENTRY:
	MOVEQ	#0,D1			; NORMAL MODULE IN MAIN
	TSTMOD
	BEQ.S	MODULESTART
	MOVEQ	#1,D1			; MODULE IN MODULE
      MODULESTART:
	MOVE.W	D1,MMODE
	CLR.W	LOADEDVERSION
      DOMODULEJOB:			; A0=PTR JOBCODE
	MOVE.W	MMODE(PC),D1
	MOVE.W	(A0)+,D0		; CAN TRASH ANYTHING
	BEQ.S	.1
	CMP.W	#1,D0
	BEQ	ADDCONST
	CMP.W	#2,D0
	BEQ	ADDOBJECT
	CMP.W	#3,D0
	BEQ	ADDCODE
	CMP.W	#4,D0
	BEQ	ADDPROCS
	CMP.W	#5,D0
	BEQ	ADDSYSCONST
	CMP.W	#6,D0
	BEQ	BINDOTHERLIB
	CMP.W	#7,D0
	BEQ	ADDRELOC
	CMP.W	#8,D0
	BEQ	ADDGLOBSENTRY
	CMP.W	#9,D0
	BEQ	ADDMODULES
	CMP.W	#10,D0
	BEQ.S	ADDDEBUG
	CMP.W	#11,D0
	BEQ.S	ADDMACROS
	BRA	ERROR36			; SUPPOSED TO BE OTHER JOBCODES
.1:	RTS

      ADDMACROS:
	JSR	PREPREADMACROS
	BRA	DOMODULEJOB

      ADDDEBUG:
	MOVE.L	A0,A6			; A6=DEBUGHUNK
	MOVE.L	4(A6),D0
	ADDQ.L	#2,D0
	LSL.L	#2,D0
	ADD.L	D0,A0			; skip LINE debug
	CMP.W	#1,D1
	BEQ.S	.NL
	GETM	A2
	MOVE.L	CODELIST(PC),D0
	BNE.S	.NN
	MOVE.L	A2,CODELIST
	BRA.S	.C
.NN:	MOVE.L	CODETAIL(PC),A1
	MOVE.L	A2,(A1)
.C:	MOVE.L	A2,CODETAIL
	CLR.L	(A2)+
	MOVE.W	#8,(A2)+
	MOVE.L	DEBUGLIST,(A2)
	MOVE.L	A2,DEBUGLIST
	ADDQ.L	#4,A2
	MOVE.L	A6,(A2)+
	CLR.L	(A2)+
	DONEM	A2
.NL:	CMP.L	#$3F1,(A0)
	BNE.S	.NL2
	MOVE.L	4(A0),D0
	ADDQ.L	#2,D0
	LSL.L	#2,D0
	ADD.L	D0,A0			; skip EVAR debug
.NL2:	TST.L	(A0)+			; BLANK TERMINATOR
	BNE	ERROR36
	BRA	DOMODULEJOB

      ADDMODULES:
	MOVE.L	(A0)+,D0
	CMP.W	#1,D1
	BNE.S	.L
	ADD.L	D0,A0
	BRA.W	DOMODULEJOB
.L:	MOVE.W	(A0)+,D0
	BEQ.W	.X
	MOVE.L	A0,A1			; A1=MODNAME
	ADD.W	D0,A0
	MOVE.L	A1,A2
.C:	TST.B	(A2)+
	BNE.S	.C
	MOVE.L	A2,CACHENAMEEND
	MOVE.L	A1,CACHENAMESTART
	JSR	SEARCHINMODLIST
	GETM	A3
	TST.L	D0
	BNE.S	.L2
	ADDQ.W	#1,AGAIN		; SIGNAL NEW MODULES
	MOVE.L	MODINFOLIST,(A3)	; MI_NEXT
	MOVE.L	A3,MODINFOLIST
	ADDQ.L	#4,A3
	MOVE.W	#$100,(A3)+		; MI_FLAGS
	SUB.L	A1,A2
	MOVE.L	A2,(A3)+		; MI_NAMELEN
	CLR.L	(A3)+			; MI_MOD
	CLR.L	(A3)+			; MI_LIST
	MOVE.L	A1,(A3)+		; MI_NAMEPTR
.L2:	MOVE.W	(A0)+,D0
	BEQ.S	.D
	MOVE.W	(A0)+,D1
	MOVE.L	A0,A1			; A1=PROCCLASS NAME
	ADD.W	D1,A0
	MOVE.L	CODELIST(PC),D1		; HOOKUP TAIL OF CODEREM
	BNE.S	.NN
	MOVE.L	A3,CODELIST
	BRA.S	.CC
.NN:	MOVE.L	CODETAIL(PC),A2
	MOVE.L	A3,(A2)
.CC:	MOVE.L	A3,CODETAIL
	CLR.L	(A3)+
	CMP.W	#1,D0
	B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,0
VREF:	MOVE.L	A1,A3			; SEARCH FOR VAR
	HASH	A3,D2,D1
	LSL.L	#2,D2
	ADD.L	#IDENTHASH,D2
	MOVE.L	D2,A3			; A3=HASHENTRYPTR
	LEA	4(A3),A4
.SL:	MOVE.L	-(A4),A4
	MOVE.L	A4,D2
	BEQ.S	.NOTF
	MOVE.L	(A4),A5
	MOVE.L	A1,A6
.CL:	CMPM.B	(A5)+,(A6)+
	BNE.S	.SL
	TST.B	-1(A5)
	BNE.S	.CL
	MOVE.L	A4,D2			; JAAAH, BESTAAT REEDS!
	BRA.S	ODONE
.NOTF:	GETM	A5			; LINKED INTO HASH TABLE!
	MOVE.L	(A3),(A5)+
	MOVE.L	A5,(A3)
	MOVE.L	A1,(A5)+		; ASCIIPTR
	MOVE.B	#GLOBV,(A5)+		; SET GLOBAL(=2)
	MOVE.B	#5,(A5)+		; REF+EXPORT
	CLR.L	(A5)+
	SUBQ.W	#4,NRGLOB
	MOVE.W	NRGLOB,D2
	MOVE.W	D2,(A5)+		; SET OFFS
	MOVE.L	A5,D2
	SUBQ.L	#8,D2
	SUBQ.L	#4,D2
	DONEM	A5
	;BRA	ODONE
ODONE:	GETM	A3			; GOT VAR IN D2, NOW HANG IN CODEREM LIST
	MOVE.L	CODELIST(PC),D1
	BNE.S	.NN
	MOVE.L	A3,CODELIST
	BRA.S	.C
.NN:	MOVE.L	CODETAIL(PC),A4
	MOVE.L	A3,(A4)
.C:	MOVE.L	A3,CODETAIL
	CLR.L	(A3)+
	MOVE.W	#4,(A3)+
	MOVE.L	A2,(A3)+
	MOVE.L	D2,(A3)+
	MOVE.W	LOADEDVERSION(PC),(A3)+
	DONEM	A3
	BRA	ADDGLOBS

      ADDCODE:
	MOVE.L	(A0)+,D7
	CMP.W	#1,D1
	BEQ.S	.SKIP
	GETM	A2
	MOVE.L	CODELIST(PC),D0
	BNE.S	.NN
	MOVE.L	A2,CODELIST
	BRA.S	.C
.NN:	MOVE.L	CODETAIL(PC),A1
	MOVE.L	A2,(A1)
.C:	MOVE.L	A2,CODETAIL
	CLR.L	(A2)+
	MOVE.W	#2,(A2)+
	MOVE.L	A0,(A2)+
	MOVE.L	D7,(A2)+
	LSL.L	#2,D7
	ADD.L	D7,A0
	DONEM	A2
	BRA	DOMODULEJOB
.SKIP:	LSL.L	#2,D7
	ADD.L	D7,A0
	BRA	DOMODULEJOB

      CODELIST:		DC.L	0
      CODETAIL:		DC.L	0

      ADDRELOC:
	MOVE.L	(A0)+,D7
	CMP.W	#1,D1
	BEQ.S	.SKIP
	GETM	A2
	MOVE.L	CODELIST(PC),D0
	BNE.S	.NN
	MOVE.L	A2,CODELIST
	BRA.S	.C
.NN:	MOVE.L	CODETAIL(PC),A1
	MOVE.L	A2,(A1)
.C:	MOVE.L	A2,CODETAIL
	CLR.L	(A2)+
	MOVE.W	#3,(A2)+
	MOVE.L	A0,(A2)+
	MOVE.L	D7,(A2)+
	CLR.L	(A2)+
	LSL.L	#2,D7
	ADD.L	D7,A0
	DONEM	A2
	BRA	DOMODULEJOB
.SKIP:	LSL.L	#2,D7
	ADD.L	D7,A0
	BRA	DOMODULEJOB

      ADDSYSCONST:
	MOVE.L	(A0)+,D0
	CMP.W	#1,D1
	BEQ.S	.S1
	ADD.L	D0,MINSTACK		; ADD USED TO STACK
.S1:	MOVE.W	(A0)+,D0
	CMP.W	OSVERSION,D0		; HIGHEST OSVERSION
	BLE.S	.1
	MOVE.W	D0,OSVERSION
	BSET	#4,WARNINGS+3
.1:	MOVE.L	(A0)+,D0
	AND.L	#%110000000000000000000,D0	; ONLY INTERESTING BITS
	OR.L	D0,CODEPREFS
	MOVE.W	(A0)+,D0
	CMP.W	ECPU,D0			; BEST CPU
	BLE.S	.2
	MOVE.W	D0,ECPU
	BSET	#4,WARNINGS+3
.2:	MOVE.W	(A0)+,D0		; BEST FPU
	CMP.W	EFPU,D0
	BLE.S	.3
	MOVE.W	D0,EFPU
	BSET	#4,WARNINGS+3
.3:	MOVE.W	(A0)+,D0		; OR BITSET
	MOVE.W	ASMCPU,D3
	OR.W	D3,D0
	CMP.W	D3,D0
	BEQ.S	.4
	MOVE.W	D0,ASMCPU
	BSET	#4,WARNINGS+3
.4:	MOVE.W	(A0)+,D0		; VERSION
	BNE.S	.5
	ADDQ.W	#1,D0			; 0 is version 1
.5:	MOVE.W	D0,LOADEDVERSION
	CMP.W	#CURVERSION,D0
	BHI	ERROR51
	ADDQ.L	#4,A0			; RESERVED
	BRA	DOMODULEJOB

      ADDPROCS:
.L:	MOVE.W	(A0)+,D0
	CMP.W	#-1,D0
	BEQ	.EX
	GETM	A4
	EXT.L	D0
	MOVE.L	A0,A1
	HASH	A1,D1,D2
	LSL.L	#2,D1
	MOVE.L	#IDENTHASH,A1
	ADD.L	D1,A1
	MOVE.L	(A1),(A4)+
	MOVE.L	A4,(A1)
	MOVE.L	A4,D6			; REMIND THIS IDENT=D6
	MOVE.L	A0,(A4)+
	MOVE.B	#LAB,(A4)+
	MOVE.B	#1,(A4)+		; FLAGS: USED  (NEVER EXPORT!)
	ADD.L	D0,A0
	MOVE.L	(A0)+,D7		; D7=OFFSET
	CMP.W	#1,(A0)+
	BNE.S	.LAB
	LEA	14(A4),A3		; note: 14
	MOVE.L	A3,(A4)+		; PROC
	MOVE.W	#-2,(A4)+
	CLR.L	(A4)+			; EXTRA!!
	MOVE.L	PROCLIST,(A4)+
	MOVE.L	A4,PROCLIST
	MOVE.W	(A0)+,(A4)+		; INIT PROC STRUCT
	CLR.W	(A4)+			; FLAGS,REGVARS
	MOVE.W	(A0)+,(A4)+
	MOVE.L	A0,(A4)+		; DEFARGS
	CLR.L	(A4)+			; of_object
	MOVE.L	D6,(A4)+		; IDENT
	CLR.L	(A4)+			; SELF
	CLR.L	(A4)+			; METHOD
	MOVE.W	(A0)+,D0
	LSL.W	#2,D0
	ADD.W	D0,A0
	MOVE.W	(A0)+,D0
	ADD.W	D0,A0
	BRA.S	.CODE
.LAB:	CLR.L	(A4)+			; LABEL
	MOVE.W	#-1,(A4)+
	CLR.L	(A4)+			; EXTRA!!
.CODE:	CMP.W	#1,MMODE		; CHECK IF MOD IN MOD
	BEQ.S	.1
	MOVE.L	CODETAIL(PC),A1
	MOVE.L	A4,(A1)
	MOVE.L	A4,CODETAIL
	CLR.L	(A4)+
	MOVE.W	#1,(A4)+
	MOVE.L	D6,(A4)+
	MOVE.L	D7,(A4)+
.2:	DONEM	A4
	BRA	.L
.EX:	BRA	DOMODULEJOB
.1:	MOVE.L	THISMOD(PC),A1		; A1=MODINFO
	MOVE.L	D6,A2			; A2=ID
	SUBQ.W	#2,10(A2)
	MOVE.L	MI_LIST(A1),(A4)	; PC_NEXT
	MOVE.L	A4,MI_LIST(A1)
	MOVE.L	A4,VARHEAVY(A2)
	ADDQ.L	#4,A4
	MOVE.W	#2,(A4)+		; PC_TYPE
	MOVE.L	D6,(A4)+		; PC_INFO
	CLR.L	(A4)+			; PC_ACC
	BRA.S	.2


      FIXPROCCODE:			; RESOLVE ADDRESSES OF CODE IN MODULES
	MOVEM.L	A0-A3/D0-D4/A5,-(A7)	; EXPECTS CODE IN A4
	LEA	CODELIST(PC),A0		; A0=CODEREM
	MOVE.L	LABM+8,A2		; A2=LABELS
.L:	MOVE.L	(A0),A0
	MOVE.L	A0,D0
	BEQ	.E
	MOVE.W	4(A0),D0
	CMP.W	#2,D0
	BNE.S	.ID
	MOVE.L	6(A0),A1		; CODE + LEN
	MOVE.L	10(A0),D1
	SUBQ.L	#1,D1
	MOVE.L	A4,D2			; D2=COPIED CODEBASE
	MOVE.L	D2,10(A0)		; SET LEN FIELD TO CODEBASE!

	MOVE.L	D1,D0			;
	LSL.L	#2,D0			;
	ADD.L	A4,D0			; CHECK CODEBUF
	MOVE.L	D0,CURACODE		;
	JSR	CHECK3			;
	MOVE.L	A4,CURACODE		;

.C:	MOVE.L	(A1)+,(A4)+
	DBRA	D1,.C
	BRA.S	.L
.ID:	CMP.W	#1,D0
	BNE.S	.REL
	MOVE.L	6(A0),A3
	MOVEQ	#0,D3
	MO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BNE.S	.L
	ADD.L	D0,A0
	BRA	DOMODULEJOB
.L:	MOVE.W	(A0)+,D0		; D0=LEN ASC
	BEQ.S	.1
	GETM	A5
	MOVE.L	(A0)+,D1
	MOVE.L	A0,A1
	HASH	A1,D2,D3
	LSL.L	#2,D2
	ADD.L	#CONSTHASH,D2
	MOVE.L	D2,A1
	MOVE.L	(A1),(A5)
	MOVE.L	A5,(A1)
	ADDQ.L	#4,A5
	MOVE.L	A0,(A5)+
	MOVE.L	D1,(A5)+
	CLR.W	(A5)+
	EXT.L	D0
	ADD.L	D0,A0
	DONEM	A5
	BRA.S	.L
.1:	BRA	DOMODULEJOB

      ADDOBJECT:
	CMP.W	#6,LOADEDVERSION
	BMI.S	.1
	MOVE.L	(A0)+,D0
	;CMP.W	#2,D1			; ever?
	;BNE.S	.1
	;ADD.L	D0,A0
	;BRA	DOMODULEJOB
.1:	ADDQ.W	#1,OBJCOUNT
	MOVE.W	OBJCOUNT(PC),D5
	GETM	A5
	MOVE.W	(A0)+,D0		; D0=LEN ASC
	BEQ	ERROR39
	MOVE.W	(A0)+,D1
	CMP.W	#-1,D1
	BNE	ERROR39
	MOVE.L	OLIST,(A5)+
	MOVE.L	A5,OLIST
	ADDQ.L	#2,A0			; OFF MAKES NO SENSE FOR HEAD
	CLR.W	(A5)+			; DELEGATESIZE=0
	MOVE.W	#%1000000000,(A5)+	; SET IMPORT
	MOVE.L	A5,A4			; A4=SIZE.W OBJ
	CLR.W	(A5)+			; STILL 0
	MOVE.W	D5,(A5)+
	MOVE.L	A0,(A5)+
	MOVE.L	A5,A6			; A6=_TAIL_ MEMBER LIST
	CLR.L	(A5)+			; MEMBERLIST=0
	CLR.L	(A5)+			; METHODLIST=0
	CLR.L	(A5)+			; SUPERCLASS=0
	CLR.L	(A5)+			; DELEGATECODE=NIL
	CLR.L	(A5)+			; ACCESLIST
	MOVE.L	#-1,(A5)+		; DELOFFSET+DESTRUCTOFF
	EXT.L	D0
	ADD.L	D0,A0
	DONEM	A5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,(A5)+		; SET OFFS
	DONEM	A5
      BLURP:
	LEA	-12(A5),A5
	TSTMOD
	BEQ.S	.3			; REMEMBER OFFSET
	GETM	A1
	MOVE.L	OFFSLIST(PC),(A1)+
	MOVE.L	A5,(A1)+
	DONEM	A1
	SUBQ.L	#8,A1
	MOVE.L	A1,OFFSLIST
.3:	GINFO	A0,A1,A5
	MOVE.W	NRGLOB,D7		; BASE OF LIB

      BLABLABLA:
.2:	TST.B	(A0)+
	BNE.S	.2
	MOVE.L	A0,A5
	MOVE.L	A0,-(A7)
	BSR.W	ADDLIBS2
	MOVE.L	(A7)+,A0
	RTS

      OFFSLIST:	DC.L	0

      DOOFF:				; GETS OFF IN D0, PRESERVES D0
	TSTMOD
	BEQ.S	.1
	CMP.W	#GLOBOFF+8,D0
	BPL.S	.1
	MOVEM.L	A0/A1/D1,-(A7)
	LEA	OFFSLIST(PC),A0
.L:	MOVE.L	(A0),A0
	MOVE.L	A0,D1
	BEQ.S	.3
	MOVE.L	4(A0),A1
	CMP.W	10(A1),D0
	BNE.S	.L
	GENGI	A1,D1
	MOVEM.L	(A7)+,A0/A1/D1
.1:	RTS
.3:	INTERN	101

      SETUPLIBS:
	BSR	ADDLIBS
	RTS

      ADDLIBS:
	LEA	EXEC(PC),A5
	MOVE.W	#-40,D7
	BSR.S	ADDLIBS2
	LEA	DOS(PC),A5
	MOVE.W	#-44,D7
	BSR.S	ADDLIBS2
	LEA	INTUI(PC),A5
	MOVE.W	#-48,D7
	BSR.S	ADDLIBS2
	LEA	GFX(PC),A5
	MOVE.W	#-52,D7
	BSR.S	ADDLIBS2
;	LEA	MATH(PC),A5
;	MOVE.W	#-56,D7
;	BSR.S	ADDLIBS2
	RTS

      ADDLIBS2:				; PAR: A5=LIB DATA, D7=OFFSET OF CUR. LIB.
	MOVE.W	#-30,D6			; D6=OFFSET OF CUR. CALL
	MOVE.L	CURLIBASC,A4		; A4=LIBSTRUCTS
	JSR	CHECK3
.L:	CMP.B	#-1,(A5)
	BEQ.S	.OUT
	MOVE.L	A5,(A4)+		; ptr to ascii
	MOVE.W	D7,(A4)+		; xbase offset
	MOVE.W	D6,(A4)+		; own offset
	MOVE.W	#-1,(A4)+		; EXCEPTION INDEX
	SUBQ.W	#6,D6
.F:	CMP.B	#32,(A5)+		; NOW GET TO THE NEXT
	BPL	.F
	CMP.B	#16,-1(A5)
	BEQ.S	.L
.F2:	TST.B	(A5)
	BMI.S	.L
	CMP.B	#16,(A5)
	BPL.S	.L
	ADDQ.L	#1,A5
	BRA.S	.F2
.OUT:	MOVE.L	A4,CURLIBASC
	CLR.L	(A4)
	CLR.L	4(A4)
	CLR.L	8(A4)
	RTS

;;HEADER

; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The InitCode and ExitCode Part ....			;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


      STACKPOKE:		DC.L	0,0
      AFTERDELEGATESLEA:	DC.L	0
      BEFORESECONDLEA:		DC.L	0
      TOTALDELSIZE:		DC.L	0

      BUILDDELEGATECONSTRUCTORS:
	MOVE.L	CURACODE,A4		; A4=CODE
	MOVEQ	#6,D0
	BSR	ADDLABEL

	LEA	OLIST+4,A5		; A5=OLIST
	MOVEQ	#1,D6			; D6=NUM
.CO:	MOVE.L	-(A5),D0
	BEQ.S	.COX
	MOVE.L	D0,A5
	TST.W	ODEL(A5)
	BEQ.S	.CO
	ADDQ.L	#1,D6
	BRA.S	.CO
.COX:	LSL.L	#2,D6
	MOVEQ	#4,D4			; D4=CUR_DEL_PTR_OFF

	LEA	OLIST+4,A5		; A5=OLIST
.L:	MOVE.L	-(A5),D0
	BEQ.W	.X
	MOVE.L	D0,A5
	MOVE.W	ODEL(A5),D7		; D7=DELSIZE
	BEQ.S	.L

	GETM	A1
	MOVE.L	.GET(PC),(A4)+
	MOVE.L	D6,(A4)+
	MOVE.W	.GET2(PC),(A4)+
	MOVE.L	OACC(A5),(A1)		; ADD T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E(PC),D1	; PATCH DELSIZE
	MOVE.L	D1,D2
	MOVE.L	BEFORESECONDLEA(PC),D0
	BEQ.S	.1
	MOVE.L	D0,A0
	MOVE.L	D2,2(A0)
.1:	NEG.L	D2
	MOVE.L	AFTERDELEGATESLEA(PC),A0
	MOVE.L	D2,-4(A0)
	MOVE.L	MINSTACK(PC),D0		; GLOBAL + ALL_LOCAL + DELEGATES
	ADD.L	GLOBSTACK(PC),D0
	ADD.L	D1,D0
	MOVE.L	CODESTACK,D1
	BNE.S	.S
	ADD.L	#MINSTACKSIZE,D0
	MOVE.L	LIBINFO(PC),D1
	BEQ.S	.NL
	SUB.L	#MINSTACKSIZE-MINSTACKSIZELIB,D0
.NL:	MOVE.L	D0,CODESTACK
	BSET	#0,CODEPREFS+3
	BRA.S	.NS
.S:	CMP.L	D0,D1
	BPL.S	.S2
	BSET	#2,WARNINGS+3
.S2:	ADD.L	#4000,D0
	CMP.L	D0,D1
	BPL.S	.S3
	BSET	#1,WARNINGS+3	
	BCLR	#2,WARNINGS+3	
.S3:
.NS:	MOVE.L	CODESTACK,D0
	LEA	STACKPOKE(PC),A0
	MOVE.L	(A0)+,A1
	MOVE.L	D0,(A1)
	MOVE.L	(A0),A1
	MOVE.L	D0,(A1)
.EX:	RTS

      MAKEINITCODE:
	MOVE.W	#3,CURSPOT
	MOVE.L	CURACODE,A4
	BTST	#3,CODEPREFS+3
	BNE	.EX
	TSTMOD
	BNE	.EX
	TST.L	LIBINFO
	BNE	LMAKEINITCODE
	LEA	FIRSTSTART(PC),A0	; NEW STACK
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	MOVE.W	(A0)+,(A4)+
	MOVE.L	A4,STACKPOKE
	ADDQ.L	#4,A4
	ADDQ.L	#4,A0
	MOVE.L	#LINKC2,D0
	BSR	COPYC
 	MOVE.L	A4,AFTERDELEGATESLEA	; PATCH IN SIZE LATER
	MOVE.W	LINKC2(PC),(A4)+
	MOVE.W	NRGLOB,D7
	MOVE.W	D7,(A4)+
	LEA	REALSTART(PC),A0
	MOVE.L	A4,A6			; BACKUP
	MOVE.L	#MIDC,D0
	BSR	COPYC
	LEA	POKESTRING-REALSTART(A6),A6
	MOVE.L	ARGBYTE,A5
	BTST	#0,(A5)
	BNE.S	.ARGU
	MOVE.L	#$4E714E71,(A6)
	MOVE.W	#$4E71,4(A6)
.ARGU:	BTST	#0,CODEPREFS+2
	BEQ.S	.NVERS
	MOVE.W	OSVERSION,D0
	MOVE.B	D0,POKE37-POKESTRING+1(A6)
.NVERS:	MOVE.W	GLOBJUMP(PC),(A4)+
	MOVEQ	#5,D0
	BSR	ADDBRANCHRELOC
	MOVE.W	EXITC(PC),(A4)+		; DELEGATES
	MOVEQ	#8,D0
	BSR	ADDBRANCHRELOC
	LEA	EXITC2(PC),A0
	MOVE.L	#ENDC2,D0
	BSR	COPYC
	LEA	ENDC2(PC),A0
	MOVE.L	A4,BEFORESECONDLEA
	MOVE.L	(A0)+,(A4)+
	MOVE.L	(A0)+,(A4)+
	MOVE.L	A4,STACKPOKE+4
	ADDQ.L	#4,A4
	ADDQ.L	#4,A0
	MOVE.L	#ST2,D0
	BSR	COPYC
	MOVE.L	ST2,(A4)+
	BSR	FIXPROCCODE
	MOVE.L	A4,CURACODE
.EX:	RTS

	MAINRTS:	RTS

      FIRSTSTART:			; CHANGES ALSO TO LFIRSTART!!!
	MOVE.L	4.W,A6
	MOVE.L	A0,A5			; SAVE A0/D0 TO A5/D7
	MOVE.L	D0,D7
	MOVE.L	#20000,D0		; THIS .L IS CHANGED!
	MOVE.L	#$10000,D1
	MOVE.L	D0,D2
	JSR	-198(A6)
	TST.L	D0
	BNE.S	.1
	MOVEQ	#20,D0			; NO FUCKIN' MEM !
	RTS
.1:	MOVE.L	D0,D6			; D6=BOTTOMSTACK
	ADD.L	D2,D0
	JSR	-132(A6)		; --> FORBID
	EXG.L	D0,A7
	MOVE.L	D0,-(A7)
	ADD.L	#1,A7			; SIZE IS PATCHED IN
      LINKC2:
	LINK	A4,#-4
      REALSTART:
	JSR	-138(A6)		; --> PERMIT
	MOVE.L	D6,-64(A4)
	SUBA.L	A1,A1			; check for wbstartup
	JSR	-294(A6)  		; findtasK
	MOVE.L	D0,A3
	TST.L	172(A3)
	BNE.S	NOWBST
	LEA	92(A3),A0
	JSR	-384(A6)  		; waitport
	LEA	92(A3),A0
	JSR	-372(A6)  		; getmsg
	MOVE.L  D0,-36(A4)
	LEA	ZEROSPOT(PC),A0
	MOVE.L	A0,-32(A4)		; WB=NO ARGS
	BRA.S	NOARGSET
      NOWBST:
	MOVE.L	A5,A0
	MOVE.L	D7,D0
	MOVE.L	A0,-32(A4)
      POKESTRING:
	MOVE.B	#0,-1(A0,D0.W)
      NOARGSET:
	MOVE.L	A6,-40(A4)		; INIT VARS
	LEA	EXITC(PC),A0
	MOVE.L	A0,-24(A4)

	LEA	INITINTUI(PC),A1	; OPEN LIBS
      POKE37:
	MOVEQ	#33,D0			; OR V37!
	JSR	-552(A6)
	MOVE.L	D0,-48(A4)
	BEQ	CLINT

	LEA	INITGFX(PC),A1
	MOVEQ	#33,D0
	JSR	-552(A6)
	MOVE.L	D0,-52(A4)
	BEQ	CLGFX

	LEA	INITDOS(PC),A1
	MOVEQ	#33,D0			; WE WILL USE FUNCTIONS NOT IN V32
	JSR	-552(A6)
	MOVE.L	D0,-44(A4)
	BEQ	CLDOS

	MOVE.L	D0,A6
	JSR	-60(A6)			; GET STDOUT, MAY BE 0
	MOVE.L	D0,-8(A4)
	JSR	-54(A6)			; GET STDIN
	MOVE.L	D0,-92(A4)
	MOVE.L	A7,-4(A4)
	BRA.S	GLOBJUMP
      INITDOS:		DC.B	"dos.library",0
      INITINTUI:	DC.B	"intuition.library",0
      INITGFX:		DC.B	"graphics.library",0
      ZEROSPOT:		DC.B	0
	EVEN
      MIDC:
      GLOBJUMP:
	JSR	GLOBJUMP
      EXITC:
	JSR	EXITC
      EXITC2:
	MOVE.L	-4(A4),A7
	TST.L	-12(A4)
	BEQ.S	.1
	MOVE.L	-44(A4),A6		; CLEANUP CON
	MOVE.L	-12(A4),D1
	MOVE.L	D1,D4
	MOVEQ	#0,D2			; NO BYTES WRITTEN
	MOVEQ	#0,D3
	JSR	-42(A6)
	MOVE.L	D4,D1
	JSR	-36(A6)
.1:	MOVE.L	4.W,A6
	MOVE.L	-20(A4),A2		; CLEANUP MEMORY
	MOVE.L	A2,D0
	BEQ.S	.3
.4:	MOVE.L	A2,A1
	MOVE.L	4(A2),D0
	MOVE.L	(A2),A2
	JSR	-210(A6)
	MOVE.L	A2,D0
	BNE.S	.4	
.3:
	MOVE.L	-44(A4),A1
	JSR	-414(A6)		; closedos
CLDOS:	MOVE.L	-52(A4),A1
	JSR	-414(A6)		; closegfx
CLGFX:	MOVE.L	-48(A4),A1
	JSR	-414(A6)		; closeintui
CLINT:	MOVE.L	-36(A4),D3
	BEQ.S	.1
	JSR	-132(A6)		; no unloadseg until we're done
	MOVE.L	D3,A1
	JSR	-378(A6)		; reply WB message
.1:	MOVE.L	-28(A4),D2		; EXITCODE
	UNLK	A4
      ENDC2:
	ADD.L	#1,A7
	MOVE.L	#$20000,D0
	MOVE.L	(A7)+,A1
	EXG.L	A1,A7
	SUBA.L	D0,A1
	JSR	-210(A6)
      ST2:
	MOVE.L	D2,D0
	RTS
      ENDC:

; sample.library

VERSION			= 37
REVISION		= 1

LIBB_DELEXP		= 3
LIB_NEGSIZE		= $10
LIB_POSSIZE		= $12
LIB_OPENCNT		= $20

TASKTABSIZE		= 16
NUMTASKTAB		= 8
NUMTASKS		= TASKTABSIZE*NUMTASKTAB
TASKTABSTOREMASK	= %1110000000 ; 16*8BYTES=128=7BIT CLEAR

sb_Flags		= 34	; LIB_SIZE
sb_pad			= 35
sb_SysLib		= 36
sb_DosLib		= 40
sb_SegList		= 44
sb_TASKS		= 48			; TASKID+A4
SampleBase_SIZEOF	= NUMTASKS*8+sb_TASKS

Remove			= -$FC
FreeMem			= -$D2

Start:	MOVEQ   #-1,d0
	rts

RomTag:	DC.W	$4AFC		; UWORD RT_MATCHWORD
	DC.L	RomTag-Start	; APTR  RT_MATCHTAG [R]
	DC.L	EndCode-Start	; APTR  RT_ENDSKIP [R]
	DC.B	$80		; UBYTE RT_FLAGS
	DC.B	VERSION		; UBYTE RT_VERSION
	DC.B	9		; UBYTE RT_TYPE
	DC.B	0		; BYTE  RT_PRI
	DC.L	LibName-Start	; APTR  RT_NAME [R]
	DC.L	IDString-Start	; APTR  RT_IDSTRING [R]
	DC.L	InitTable-Start	; APTR  RT_INIT  table for InitResident()

InitTable:
	DC.L	SampleBase_SIZEOF	; size of library base data space
	DC.L	0         		; pointer to function initializers
	DC.L	dataTable-Start		; pointer to data initializers
	DC.L	initRoutine-Start	; routine to run

dataTable:
	DC.W	-$5FF8
	DC.B	$9,0
	DC.W	-$7FF6
	DC.L	LibName-Start
	DC.W	-$5FF2,$600,-$6FEC,VERSION,-$6FEA,REVISION,-$7FE8
	DC.L	IDString-Start,0

initRoutine:
	move.l	a5,-(sp)
	move.l	d0,a5
	move.l	a6,sb_SysLib(a5)
	move.l	a0,sb_SegList(a5)
	LEA	sb_TASKS(a5),A0			; list of opening tasks
	MOVEQ	#NUMTASKS-1,D0
.L:	CLR.L	(A0)+
	CLR.L	(A0)+
	DBRA	D0,.L
	move.l	a5,d0
	move.l	(sp)+,a5
	rts

Open:	addq.w	#1,LIB_OPENCNT(a6)		; ( libptr:a6, version:d0 )
	bclr	#LIBB_DELEXP,sb_Flags(a6)
	BSR.W	GETTC
	MOVE.L	A6,D0
	MOVE.L	4.W,A6
	JSR	-132(A6)			; --> FORBID
.L:	TST.L	(A0)+				; FIND EMPTY SPOT.
	BEQ.S	.S
	ADDQ.L	#4,A0
	DBRA	D1,.L
	JSR	-138(A6)			; --> PERMIT
	MOVE.L	D0,A6
.FAIL:	MOVEQ	#0,D0				; AAARGH!!! ERROR!!
	RTS
.S:	JSR	-138(A6)			; --> PERMIT
	MOVE.L	D0,A6
	MOVEM.L	D2-D7/A2-A6,-(A7)
	MOVE.L	A0,A5				; AO POS BEWAREN OM A4 ..
	MOVE.L	A1,-(A0)			; .. IN TE STOPPEN LATER
	BSR	LFIRSTSTART
	MOVEM.L	(A7)+,D2-D7/A2-A6
	TST.L	D0
	BEQ.S	.FAIL
	move.l	a6,d0
	rts

Close:	BSR.S	GETTC
.L:	CMPA.L	(A0)+,A1
	BEQ.S	.F
	ADDQ.L	#4,A0
	DBRA	D1,.L
	RTS					; OTHER TASK, SO NOP
.F:	MOVEM.L	D2-D7/A2-A6,-(A7)
	MOVE.L	(A0),A4
	CLR.L	-(A0)				; change is multitask safe
	BSR	LEXITC
	MOVEM.L	(A7)+,D2-D7/A2-A6
	moveq	#0,d0				; ( libptr:a6 )
	subq.w	#1,LIB_OPENCNT(a6)
	bne.s	.1
	btst	#LIBB_DELEXP,sb_Flags(a6)
	beq.s	.1
	bsr	Expung
.1:	rts

Expung:	movem.l	d2/a5/a6,-(sp)			; ( libptr: a6 )
	move.l	a6,a5
	move.l	sb_SysLib(a5),a6
	tst.w	LIB_OPENCNT(a5)
	beq	.1
	bset	#LIBB_DELEXP,sb_Flags(a5)
	moveq	#0,d0
	bra.s   ExpEnd
.1:	move.l	sb_SegList(a5),d2
	move.l	a5,a1
	jsr	Remove(A6)
	moveq	#0,d0
	move.l	a5,a1
	move.w	LIB_NEGSIZE(a5),d0
	sub.l	d0,a1
	add.w	LIB_POSSIZE(a5),d0
	jsr	FreeMem(A6)
	move.l   d2,d0
ExpEnd:	movem.l	(sp)+,d2/a5/a6
	rts

Null:	moveq	#0,d0
	rts

GETTC:	MOVE.L	4.W,A1				; COPY IN GETA4!!!!!!!!
	MOVE.L	276(A1),A1			; A1=THISTASK
	MOVE.L	A1,D1
	AND.W	#TASKTABSTOREMASK,D1
	LEA	sb_TASKS(A6,D1.W),A0		; A0=HASHED TASKTABLE
	MOVEQ	#TASKTABSIZE-1,D1		; D1=SIZE
	RTS

EndCode:

; same thing, only now for libraries

      LFIRSTSTART:			; a5 here = ptr to put a4 in
	MOVE.L	A7,A3			; A3 = ORIG STACK
	MOVE.L	4.W,A6
	MOVE.L	#20000,D0		; THIS .L IS CHANGED!
	MOVE.L	#$10000,D1
	MOVE.L	D0,D2
	JSR	-198(A6)
	TST.L	D0
	BEQ.W	LNOMEM
	MOVE.L	D0,D6			; D6=BOTTOMSTACK
	ADD.L	D2,D0
	JSR	-132(A6)		; --> FORBID
	MOVE.L	D0,A7
	ADD.L	#1,A7			; SIZE IS PATCHED IN
      LLINKC2:
	LINK	A4,#-4
      LREALSTART:
	JSR	-138(A6)		; --> PERMIT
	MOVE.L	A3,-4(A4)
	MOVE.L	D6,-64(A4)
	MOVE.L	A6,-40(A4)		; INIT VARS
	LEA	LINITINTUI(PC),A1	; OPEN LIBS
      LPOKE37:
	MOVEQ	#33,D0			; OR V37!
	JSR	-552(A6)
	MOVE.L	D0,-48(A4)
	BEQ	LCLINT
	LEA	LINITGFX(PC),A1
	MOVEQ	#33,D0
	JSR	-552(A6)
	MOVE.L	D0,-52(A4)
	BEQ	LCLGFX
	LEA	LINITDOS(PC),A1
	MOVEQ	#33,D0			; WE WILL USE FUNCTIONS NOT IN V32
	JSR	-552(A6)
	MOVE.L	D0,-44(A4)
	BEQ	LCLDOS
	MOVE.L	A4,(A5)			; PUT A4 IN TABLE
	BRA.S	LGLOBJUMP
      LINITDOS:		DC.B	"dos.library",0
      LINITINTUI:	DC.B	"intuition.library",0
      LINITGFX:		DC.B	"graphics.library",0
      LZEROSPOT:	DC.B	0
	EVEN
      LMIDC:
      LGLOBJUMP:
	JMP	LGLOBJUMP
      LNOMEM:
      LRTS:
	RTS
      LEXITC:				; START OF CLOSE, A4=A4
	JSR	LEXITC
      LEXITC3:
	JSR	LRTS
      LEXITC2:
	MOVE.L	A7,-4(A4)
	MOVE.L	4.W,A6
	MOVE.L	-20(A4),A2		; CLEANUP MEMORY
	MOVE.L	A2,D0
	BEQ.S	.3
.4:	MOVE.L	A2,A1
	MOVE.L	4(A2),D0
	MOVE.L	(A2),A2
	JSR	-210(A6)
	MOVE.L	A2,D0
	BNE.S	.4	
.3:	MOVE.L	-44(A4),A1
	JSR	-414(A6)		; closedos
LCLDOS:	MOVE.L	-52(A4),A1
	JSR	-414(A6)		; closegfx
LCLGFX:	MOVE.L	-48(A4),A1
	JSR	-414(A6)		; closeintui
LCLINT:
      LENDC2:
	MOVE.L	#$20000,D0
	MOVE.L	-64(A4),A1
	MOVE.L	-4(A4),A7
	JSR	-210(A6)
	MOVEQ	#0,D0			; FAIL (OPEN ONLY)
	RTS
      LENDC:

LibName:
IDString:

ENDFUNTAB:

      COPYC:				; A0=START,D0=END,A4=DEST
	SUB.L	A0,D0
	LSR.L	#1,D0
	SUBQ.L	#1,D0
.1:	MOVE.W	(A0)+,(A4)+
 	DBRA	D0,.1
 	RTS

      COPYRELOC:
	MOVE.L	A4,D0
	MOVE.L	(A0)+,(A4)+
	BSR	ADDDIVRELOC
	RTS

      LMAKEINITCODE:
	MOVE.L	LIBINFO(PC),A6		; A6=LIBINFO
	MOVE.L	12(A6),D2
	SUB.L	(A6),D2
	LEA	Start(PC),A0
	MOVE.L	(A0)+,(A4)+
	MOVE.W	(A0)+,(A4)+
	BSR.S	COPYRELOC		; MATCHTAG
	BSR.S	COPYRELOC		; ENDSKIP
	MOVE.B	(A0)+,(A4)+
	ADDQ.L	#1,A0
	MOVE.B	7(A6),(A4)+		; VERSION
	MOVE.W	(A0)+,(A4)+
	BSR.S	COPYRELOC		; LIBNAME
	BSR.S	COPYRELOC		; IDSTRING
	ADD.L	D2,-4(A4)
	BSR.S	COPYRELOC		; INIT
	MOVE.L	(A0)+,(A4)+
	MOVE.L	A4,FUNTABADR
	ADDQ.L	#4,A0
	CLR.L	(A4)+			; FUN INIT
	BSR.S	COPYRELOC		; DATA INIT
	BSR.S	COPYRELOC		; RUN
	MOVE.L	(A0)+,(A4)+
	MOVE.W	(A0)+,(A4)+
	BSR.S	COPYRELOC		; LIBNAME
	MOVE.L	(A0)+,(A4)+
	MOVE.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.CLOSE(PC),A1
.IL:	CMPM.B	(A2)+,(A1)+
	BNE.S	.CL
	TST.B	-1(A2)
	BNE.S	.IL
	CMPI.B	#LAB,4(A3)
	BNE.S	.CL
	MOVE.L	6(A3),D4		; NO LABELS
	BEQ.S	.CL
	MOVE.L	D4,A2			; A2=PROC
	BTST	#1,2(A2)
	BNE	ERROR70			; NO METHODS
	TST.W	(A2)
	BNE	ERROR70			; NO ARGS
	BSET	#0,5(A3)
	MOVE.W	10(A3),D0
	BSR	ADDBRANCHRELOC
	BRA.S	.CN
.CLOSE:	DC.B	"close",0
.NF:	MOVE.L	A4,D0
	BSR	ADDDIVRELOC
	MOVE.L	A4,D3
	SUB.L	#LEXITC3-LRTS+2,D3
	SUB.L	ACODE(PC),D3
	MOVE.L	D3,(A4)+
.CN:	MOVEM.L	(A7)+,D3-D4/A1-A3

	LEA	LEXITC2(PC),A0
	MOVE.L	#LENDC2,D0
	BSR	COPYC
	LEA	LENDC2(PC),A0
	MOVE.W	(A0)+,(A4)+
	MOVE.L	A4,STACKPOKE+4
	ADDQ.L	#4,A4
	ADDQ.L	#4,A0
	MOVE.L	#LENDC,D0
	BSR	COPYC
	MOVE.L	LIBINFO(PC),A6
	MOVE.L	(A6),A0
.1:	MOVE.B	(A0)+,(A4)+
 	BNE.S	.1
	MOVE.L	12(A6),A0
.2:	MOVE.B	(A0)+,(A4)+
 	BNE.S	.2
 	MOVE.L	A4,D0
 	BTST	#0,D0
 	BEQ.S	.3
 	CLR.B	(A4)+
.3:	BSR	FIXPROCCODE
	MOVE.L	A4,CURACODE
	RTS

      FUNTABADR:	DC.L	0

funcTable:
	dc.l	Open-Start
	dc.l	Close-Start
	dc.l	Expung-Start
	dc.l	Null-Start

GETA4:	MOVE.L	4.W,A1			; COPY IN GETTC!!!
	MOVE.L	276(A1),A1		; A1=THISTASK
	MOVE.L	A1,D1
	AND.W	#TASKTABSTOREMASK,D1
	LEA	sb_TASKS(A6,D1.W),A0	; A0=HASHED TASKTABLE
	MOVEQ	#TASKTABSIZE-1,D1	; D1=SIZE
.L:	CMPA.L	(A0)+,A1
	BEQ.S	.F
	ADDQ.L	#4,A0
	DBRA	D1,.L
	SUB.L	A4,A4			; BIG PROBLEM HERE!!!
	RTS
.F:	MOVE.L	(A0)+,A4
	RTS
ENDGETA4:

      BUILDLIBFUNS:
	MOVE.L	LIBINFO(PC),D6
	BEQ.W	.X
	MOVE.L	D6,A6			; A6 = LIBINFO
	MOVE.L	CURACODE(PC),A4		; A4 = CODE
	MOVE.L	FUNTABADR(PC),A5
	MOVE.L	A4,D0
	SUB.L	ACODE(PC),D0
	MOVE.L	D0,(A5)
	MOVE.L	A5,D0
	BSR	ADDDIVRELOC
	LEA	funcTable(PC),A0
	BSR	COPYRELOC
	BSR	COPYRELOC
	BSR	COPYRELOC
	BSR	COPYRELOC
	MOVE.L	A4,A2			; A2 = LIBTAB
	MOVE.W	18(A6),D0
	LSL.W	#2,D0
	ADD.W	D0,A4
	MOVE.L	#-1,(A4)+
	MOVE.L	A4,D7			; D7 = GETA4ADDR
	LEA	GETA4(PC),A0
	MOVE.L	#ENDGETA4,D0
	BSR	COPYC
	LEA	20(A6),A6		; A6 = FUNTAB
.L:	MOVE.L	(A6)+,D0
	BEQ.W	.C
	ADD.W	#20-4,A6
	MOVE.L	D0,A5			; A5 = IDENT
	CMP.B	#LAB,4(A5)
	BNE	ERROR70
	BTST	#4,5(A5)
	BNE	ERROR70
	MOVE.L	6(A5),D0
	BEQ	ERROR70
	MOVE.L	D0,A3			; A3 = PROC
	TST.L	10(A3)
	BNE	ERROR70
	MOVE.L	A2,D0
	BSR	ADDDIVRELOC
	MOVE.L	A4,D0
	SUB.L	ACODE(PC),D0
	MOVE.L	D0,(A2)+
	MOVE.L	.M1(PC),(A4)+
	MOVE.W	-2(A6),D4
	BMI.S	.NS
	CMP.W	(A3),D4			; BOTH LIBFUN DECLS NARGS
	BNE	ERROR70
.NS:	MOVE.W	(A3),D4
	BEQ.W	.R
	CMP.W	#13,D4
	BPL	ERROR70
	TST.W	-4(A6)
	BMI.S	.NS2

	MOVEM.L	D0/D1/A0,-(A7)
	LEA	-16(A6),A0
	MOVE.W	-2(A6),D0
	SUBQ.W	#1,D0
	MOVEQ	#0,D1
.RML:	MOVE.B	(A0)+,D1
	MOVE.W	.MV1(PC),(A4)
	OR.W	D1,(A4)+
	DBRA	D0,.RML
	MOVEM.L	(A7)+,D0/D1/A0

	BRA.S	.R
.NS2:	CMP.W	#1,D4
	BEQ.W	.ONE
	SUBQ.W	#2,D4
	LSL.W	#1,D4
	MOVE.W	.M1(PC),(A4)+
	MOVE.W	.TAB(PC,D4.W),(A4)+
.R:	MOVE.W	.BSR(PC),(A4)+		; 2XENTRY
	MOVE.L	D7,D0
	SUB.L	A4,D0
	MOVE.W	D0,(A4)+
	MOVE.W	10(A5),D0
	MOVE.W	.JSR(PC),NEWOP
	MOVE.L	.BSR(PC),(A4)+
	BSR	ADDBRANCH
	MOVE.W	(A3),D4
	BEQ.S	.R2
	CMP.W	#1,D4
	BEQ.S	.ONEA
	CMP.W	#2,D4
	BEQ.S	.TWOA
	LSL.W	#2,D4
	MOVE.W	.LEA(PC),(A4)+
	MOVE.W	D4,(A4)+
.R2:	MOVE.L	.M2(PC),(A4)+
	MOVE.W	.RTS(PC),(A4)+
	BRA.W	.L
.C:	MOVE.L	A4,CURACODE
.X:	RTS
.TAB:	DC.W	%1000000010000000	; 2
	DC.W	%1100000010000000	; 3
	DC.W	%1100000011000000	; 4
	DC.W	%1110000011000000	; 5
	DC.W	%1110000011100000	; 6
	DC.W	%1111000011100000	; 7
	DC.W	%1111000011110000	; 8
	DC.W	%1111100011110000	; 9
	DC.W	%1111110011110000	; 10
	DC.W	%1111111011110000	; 11
	DC.W	%1111111111110000	; 12
.M1:	MOVEM.L	D2/A2-A6,-(A7)
.M2:	MOVEM.L	(A7)+,D2/A2-A6
.MV1:	MOVE.L	D0,-(A7)
.RTS:	RTS
.BSR:	BSR	.X
.JSR:	JSR	.X
.LEA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COPY
.1:	BTST	#4,CODEPREFS+1
	BEQ.S	.2
	LEA	CLOSEMATHTRANS(PC),A0
	MOVE.L	#CLOSETRANSEND,D0
	BSR	CCOPY
.2:	MOVE.W	.RTS(PC),(A4)+
	MOVE.L	A4,CURACODE
	JSR	CHECK3
.EX:
.RTS:	RTS

      CCOPY:
	SUB.L	A0,D0
	LSR.L	#1,D0
	SUBQ.L	#1,D0
.L:	MOVE.W	(A0)+,(A4)+
	DBRA	D0,.L
	RTS

      OPENMATHBAS:
	BRA.S	BASCONT
      INITMATH:
	DC.B	"mathieeesingbas.library",0
	EVEN
      BASCONT:
	MOVE.L	4.W,A6
	LEA	INITMATH(PC),A1
	MOVEQ	#33,D0
	JSR	-552(A6)
	MOVE.L	D0,-56(A4)
	BNE.S	OPENBASEND
	MOVEQ	#0,D2
      OPENBASEND:

      OPENMATHTRANS:
	BRA.S	TRANSCONT
      INITMATHT:
	DC.B	"mathieeesingtrans.library",0
	EVEN
      TRANSCONT:
	MOVE.L	4.W,A6
	LEA	INITMATHT(PC),A1
	MOVEQ	#33,D0
	JSR	-552(A6)
	MOVE.L	D0,-60(A4)
	BNE.S	OPENTRANSEND
	MOVEQ	#0,D2
      OPENTRANSEND:

      CLOSEMATHBAS:
	MOVE.L	4.W,A6
	MOVE.L	-56(A4),D0
	BEQ.S	CLOSEBASEND
	MOVE.L	D0,A1
	JSR	-414(A6)
      CLOSEBASEND:

      CLOSEMATHTRANS:
	MOVE.L	4.W,A6
	MOVE.L	-60(A4),D0
	BEQ.S	CLOSETRANSEND
	MOVE.L	D0,A1
	JSR	-414(A6)
      CLOSETRANSEND:

      ADDGLOBVARS:
	BTST	#3,CODEPREFS+3
	BEQ.S	.C
	RTS
.C:	GETM	A5
	LEA	GLOBVARTAB(PC),A4
.1:	MOVE.L	(A4)+,D7
	MOVE.L	(A4)+,D6
	BEQ.S	.2
	CMP.L	#GLOBVARTAB+24,A4
	BNE.S	.NARG
	LEA	9(A5),A1
	MOVE.L	A1,ARGBYTE
.NARG:	MOVE.L	D7,A1
	HASH	A1,D0,D1
	LSL.L	#2,D0
	MOVE.L	#IDENTHASH,A1
	ADD.L	D0,A1
	MOVE.L	(A1),(A5)+
	MOVE.L	A5,(A1)
	MOVE.L	D7,(A5)+		; SET ASCIIPTR
	MOVE.B	#GLOBV,(A5)+		; SET GLOBAL(=2)
	MOVE.B	#2,(A5)+		; UNREF+SYSTEMVAR
	CLR.L	(A5)+
	MOVE.W	D6,(A5)+		; SET OFFS
	BRA.S	.1
.2:	DONEH	A5
BURP:	MOVEQ	#NRSYSCONST,D0
	SUBQ.W	#1,D0
	GETM	A0
	LEA	SYSCONST(PC),A1
.3:	MOVE.L	(A1)+,A2
	MOVE.L	A2,A3
	HASH	A3,D1,D2
	LSL.L	#2,D1
	ADD.L	#CONSTHASH,D1
	MOVE.L	D1,A3
	MOVE.L	(A3),(A0)
	MOVE.L	A0,(A3)
	ADDQ.L	#4,A0
	MOVE.L	A2,(A0)+
	CMPA.L	#SYSCONST+36,A1
	BNE.S	.SL
	MOVE.L	A0,STRLENADR
.SL:	MOVE.L	(A1)+,(A0)+
	CLR.W	(A0)+
	DBRA	D0,.3
	DONEH	A0
	RTS

NRSYSCONST	= 9
STRLENADR:	DC.L	0

      SYSCONST:
	DC.L	.1,-1,.2,0,.3,0,.4,-1,.5,0,.6,120,.7,1005,.8,1006,.9,0
.1:	DC.B	"TRUE",0
.2:	DC.B	"FALSE",0
.3:	DC.B	"NIL",0
.4:	DC.B	"ALL",0
.5:	DC.B	"STRLEN",0		; MUST BE #5
.6:	DC.B	"GADGETSIZE",0
.7:	DC.B	"OLDFILE",0
.8:	DC.B	"NEWFILE",0
.9:	DC.B	"EMPTY",0
	EVEN

      ARGBYTE:	DC.L	0		; EXACT BYTE LOC OF "arg".FLAGS

      GLOBVARTAB:
	DC.L	.1,-8
	DC.L	.2,-12
	DC.L	.3,-32			; must be 16..24 bytes offset
	DC.L	.4,-40
	DC.L	.5,-44
	DC.L	.6,-48
	DC.L	.7,-52
	DC.L	.8,-16
	DC.L	.9,-36
;	DC.L	.10,-56
	DC.L	.11,-84
	DC.L	.12,-92
	DC.L	.13,-96
	DC.L	0,0

.1:	DC.B	"stdout",0
.2:	DC.B	"conout",0
.3:	DC.B	"arg",0			; MUST BE 3RD
.4:	DC.B	"execbase",0
.5:	DC.B	"dosbase",0
.6:	DC.B	"intuitionbase",0
.7:	DC.B	"gfxbase",0
.8:	DC.B	"stdrast",0
.9:	DC.B	"wbmessage",0
;.10:	DC.B	"mathieeesingbasbase",0
.11:	DC.B	"exception",0
.12:	DC.B	"stdin",0
.13:	DC.B	"exceptioninfo",0
	EVEN

      INITFUNCS:			; init efuncs
	MOVE.L	#EFUNCBYTE,A0
	MOVE.L	#EFUNCRAISE,A1
	MOVE.W	#NREFUNC,D0
	SUBQ.W	#1,D0
	MOVEQ	#0,D1
.1:	MOVE.B	D1,(A0)+
	MOVE.W	D1,(A1)+
	ADDQ.L	#8,A1
	DBRA	D0,.1
	RTS

      LINKDELEGATECONSTRUCTORS:
	LEA	OLIST+4,A0
.L:	MOVE.L	-(A0),D0
	BEQ	.X
	MOVE.L	D0,A0
	TST.W	ODEL(A0)
	BEQ.S	.L
	BTST	#1,OFLAGS(A0)
	BNE.S	.L
	MOVE.L	CURACODE,A4		; 32K VERWEG !
	MOVE.L	A4,ODCODE(A0)		; SET DCODE FOR THIS OBJECT
	MOVE.L	OSUPER(A0),D0
	BEQ.S	.NSUP
	MOVE.L	D0,A2			; A2=SUPER
	TST.W	(A2)			; CHECK IF SUPER HAS DELCONSTRUCTOR
	BEQ.S	.NSUP
	GETM	A1
	MOVE.L	OACC(A2),(A1)		; ADD TO ACCESSLIST OF SUPER
	MOVE.L	A1,OACC(A2)
	ADDQ.L	#4,A1
	MOVE.W	.J(PC),(A4)+		; MAKE JSR SUPERDELEGATECONSTR.
	MOVE.L	A4,(A1)+
	MOVE.W	#1,(A1)+
	DONEM	A1
	CLR.L	(A4)+
.NSUP:	MOVE.W	.GL(P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,D5		; IIII
	RTS


      GVA0D0_0:
	GENVAR	0,A0,10(A0),D0		; III
	RTS
      GVA0D1_0:
	GENVAR	0,A0,10(A0),D1		; IIIII
	RTS
      GVA0D2_0:
	MOVE.L	D1,-(A7)
	MOVE.L	D2,D1
	BSR.S	GVA0D1_0		; II
	MOVE.L	(A7)+,D1
	RTS
      GVA0D3_0:
	MOVE.L	D1,-(A7)
	MOVE.L	D3,D1
	BSR.W	GVA0D1_0		; I
	MOVE.L	(A7)+,D1
	RTS
      GVA0D4_0:
	MOVE.L	D1,-(A7)
	MOVE.L	D4,D1
	BSR.W	GVA0D1_0		; I
	MOVE.L	(A7)+,D1
	RTS
      GVA1D2_0:
	GENVAR	0,A1,10(A1),D2		; I
	RTS
      GVA6D3_0:
	GENVAR	0,A6,10(A6),D3		; I
	RTS


      GVA0D0_9:
	GENVAR	9,A0,10(A0),D0		; II
	RTS
      GVA0D2_9:
	MOVE.L	D0,-(A7)
	MOVE.L	D2,D0
	BSR.W	GVA0D0_9		; I
	MOVE.L	(A7)+,D0
	RTS
      GVA0D4_9:
	MOVE.L	D0,-(A7)
	MOVE.L	D4,D0
	BSR.W	GVA0D0_9		; II
	MOVE.L	(A7)+,D0
	RTS
      GVA0D5_9:
	MOVE.L	D0,-(A7)
	MOVE.L	D5,D0
	BSR.W	GVA0D0_9		; I
	MOVE.L	(A7)+,D0
	RTS
      GVA0D7_9:
	MOVE.L	D0,-(A7)
	MOVE.L	D7,D0
	BSR.W	GVA0D0_9		; I
	MOVE.L	(A7)+,D0
	RTS

      GVA1D2_9:
	GENVAR	9,A1,10(A1),D2		; I
	RTS
      GVA6D0_9:
	GENVAR	9,A6,10(A6),D0		; I
	RTS
      GVA6D3_9:
	MOVE.L	D0,-(A7)
	MOVE.L	D3,D0
	BSR.W	GVA6D0_9		; II
	MOVE.L	(A7)+,D0
	RTS




; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
;	The Internal LIBRARYCALLS				;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;


EXEC:
 DC.B "Supervisor",13,16,16,16,16,16,16,"InitCode",0
 DC.B 1,"InitStruct",9,10,0,"MakeLibrary",8,9,10,0,1,"MakeFunctions",8,9,10
 DC.B "FindResident",9,"InitResident",9,1,"Alert",7,"Debug",0,"Disable",16
 DC.B "Enable",16,"Forbid",16,"Permit",16,"SetSR",0,1,"SuperState",16
 DC.B "UserState",0,"SetIntVector",0,9,"AddIntServer",0,9,"RemIntServer",0,9
 DC.B "Cause",9,"Allocate",8,0,"Deallocate",8,9,0,"AllocMem",0,1,"AllocAbs",0
 DC.B 9,"FreeMem",9,0,"AvailMem",1,"AllocEntry",8,"FreeEntry",8,"Insert",8,9
 DC.B 10,"AddHead",8,9,"AddTail",8,9,"Remove",9,"RemHead",8,"RemTail",8
 DC.B "Enqueue",8,9,"FindName",8,9,"AddTask",9,10,11,"RemTask",9,"FindTask",9
 DC.B "SetTaskPri",9,0,"SetSignal",0,1,"SetExcept",0,1,"Wait",0,"Signal",9,0
 DC.B "AllocSignal",0,"FreeSignal",0,"AllocTrap",0,"FreeTrap",0,"AddPort",9
 DC.B "RemPort",9,"PutMsg",8,9,"GetMsg",8,"ReplyMsg",9,"WaitPort",8,"FindPort"
 DC.B 9,"AddLibrary",9,"RemLibrary",9,"OldOpenLibrary",9,"CloseLibrary",9
 DC.B "SetFunction",9,8,0,"SumLibrary",9,"AddDevice",9,"RemDevice",9
 DC.B "OpenDevice",8,0,9,1,"CloseDevice",9,"DoIO",9,"SendIO",9,"CheckIO",9
 DC.B "WaitIO",9,"AbortIO",9,"AddResource",9,"RemResource",9,"OpenResource",9
 DC.B 16,16,16,"RawDoFmt",8,9,10,11,"GetCC",16,"TypeOfMem",9,"Procure",8,9
 DC.B "Vacate",8,9,"OpenLibrary",9,0,"InitSemaphore",8,"ObtainSemaphore",8
 DC.B "ReleaseSemaphore",8,"AttemptSemaphore",8,"ObtainSemaphoreList",8
 DC.B "ReleaseSemaphoreList",8,"FindSemaphore",9,"AddSemaphore",9
 DC.B "RemSemaphore",9,"SumKickData",16,"AddMemList",0,1,2,8,9,"CopyMem",8,9,0
 DC.B "CopyMemQuick",8,9,0,"CacheClearU",16,"CacheClearE",8,0,1,"CacheControl"
 DC.B 0,1,"CreateIORequest",8,0,"DeleteIORequest",8,"CreateMsgPort",16
 DC.B "DeleteMsgPort",8,"ObtainSemaphoreShared",8,"AllocVec",0,1,"FreeVec",9
 DC.B "CreatePool",0,1,2,"DeletePool",8,"AllocPooled",8,0,"FreePooled",8,9,0
 DC.B "AttemptSemaphoreShared",8,"ColdReboot",16,"StackSwap",8,"ChildFree",0
 DC.B "ChildOrphan",0,"ChildStatus",0,"ChildWait",0,"CachePreDMA",8,9,0
 DC.B "CachePostDMA",8,9,0,"AddMemHandler",9,"RemMemHandler",9
 DC.B "ObtainQuickVector",8,"ÿ",0,0,0,0

GFX:
 DC.B "BltBitMap",8,0,1,9,2,3,4,5,6,7,10
 DC.B "BltTemplate",8,0,1,9,2,3,4,5,"ClearEOL",9,"ClearScreen",9,"TextLength"
 DC.B 9,8,0,"Text",9,8,0,"SetFont",9,8,"OpenFont",8,"CloseFont",9
 DC.B "AskSoftStyle",9,"SetSoftStyle",9,0,1,"AddBob",8,9,"AddVSprite",8,9
 DC.B "DoCollision",9,"DrawGList",9,8,"InitGels",8,9,10,"InitMasks",8
 DC.B "RemIBob",8,9,10,"RemVSprite",8,"SetCollision",0,8,9,"SortGList",9
 DC.B "AddAnimOb",8,9,10,"Animate",8,9,"GetGBuffers",8,9,0,"InitGMasks",8
 DC.B "DrawEllipse",9,0,1,2,3,"AreaEllipse",9,0,1,2,3,"LoadRGB4",8,9,0
 DC.B "InitRastPort",9,"InitVPort",8,"MrgCop",9,"MakeVPort",8,9,"LoadView",9
 DC.B "WaitBlit",16,"SetRast",9,0,"Move",9,0,1,"Draw",9,0,1,"AreaMove",9,0,1
 DC.B "AreaDraw",9,0,1,"AreaEnd",9,"WaitTOF",16,"Qblit",9,"InitArea",8,9,0
 DC.B "SetRGB4",8,0,1,2,3,"QbSBlit",9,"BltClear",9,0,1,"RectFill",9,0,1,2,3
 DC.B "BltPattern",9,8,0,1,2,3,4,"ReadPixel",9,0,1,"WritePixel",9,0,1,"Flood"
 DC.B 9,2,0,1,"PolyDraw",9,0,8,"SetAPen",9,0,"SetBPen",9,0,"SetDrMd",9,0
 DC.B "InitView",9,"Cbump",9,"Cmove",9,0,1,"Cwait",9,0,1,"VbeamPos",16
 DC.B "InitBitMap",8,0,1,2,"ScrollRaster",9,0,1,2,3,4,5,"WaitBOVP",8
 DC.B "GetSprite",8,0,"FreeSprite",0,"ChangeSprite",8,9,10,"MoveSprite",8,9,0
 DC.B 1,"LockLayerRom",13,"UnlockLayerRom",13,"SyncSBitMap",8,"CopySBitMap",8
 DC.B "OwnBlitter",16,"DisownBlitter",16,"InitTmpRas",8,9,0,"AskFont",9,8
 DC.B "AddFont",9,"RemFont",9,"AllocRaster",0,1,"FreeRaster",8,0,1
 DC.B "AndRectRegion",8,9,"OrRectRegion",8,9,"NewRegion",16,"ClearRectRegion"
 DC.B 8,9,"ClearRegion",8,"DisposeRegion",8,"FreeVPortCopLists",8
 DC.B "FreeCopList",8,"ClipBlit",8,0,1,9,2,3,4,5,6,"XorRectRegion",8,9
 DC.B "FreeCprList",8,"GetColorMap",0,"FreeColorMap",8,"GetRGB4",8,0
 DC.B "ScrollVPort",8,"UcopperListInit",8,0,"FreeGBuffers",8,9,0
 DC.B "BltBitMapRastPort",8,0,1,9,2,3,4,5,6,"OrRegionRegion",8,9
 DC.B "XorRegionRegion",8,9,"AndRegionRegion",8,9,"SetRGB4CM",8,0,1,2,3
 DC.B "BltMaskBitMapRastPort",8,0,1,9,2,3,4,5,6,10,16,16,"AttemptLockLayerRom"
 DC.B 13,"GfxNew",0,"GfxFree",8,"GfxAssociate",8,9,"BitMapScale",8,"ScalerDiv"
 DC.B 0,1,2,"TextExtent",9,8,0,10,"TextFit",9,8,0,10,11,1,2,3,"GfxLookUp",8
 DC.B "VideoControl",8,9,"OpenMonitor",9,0,"CloseMonitor",8,"FindDisplayInfo"
 DC.B 0,"NextDisplayInfo",0,16,16,16,"GetDisplayInfoData",8,9,0,1,2
 DC.B "FontExtent",8,9,"ReadPixelLine8",8,0,1,2,10,9,"WritePixelLine8",8,0,1,2
 DC.B 10,9,"ReadPixelArray8",8,0,1,2,3,10,9,"WritePixelArray8",8,0,1,2,3,10,9
 DC.B "GetVPModeID",8,"ModeNotAvailable",0,"WeighTAMatch",8,9,10,"EraseRect",9
 DC.B 0,1,2,3,"ExtendFont",8,9,"StripFont",8,"CalcIVG",8,9,"AttachPalExtra",8
 DC.B 9,"ObtainBestPenA",8,1,2,3,9,16,"SetRGB32",8,0,1,2,3,"GetAPen",8
 DC.B "GetBPen",8,"GetDrMd",8,"GetOutlinePen",8,"LoadRGB32",8,9,"SetChipRev",0
 DC.B "SetABPenDrMd",9,0,1,2,"GetRGB32",8,0,1,9,16,16,"AllocBitMap",0,1,2,3,8
 DC.B "FreeBitMap",8,"GetExtSpriteA",10,9,"CoerceMode",8,0,1,"ChangeVPBitMap"
 DC.B 8,9,10,"ReleasePen",8,0,"ObtainPen",8,0,1,2,3,4,"GetBitMapAttr",8,1
 DC.B "AllocDBufInfo",8,"FreeDBufInfo",9,"SetOutlinePen",8,0,"SetWriteMask",8
 DC.B 0,"SetMaxPen",8,0,"SetRGB32CM",8,0,1,2,3,"ScrollRasterBF",9,0,1,2,3,4,5
 DC.B "FindColor",11,1,2,3,4,16,"AllocSpriteDataA",10,9,"ChangeExtSpriteA",8,9
 DC.B 10,11,"FreeSpriteData",10,"SetRPAttrsA",8,9,"GetRPAttrsA",8,9
 DC.B "BestModeIDA",8,"WriteChunkyPixels",8,0,1,2,3,10,4,"ÿ",0,0,0,0


INTUI:
 DC.B "OpenIntuition",16,"Intuition",8
 DC.B "AddGadget",8,9,0,"ClearDMRequest",8,"ClearMenuStrip",8,"ClearPointer",8
 DC.B "CloseScreen",8,"CloseWindow",8,"CloseWorkBench",16,"CurrentTime",8,9
 DC.B "DisplayAlert",0,8,1,"DisplayBeep",8,"DoubleClick",0,1,2,3,"DrawBorder"
 DC.B 8,9,0,1,"DrawImage",8,9,0,1,"EndRequest",8,9,"GetDefPrefs",8,0
 DC.B "GetPrefs",8,0,"InitRequester",8,"ItemAddress",8,0,"ModifyIDCMP",8,0
 DC.B "ModifyProp",8,9,10,0,1,2,3,4,"MoveScreen",8,0,1,"MoveWindow",8,0,1
 DC.B "OffGadget",8,9,10,"OffMenu",8,0,"OnGadget",8,9,10,"OnMenu",8,0
 DC.B "OpenScreen",8,"OpenWindow",8,"OpenWorkBench",16,"PrintIText",8,9,0,1
 DC.B "RefreshGadgets",8,9,10,"RemoveGadget",8,9,"ReportMouse",0,8,"Request",8
 DC.B 9,"ScreenToBack",8,"ScreenToFront",8,"SetDMRequest",8,9,"SetMenuStrip",8
 DC.B 9,"SetPointer",8,9,0,1,2,3,"SetWindowTitles",8,9,10,"ShowTitle",8,0
 DC.B "SizeWindow",8,0,1,"ViewAddress",16,"ViewPortAddress",8,"WindowToBack",8
 DC.B "WindowToFront",8,"WindowLimits",8,0,1,2,3,"SetPrefs",8,0,1
 DC.B "IntuiTextLength",8,"WbenchToBack",16,"WbenchToFront",16,"AutoRequest",8
 DC.B 9,10,11,0,1,2,3,"BeginRefresh",8,"BuildSysRequest",8,9,10,11,0,1,2
 DC.B "EndRefresh",8,0,"FreeSysRequest",8,"MakeScreen",8,"RemakeDisplay",16
 DC.B "RethinkDisplay",16,"AllocRemember",8,0,1,"AlohaWorkbench",8
 DC.B "FreeRemember",8,0,"LockIBase",0,"UnlockIBase",8,"GetScreenData",8,0,1,9
 DC.B "RefreshGList",8,9,10,0,"AddGList",8,9,0,1,10,"RemoveGList",8,9,0
 DC.B "ActivateWindow",8,"RefreshWindowFrame",8,"ActivateGadget",8,9,10
 DC.B "NewModifyProp",8,9,10,0,1,2,3,4,5,"QueryOverscan",8,9,0
 DC.B "MoveWindowInFrontOf",8,9,"ChangeWindowBox",8,0,1,2,3,"SetEditHook",8
 DC.B "SetMouseQueue",8,0,"ZipWindow",8,"LockPubScreen",8,"UnlockPubScreen",8
 DC.B 9,"LockPubScreenList",16,"UnlockPubScreenList",16,"NextPubScreen",8,9
 DC.B "SetDefaultPubScreen",8,"SetPubScreenModes",0,"PubScreenStatus",8,0
 DC.B "ObtainGIRPort",8,"ReleaseGIRPort",8,"GadgetMouse",8,9,10,16
 DC.B "GetDefaultPubScreen",8,"EasyRequestArgs",8,9,10,11
 DC.B "BuildEasyRequestArgs",8,9,0,11,"SysReqHandler",8,9,0
 DC.B "OpenWindowTagList",8,9,"OpenScreenTagList",8,9,"DrawImageState",8,9,0,1
 DC.B 2,10,"PointInImage",0,8,"EraseImage",8,9,0,1,"NewObjectA",8,9,10
 DC.B "DisposeObject",8,"SetAttrsA",8,9,"GetAttr",0,8,9,"SetGadgetAttrsA",8,9
 DC.B 10,11,"NextObject",8,16,"MakeClass",8,9,10,0,1,"AddClass",8
 DC.B "GetScreenDrawInfo",8,"FreeScreenDrawInfo",8,9,"ResetMenuStrip",8,9
 DC.B "RemoveClass",8,"FreeClass",8,16,16,16,16,16,16,16,16
 DC.B "AllocScreenBuffer",8,9,0,"FreeScreenBuffer",8,9,"ChangeScreenBuffer",8
 DC.B 9,"ScreenDepth",8,0,9,"ScreenPosition",8,0,1,2,3,4,"ScrollWindowRaster"
 DC.B 9,0,1,2,3,4,5,"LendMenus",8,9,"DoGadgetMethodA",8,9,10,11
 DC.B "SetWindowPointerA",8,9,"TimedDisplayAlert",0,8,1,9,"HelpControl",8,0
 DC.B "ÿ",0,0,0,0

DOS:
 DC.B "Open",1,2,"Close",1,"Read",1,2,3,"Write",1,2,3
 DC.B "Input",16,"Output",16,"Seek",1,2,3,"DeleteFile",1,"Rename",1,2,"Lock",1
 DC.B 2,"UnLock",1,"DupLock",1,"Examine",1,2,"ExNext",1,2,"Info",1,2
 DC.B "CreateDir",1,"CurrentDir",1,"IoErr",16,"CreateProc",1,2,3,4,"Exit",1
 DC.B "LoadSeg",1,"UnLoadSeg",1,16,16,"DeviceProc",1,"SetComment",1,2
 DC.B "SetProtection",1,2,"DateStamp",1,"Delay",1,"WaitForChar",1,2
 DC.B "ParentDir",1,"IsInteractive",1,"Execute",1,2,3,"AllocDosObject",1,2
 DC.B "FreeDosObject",1,2,"DoPkt",1,2,3,4,5,6,7,"SendPkt",1,2,3,"WaitPkt",16
 DC.B "ReplyPkt",1,2,3,"AbortPkt",1,2,"LockRecord",1,2,3,4,5,"LockRecords",1,2
 DC.B "UnLockRecord",1,2,3,"UnLockRecords",1,"SelectInput",1,"SelectOutput",1
 DC.B "FgetC",1,"FputC",1,2,"UnGetC",1,2,"Fread",1,2,3,4,"Fwrite",1,2,3,4
 DC.B "Fgets",1,2,3,"Fputs",1,2,"VfWritef",1,2,3,"VfPrintf",1,2,3,"Flush",1
 DC.B "SetVBuf",1,2,3,4,"DupLockFromFH",1,"OpenFromLock",1,"ParentOfFH",1
 DC.B "ExamineFH",1,2,"SetFileDate",1,2,"NameFromLock",1,2,3,"NameFromFH",1,2
 DC.B 3,"SplitName",1,2,3,4,5,"SameLock",1,2,"SetMode",1,2,"ExAll",1,2,3,4,5
 DC.B "ReadLink",1,2,3,4,5,"MakeLink",1,2,3,"ChangeMode",1,2,3,"SetFileSize",1
 DC.B 2,3,"SetIoErr",1,"Fault",1,2,3,4,"PrintFault",1,2,"ErrorReport",1,2,3,4
 DC.B 16,"Cli",16,"CreateNewProc",1,"RunCommand",1,2,3,4,"GetConsoleTask",16
 DC.B "SetConsoleTask",1,"GetFileSysTask",16,"SetFileSysTask",1,"GetArgStr",16
 DC.B "SetArgStr",1,"FindCliProc",1,"MaxCli",16,"SetCurrentDirName",1
 DC.B "GetCurrentDirName",1,2,"SetProgramName",1,"GetProgramName",1,2
 DC.B "SetPrompt",1,"GetPrompt",1,2,"SetProgramDir",1,"GetProgramDir",16
 DC.B "SystemTagList",1,2,"AssignLock",1,2,"AssignLate",1,2,"AssignPath",1,2
 DC.B "AssignAdd",1,2,"RemAssignList",1,2,"GetDeviceProc",1,2,"FreeDeviceProc"
 DC.B 1,"LockDosList",1,"UnLockDosList",1,"AttemptLockDosList",1,"RemDosEntry"
 DC.B 1,"AddDosEntry",1,"FindDosEntry",1,2,3,"NextDosEntry",1,2,"MakeDosEntry"
 DC.B 1,2,"FreeDosEntry",1,"IsFileSystem",1,"Format",1,2,3,"Relabel",1,2
 DC.B "Inhibit",1,2,"AddBuffers",1,2,"CompareDates",1,2,"DateToStr",1
 DC.B "StrToDate",1,"InternalLoadSeg",0,8,9,10,"InternalUnLoadSeg",1,9
 DC.B "NewLoadSeg",1,2,"AddSegment",1,2,3,"FindSegment",1,2,3,"RemSegment",1
 DC.B "CheckSignal",1,"ReadArgs",1,2,3,"FindArg",1,2,"ReadItem",1,2,3
 DC.B "StrToLong",1,2,"MatchFirst",1,2,"MatchNext",1,"MatchEnd",1
 DC.B "ParsePattern",1,2,3,"MatchPattern",1,2,16,"FreeArgs",1,16,"FilePart",1
 DC.B "PathPart",1,"AddPart",1,2,3,"StartNotify",1,"EndNotify",1,"SetVar",1,2
 DC.B 3,4,"GetVar",1,2,3,4,"DeleteVar",1,2,"FindVar",1,2,16,"CliInitNewcli",8
 DC.B "CliInitRun",8,"WriteChars",1,2,"PutStr",1,"Vprintf",1,2,16
 DC.B "ParsePatternNoCase",1,2,3,"MatchPatternNoCase",1,2,16,"SameDevice",1,2
 DC.B "ExAllEnd",1,2,3,4,5,"SetOwner",1,2,"ÿ",0,0,0,0

 EVEN


      INSTABLE:				; +IOFF
	DC.L	.0,0,.1,0,.2,0,.3,0,.4,0,.5,0,.6,0,.7,0,.8,0,.9,0,.10,0,.11,0
	DC.L	.12,0,.13,0,.14,0,.15,0,.16,0,.17,0,.18,0,.19,0,.20,0,.21,0
	DC.L	.22,0,.23,0,.24,0,.25,0,.26,0,.27,0,.28,0,.29,0,.30,0,.31,0
	DC.L	.32,0,.33,0,.34,0,.35,0,.36,0,.37,0,.38,0,.39,0,.40,0,.41,0
	DC.L	.42,0,.43,0,.44,0,.45,0,.46,0,.47,0,.48,0,.49,0,.50,0,.51,0
	DC.L	.52,0,.53,0,.54,0,.55,0,.56,0,.57,0,.58,0,.59,0,.60,0,.61,0
	DC.L	.62,0,.63,0,.64,0,.65,0,.66,0,.67,0,.68,0,0,0

.0:	DC.B	'PROC',0
.1:	DC.B	'ENDPROC',0
.2:	DC.B	'IF',0
.3:	DC.B	'ENDIF',0
.4: 	DC.B	'VOID',0
.5: 	DC.B	'WHILE',0
.6: 	DC.B	'ENDWHILE',0
.7:	DC.B	'FOR',0
.8:	DC.B	'ENDFOR',0
.9:	DC.B	'SELECT',0
.10:	DC.B	'CASE',0
.11:	DC.B	'DEFAULT',0
.12:	DC.B	'ENDSELECT',0
.13:	DC.B	'REPEAT',0
.14:	DC.B	'UNTIL',0
.15:	DC.B	'JUMP',0
.16:	DC.B	'DEF',0
.17:	DC.B	0			; IS NOG _WEL_ LOCAL !!!
.18:	DC.B	'ELSE',0
.19:	DC.B	'INCBIN',0
.20:	DC.B	'LONG',0
.21:	DC.B	'INT',0
.22:	DC.B	'CHAR',0
.23:	DC.B	'INC',0
.24:	DC.B	'DEC',0
.25:	DC.B	'THEN',0
.26:	DC.B	'LOOP',0
.27:	DC.B	'ENDLOOP',0
.28:	DC.B	'DO',0
.29:	DC.B	'AND',0
.30:	DC.B	'OR',0
.31:	DC.B	'CONST',0
.32:	DC.B	'OPT',0
.33:	DC.B	'MODULE',0
.34:	DC.B	'STACK',0
.35:	DC.B	'EXIT',0
.36:	DC.B	'LARGE',0
.37:	DC.B	'ASM',0
.38:	DC.B	'NOWARN',0
.39:	DC.B	'TO',0
.40:	DC.B	'STEP',0
.41:	DC.B	'ARRAY',0
.42:	DC.B	'STRING',0
.43:	DC.B	'DIR',0
.44:	DC.B	'PTR',0
.45:	DC.B	'OF',0
.46:	DC.B	'ELSEIF',0
.47:	DC.B	'LIST',0
.48:	DC.B	'OBJECT',0
.49:	DC.B	'ENDOBJECT',0
.50:	DC.B	'SIZEOF',0
.51:	DC.B	'RETURN',0
.52:	DC.B	'OSVERSION',0
.53:	DC.B	'ENUM',0
.54:	DC.B	'SET',0
.55:	DC.B	'BUT',0
.56:	DC.B	'HANDLE',0
.57:	DC.B	'EXCEPT',0
.58:	DC.B	'RAISE',0
.59:	DC.B	'EXPORT',0
.60:	DC.B	'REG',0
.61:	DC.B	'END',0
.62:	DC.B	'IS',0
.63:	DC.B	'NEW',0
.64:	DC.B	'PUBLIC',0
.65:	DC.B	'PRIVATE',0
.66:	DC.B	'SUPER',0
.67:	DC.B	'PREPROCESS',0
.68:	DC.B	'LIBRARY',0
	EVEN



;;FUNCS

; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	;
;	ALL BUILDIN E FUNCTIONS					;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,	;

      EFUNCFLAGSTAB:
	DC.B	0,0,0,0,0,0,0,0,0,0	;  1-10
	DC.B	0,0,0,0,0,0,0,0,0,0	; 11-20
	DC.B	0,0,0,0,0,0,0,0,0,0	; 21-30
	DC.B	0,0,0,0,0,0,0,0,0,0	; 31-40
	DC.B	0,0,0,0,0,0,0,0,0,0	; 41-50
	DC.B	0,0,0,0,0,0,0,0,0,0	; 51-60
	DC.B	0,0,0,0,0,0,0,0,0,0	; 61-70
	DC.B	0,0,0,0,0,0,0,0,0,0	; 71-80
	DC.B	0,0,0,0,0,0,0,0,0,0	; 81-90
	DC.B	0,0,0,0,0,0,1,1,1,1	; 91-100
	DC.B	1,2,2,2,2,2,2,2,2,0	; 101-110
	DC.B	0,0,0,0,0,0,0,0,0,0	; 111-120
	DC.B	0,0,0,0,0,0,0,0,0,0	; 121-130
	DC.B	0,0,0,0,0,0,0,0,0,0	; 131-140

; BITS: 0 = USES MATHBAS
;       1 = USES MATHTRANS


FOFF		= $100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,2,0
	DC.L	.96,I_BOUNDS,3,0
	DC.L	.97,I_REALF,3,0
	DC.L	.98,I_REALVAL,1,0
	DC.L	.99,I_FABS,1,0
	DC.L	.100,I_FFLOOR,1,0
	DC.L	.101,I_FCEIL,1,0
	DC.L	.102,I_FSIN,1,0
	DC.L	.103,I_FCOS,1,0
	DC.L	.104,I_FTAN,1,0
	DC.L	.105,I_FEXP,1,0
	DC.L	.106,I_FLOG,1,0
	DC.L	.107,I_FPOW,2,0
	DC.L	.108,I_FSQRT,1,0
	DC.L	.109,I_FLOG10,1,0
	DC.L	.110,I_FASTDISPOSE,2,0
	DC.L	.111,I_FASTNEW,1,0
	DC.L	.112,I_MIN,2,0
	DC.L	.113,I_MAX,2,0
	DC.L	.114,I_OSTRCMP,3,$FF
	DC.L	.115,I_ASTRCOPY,3,$FF
	DC.L	.116,I_CELL,1,0
	DC.L	.117,I_FREECELLS,0,0
	DC.L	.118,I_SETCHUNKSIZE,1,0
	DC.L	.119,I_CAR,1,0
	DC.L	.120,I_CDR,1,0
	DC.L	.121,I_CONS,0,0
	DC.L	.122,I_FASTDISPOSELIST,1,0
	DC.L	.123,I_FATAN,1,0
	DC.L	.124,I_FSINCOS,2,0
	DC.L	.125,I_FSINH,1,0
	DC.L	.126,I_FCOSH,1,0
	DC.L	.127,I_FTANH,1,0
	DC.L	.128,I_FTIEEE,1,0
	DC.L	.129,I_FFIEEE,1,0
	DC.L	.130,I_FASIN,1,0
	DC.L	.131,I_FACOS,1,0
	DC.L	0,I_CODEEND,0,0

.1:	DC.B	'WriteF',0
.2:	DC.B	'Mul',0
.3:	DC.B	'Div',0
.4:	DC.B	'OpenW',0
.5:	DC.B	'OpenS',0
.6:	DC.B	'Mouse',0
.7:	DC.B	'Plot',0
.8:	DC.B	'Line',0
.9:	DC.B	'TextF',0
.10:	DC.B	'Colour',0
.11:	DC.B	'SetStdRast',0
.12:	DC.B	'SetStdOut',0
.13:	DC.B	'Long',0
.14:	DC.B	'Int',0
.15:	DC.B	'Char',0
.16:	DC.B	'PutLong',0
.17:	DC.B	'PutInt',0
.18:	DC.B	'PutChar',0
.19:	DC.B	'New',0
.20:	DC.B	'CleanUp',0
.21:	DC.B	'CloseW',0
.22:	DC.B	'CloseS',0
.23:	DC.B	'And',0
.24:	DC.B	'Or',0
.25:	DC.B	'Not',0
.26:	DC.B	'Gadget',0
.27:	DC.B	'SetTopaz',0
.28:	DC.B	'StrCmp',0
.29:	DC.B	'StrCopy',0
.30:	DC.B	'StrAdd',0
.31:	DC.B	'StrLen',0
.32:	DC.B	'EstrLen',0
.33:	DC.B	'StrMax',0
.34:	DC.B	'String',0
.35:	DC.B	'RightStr',0
.36:	DC.B	'MidStr',0
.37:	DC.B	'StringF',0
.38:	DC.B	'Val',0
.39:	DC.B	'InStr',0
.40:	DC.B	'TrimStr',0
.41:	DC.B	'UpperStr',0
.42:	DC.B	'LowerStr',0
.43:	DC.B	'ReadStr',0
.44:	DC.B	'Out',0
.45:	DC.B	'Inp',0
.46:	DC.B	'KickVersion',0
.47:	DC.B	'FileLength',0
.48:	DC.B	'MouseX',0
.49:	DC.B	'MouseY',0
.50:	DC.B	'FreeStack',0
.51:	DC.B	'CtrlC',0
.52:	DC.B	'List',0
.53:	DC.B	'ListCopy',0
.54:	DC.B	'ListAdd',0
.55:	DC.B	'ListCmp',0
.56:	DC.B	'ListLen',0
.57:	DC.B	'ListMax',0
.58:	DC.B	'Even',0
.59:	DC.B	'Odd',0
.60:	DC.B	'Eval',0
.61:	DC.B	'ForAll',0
.62:	DC.B	'Exists',0
.63:	DC.B	'MapList',0
.64:	DC.B	'Abs',0
.65:	DC.B	'Shl',0
.66:	DC.B	'Shr',0
.67:	DC.B	'Box',0
.68:	DC.B	'Dispose',0
.69:	DC.B	'DisposeLink',0
.70:	DC.B	'Link',0
.71:	DC.B	'Next',0
.72:	DC.B	'Forward',0
.73:	DC.B	'SetStr',0
.74:	DC.B	'SetList',0
.75:	DC.B	'WaitIMessage',0
.76:	DC.B	'MsgCode',0
.77:	DC.B	'MsgQualifier',0
.78:	DC.B	'MsgIaddr',0
.79:	DC.B	'Rnd',0
.80:	DC.B	'RndQ',0
.81:	DC.B	'Mod',0
.82:	DC.B	'Eor',0
.83:	DC.B	'Raise',0
.84:	DC.B	'ListItem',0
.85:	DC.B	'NewR',0
.86:	DC.B	'Sign',0
.87:	DC.B	'PrintF',0
.88:	DC.B	'WaitLeftMouse',0
.89:	DC.B	'LeftMouse',0
.90:	DC.B	'SetStdIn',0
.91:	DC.B	'Throw',0
.92:	DC.B	'ReThrow',0
.93:	DC.B	'SelectList',0
.94:	DC.B	'SetColour',0
.95:	DC.B	'NewM',0
.96:	DC.B	'Bounds',0
.97:	DC.B	'RealF',0
.98:	DC.B	'RealVal',0
.99:	DC.B	'Fabs',0
.100:	DC.B	'Ffloor',0
.101:	DC.B	'Fceil',0
.102:	DC.B	'Fsin',0
.103:	DC.B	'Fcos',0
.104:	DC.B	'Ftan',0
.105:	DC.B	'Fexp',0
.106:	DC.B	'Flog',0
.107:	DC.B	'Fpow',0
.108:	DC.B	'Fsqrt',0
.109:	DC.B	'Flog10',0
.110:	DC.B	'FastDispose',0
.111:	DC.B	'FastNew',0
.112:	DC.B	'Min',0
.113:	DC.B	'Max',0
.114:	DC.B	'OstrCmp',0
.115:	DC.B	'AstrCopy',0
.116:	DC.B	'Cell',0
.117:	DC.B	'FreeCells',0
.118:	DC.B	'SetChunkSize',0
.119:	DC.B	'Car',0
.120:	DC.B	'Cdr',0
.121:	DC.B	'_Cons',0
.122:	DC.B	'FastDisposeList',0
.123:	DC.B	'Fatan',0
.124:	DC.B	'Fsincos',0
.125:	DC.B	'Fsinh',0
.126:	DC.B	'Fcosh',0
.127:	DC.B	'Ftanh',0
.128:	DC.B	'Ftieee',0
.129:	DC.B	'Ffieee',0
.130:	DC.B	'Fasin',0
.131:	DC.B	'Facos',0
	EVEN


; NOTE: ALL THIS CODE SAVES D3-D7/A4/A5/A7 BEFORE THRASHING

      I_WRITEF:
	TST.L	-8(A4)			;STDIO
	BEQ	.2
.3:	LEA	8(A7),A1
	MOVE.L	4(A7),D0
	MOVE.L	8(A7,D0.L),A0
	LEA     .1(PC),A2
	MOVE.L  4.W,A6
	MOVE.L  -64(A4),A3
	MOVE.L  A3,D2
	JSR     -522(A6)
	MOVE.L  -8(A4),D1
	MOVE.L  D2,A0
.5:	TST.B	(A0)+
	BNE	.5
	SUB.L	D2,A0
	MOVE.L	D3,A3			; BACKUP
	MOVE.L	A0,D3
	SUBQ.L	#1,D3
	MOVE.L  -44(A4),A6
	JSR     -48(A6)
	MOVE.L	D3,D0
	MOVE.L	A3,D3
	RTS
.1:	MOVE.B  D0,(A3)+		; RDF DUMP
	RTS
.2:	LEA	.4(PC),A0
	MOVE.L	A0,D1			;OPEN CON
	MOVE.L	#1006,D2
	MOVE.L	-44(A4),A6
	JSR	-30(A6)
	MOVE.L	D0,-12(A4)
	MOVE.L	D0,-8(A4)
	TST.L	D0
	BNE.S	.3
	MOVEQ	#20,D0
	MOVE.L	D0,-28(A4)
	MOVE.L	-24(A4),A0
	JMP	(A0)
.4:	DC.B	"CON:0/11/640/80/Output",0
	EVEN

      I_MUL:
	MOVE.L	D3,A3
	MOVE.L	4(A7),D1
	MOVE.L	8(A7),D0
	MOVE.L  D0,D2
	MOVE.L  D0,D3
	MULU    D1,D0
	SWAP    D3
	MULU    D1,D3
	SWAP    D3
	CLR.W   D3
	ADD.L   D3,D0
	SWAP    D1
	MULU    D1,D2
	SWAP    D2
	CLR.W   D2
	ADD.L   D2,D0
	MOVE.L	A3,D3
	RTS

      I_DIV:
;	MOVE.L	D3,A3
;	MOVE.L	8(A7),D1
;	MOVE.L	4(A7),D0
;	MOVEQ   #32,D3
;	MOVEQ   #0,D2
;.1:	SUB.L   D0,D2
;	BCC.B   .2
;	ADD.L   D0,D2
;.2:	ROXL.L  #1,D1
;	ROXL.L  #1,D2
;	DBF     D3,.1
;	NOT.L   D1
;	MOVE.L	D1,D0
;	MOVE.L	A3,D3
;	RTS


; maxon:

MOVE.L	8(A7),D0
MOVE.L	4(A7),D1

L6:      tst.l    d0
         bmi.s    L8
         tst.l    d1
         bpl.s    L9
         neg.l    d1
L7:      bsr.s    L9
         neg.l    d0
         rts      

L8:      neg.l    d0
         tst.l    d1
         bpl.s    L7
         neg.l    d1
L9:      swap     d1
         tst.w    d1
         bne.s    L10
         move.l   d3,-(a7)
         swap     d1
         move.w   d1,d3
         move.w   d0,d2
         clr.w    d0
         swap     d0
         divu     d3,d0
         move.l   d0,d1
         swap     d0
         move.w   d2,d1
         divu     d3,d1
         move.w   d1,d0
         clr.w    d1
         swap     d1
         move.l   (a7)+,d3
         rts      

L10:     swap     d1
E11:     movem.l  d3-d4,-(a7)
         moveq    #$1f,d2
         moveq    #$00,d3
         moveq    #$00,d4
L12:     asl.l    #$1,d3
         asl.l    #$1,d0
         roxl.l   #$1,d4
         cmp.l    d1,d4
         bcs.s    L13
         sub.l    d1,d4
         addq.l   #$1,d3
L13:     dbf      d2,L12
         move.l   d4,d1
         move.l   d3,d0
         movem.l  (a7)+,d3-d4
         rts      


      I_OPENW:
	LEA	.1(PC),A0
	MOVE.L	4(A7),48(A0)
	MOVE.L	8(A7),18(A0)
	MOVE.W	14(A7),46(A0)
	MOVE.L	16(A7),30(A0)
	MOVE.L	20(A7),26(A0)
	MOVE.L	24(A7),D0
	MOVEQ	#18,D1
	BSET	D1,D0
	MOVE.L	D0,14(A0)
	MOVE.L	28(A7),10(A0)
	MOVE.W	34(A7),6(A0)
	MOVE.W	38(A7),4(A0)
	MOVE.W	42(A7),2(A0)
	MOVE.W	46(A7),(A0)
	MOVE.L	-48(A4),A6
	JSR	-$CC(A6)
	MOVE.L	D0,A0
	MOVE.L	A0,D0
	BEQ.S	.2
	MOVE.L	50(A0),D1
	MOVE.L	D1,-16(A4)
.2:	RTS
.1:	DC.W	0,0,0,0,-1
	DC.L	0,0,0,0,0,0,0
	DC.W	80,25,-1,-1,0,0,0

      I_OPENS:
	LEA	.1(PC),A0
	MOVE.L	4(A7),32(A0)
	MOVE.L	8(A7),20(A0)
	MOVE.W	14(A7),12(A0)
	MOVE.W	18(A7),8(A0)
	MOVE.W	22(A7),6(A0)
	MOVE.W	26(A7),4(A0)
	MOVE.L	-48(A4),A6
	JSR	-198(A6)
	MOVE.L	D0,D1
	BEQ.S	.2
	ADD.L	#84,D1
	MOVE.L	D1,-16(A4)
.2:	RTS
.1:	DC.W	0,0,640,256,1,$0001,$8000,$100F
	DC.L	0,0,0,0,0

      I_MOUSE:
	MOVEQ	#0,D0
	BTST	#6,$BFE001
	BNE.S	.1
	MOVEQ	#1,D0
.1:	BTST	#10,$DFF016
	BNE.S	.2
	BSET	#1,D0
.2:	BTST	#8,$DFF016
	BNE.S	.3
	BSET	#2,D0
.3:	RTS

      I_PLOT:
	MOVE.L	-16(A4),A1
	MOVE.L	A1,D0
	BEQ.S	.1
	MOVE.L	-52(A4),A6
	MOVE.L	4(A7),D0
	JSR	-342(A6)
	MOVE.L	-16(A4),A1
	MOVE.L	12(A7),D0
	MOVE.L	8(A7),D1
	JSR	-324(A6)	
.1:	RTS

      I_LINE:
	MOVE.L	-16(A4),A1
	MOVE.L	A1,D0
	BEQ.S	.1
	MOVE.L	-52(A4),A6
	MOVE.L	4(A7),D0
	JSR	-342(A6)
	MOVE.L	-16(A4),A1
	MOVE.L	12(A7),D0
	MOVE.L	8(A7),D1
	JSR	-240(A6)	
	MOVE.L	-16(A4),A1
	MOVE.L	20(A7),D0
	MOVE.L	16(A7),D1
	JSR	-246(A6)	
.1:	RTS

      I_TEXTF:
	MOVE.L	4(A7),D0
	MOVE.L	8(A7,D0.L),A0
	LEA	8(A7),A1
	LEA     .3(PC),A2
	MOVE.L  4.W,A6
	;MOVE.L  276(A6),A3
	;MOVE.L  58(A3),A3
	MOVE.L  -64(A4),A3		; BETTER!
	MOVE.L  A3,D2
	JSR     -522(A6)
	MOVE.L	-16(A4),A1
	MOVE.L	A1,D0
	BEQ.S	.1
	MOVE.L	-52(A4),A6
	MOVE.L	4(A7),D0
	MOVE.L	12(A7,D0.L),D1
	MOVE.L	16(A7,D0.L),D0
	JSR	-240(A6)	
	MOVE.L	-16(A4),A1
	MOVE.L	D2,A0
	MOVE.L	A0,A2
.2:	TST.B	(A2)+
	BNE.S	.2
	MOVE.L	A2,D0
	SUB.L	A0,D0
	SUBQ.L	#1,D0
	MOVE.L	D0,D2
	JSR	-60(A6)
	MOVE.L	D2,D0
.1:	RTS
.3:	MOVE.B  D0,(A3)+		;RDF DUMP
	RTS

      I_COLOR:
	MOVE.L	-16(A4),A1
	MOVE.L	A1,D0
	BEQ.S	.1
	MOVE.L	-52(A4),A6
	MOVE.L	8(A7),D0
	JSR	-342(A6)
	MOVE.L	-16(A4),A1
	MOVE.L	4(A7),D0
	JSR	-348(A6)
.1:	RTS


      I_SETRAST:
	MOVE.L	-16(A4),D0
	MOVE.L	4(A7),D1
	BEQ.S	.1
	MOVE.L	D1,-16(A4)
.1:	RTS

      I_SETOUT:
	MOVE.L	-8(A4),D0
	MOVE.L	4(A7),D1
	BEQ.S	.1
	MOVE.L	D1,-8(A4)
.1:	RTS

      I_LONG:
	MOVE.L	4(A7),A0
	MOVE.L	(A0),D0
	RTS

      I_INT:
	MOVE.L	4(A7),A0
	MOVEQ	#0,D0
	MOVE.W	(A0),D0
	RTS

      I_CHAR:
	MOVE.L	4(A7),A0
	MOVEQ	#0,D0
	MOVE.B	(A0),D0
	RTS

      I_PUTLONG:
	MOVE.L	8(A7),A0
	MOVE.L	4(A7),(A0)
	RTS

      I_PUTINT:
	MOVE.L	8(A7),A0
	MOVE.W	6(A7),(A0)
	RTS

      I_PUTCHAR:
	MOVE.L	8(A7),A0
	MOVE.B	7(A7),(A0)
	RTS

      I_NEW:
	MOVE.L	4(A7),D0
	MOVE.L	#$10000,D1
	ADDQ.L	#8,D0
	MOVE.L	D0,D2
	MOVE.L	4.W,A6
	JSR	-198(A6)
	TST.L	D0
	BEQ.S	.1
	MOVE.L	D0,A0
	MOVE.L	-20(A4),(A0)
	MOVE.L	D2,4(A0)
	MOVE.L	D0,-20(A4)
	ADDQ.L	#8,D0
.1:	RTS

      I_EXIT:
	MOVE.L	4(A7),-28(A4)
	MOVE.L	-24(A4),A0
	JMP	(A0)

      I_CLOSEW:
	CLR.L	-16(A4)
	MOVE.L	4(A7),A0
	MOVE.L	A0,D0
	BEQ.S	.1
	MOVE.L	-48(A4),A6
	JSR	-72(A6)
.1:	RTS

      I_CLOSES:
	CLR.L	-16(A4)
	MOVE.L	4(A7),A0
	MOVE.L	A0,D0
	BEQ.S	.1
	MOVE.L	-48(A4),A6
	JSR	-66(A6)
.1:	RTS

      I_AND:
	MOVE.L	8(A7),D0
	AND.L	4(A7),D0
	RTS

      I_OR:
	MOVE.L	8(A7),D0
	OR.L	4(A7),D0
	RTS

      I_NOT:
	MOVE.L	4(A7),D0
	NOT.L	D0
	RTS

      I_BOOLGAD:
	MOVE.L	32(A7),D2
	MOVE.L	D2,A1			; A1,D2=GADGET
	MOVE.L	A1,A2
	MOVEQ	#28,D0
.L:	CLR.L	(A2)+
	DBRA	D0,.L
	LEA	44(A1),A0		; A0   =BORDER1
	LEA	16(A0),A2		; A2   =INTUITEXT
	LEA	20(A2),A3		; A3   =20 empty bytes
	MOVE.L	24(A7),40(A1)		; --> INIT GADGET
	MOVE.W	18(A7),4(A1)
	MOVE.W	14(A7),6(A1)
	MOVE.W	10(A7),D0
	MOVE.W	D0,8(A1)
	MOVE.W	#12,10(A1)		; D0,D1 = W,H
	SUBQ.W	#1,D0
	MOVEQ	#11,D1
	MOVE.W	#$0,12(A1)		; FLAGS
	MOVE.W	#$1,14(A1)		; ACTIVATEFLAGS
	MOVE.W	#$1,16(A1)		; TYPEFLAGS
	BTST	#0,23(A7)
	BEQ.S	.5
	BSET	#0,14(A1)
.5:	BTST	#1,23(A7)
	BEQ.S	.6
	BSET	#7,13(A1)
.6:	MOVE.L	A2,26(A1)
	MOVE.L	A0,18(A1)
	MOVE.W	D0,8(A3)		; --> INIT VECTORZ
	MOVE.W	D0,12(A3)
	MOVE.W	D1,6(A3)
	MOVE.W	D1,10(A3)
	MOVE.L	4(A7),D0
	MOVE.L	D0,12(A2)		; --> INIT INTUITEXT
	MOVE.L	#$01000100,(A2)
	MOVE.W	#$2,6(A2)
	MOVE.L	D0,A6
.7:	TST.B	(A6)+
	BNE.S	.7
	SUB.L	D0,A6
	SUBQ.L	#1,A6
	MOVE.L	8(A7),D1
	MOVE.L	A6,D0
	LSL.W	#3,D0
	SUB.L	D0,D1
	LSR.W	#1,D1
	MOVE.W	D1,4(A2)
	MOVEQ	#0,D0
	MOVE.L	D0,(A0)			; --> INIT BORDER
	MOVE.L	#$01000005,4(A0)
	MOVE.L	A3,8(A0)
	LEA	.3(PC),A3		; --> TOPAZ
	LEA	8(A3),A0
	MOVE.L	A0,(A3)
	MOVE.L	A3,8(A2)
	MOVE.L	28(A7),A0		; --> LINK GLIST
	MOVE.L	A0,D0
	BEQ.S	.2
	MOVE.L	(A0),D0			; NEXTNODE OF PRED
	MOVE.L	A1,(A0)			; HANG ONTO PRED
	MOVE.L	D0,(A1)			; CONNECT NEXTNODE
.2:	MOVE.L	D2,D0
	ADD.L	#120,D0
	RTS
.3:	DC.L	0,$80060
.4:	DC.B	"topaz.font",0,0

      I_SETTOPAZ:
	MOVE.L	-52(A4),A6
	LEA	.2(PC),A0
	LEA	.3(PC),A1
	MOVE.L	A1,(A0)
	MOVE.W	6(A7),4(A0)
	JSR	-72(A6)			; OPENFONT
	TST.L	D0
	BEQ.S	.1
	MOVE.L	D0,A0
	MOVE.L	-16(A4),A1
	MOVE.L	A1,D0
	BEQ.S	.1
	JSR	-66(A6)			; SETFONT
.1:	RTS
.2:	DC.L	0,$80060
.3:	DC.B	"topaz.font",0,0

      I_STRCMP:
	MOVEQ	#0,D0
	MOVE.W	6(A7),D0		; LEN
	MOVE.L	8(A7),A1		; STR1
	MOVE.L	12(A7),A0		; STR2
	ADDQ.L	#1,D0
.1:	SUBQ.L	#1,D0
	B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OVE.L	16(A7),A0		; ESTR
	MOVE.L	A0,A2
	MOVEQ	#0,D1
	MOVE.W	-4(A0),D1
	CMP.L	D0,D1
	BPL.S	.1
	MOVE.L	D1,D0
.1:	MOVE.L	D0,D2
	SUBQ.L	#1,D0			; D0=COPYLEN
.2:	MOVE.B	(A1)+,(A0)+
	BEQ.S	.3
	DBRA	D0,.2
	MOVE.B	#0,(A0)+
.3:	ADDQ.W	#1,D0
	SUB.W	D0,D2
	MOVE.W	D2,-2(A2)
	MOVE.L	A2,D0
	RTS

      I_STRINGF:
	MOVE.L	4(A7),D0
	MOVE.L	8(A7,D0.L),A0		; formatstr
	LEA	8(A7),A1		; argarray
	LEA     .1(PC),A2		; putfun
	MOVE.L  4.W,A6
	;MOVE.L  276(A6),A3
	;MOVE.L  58(A3),A3
	MOVE.L  -64(A4),A3		; BETTER!
	MOVE.L  A3,D2			; both bottom OWN stack
	JSR     -522(A6)
	MOVE.L	D2,A1
	MOVE.L	4(A7),D0
	MOVE.L	12(A7,D0.L),A0		; ESTR
	MOVE.L	A0,A2
	MOVEQ	#0,D0
	MOVE.W	-4(A0),D0
	MOVE.L	D0,D2
	SUBQ.L	#1,D0			; D0=COPYLEN
.2:	MOVE.B	(A1)+,(A0)+
	BEQ.S	.3
	DBRA	D0,.2
	MOVE.B	#0,(A0)+
.3:	ADDQ.W	#1,D0
	SUB.W	D0,D2
	MOVE.W	D2,-2(A2)
	MOVE.L	D2,D1
	EXT.L	D1
	MOVE.L	A2,D0
	RTS
.1:	MOVE.B  D0,(A3)+		;RDF DUMP
	RTS

      I_VAL:
	MOVEM.L	D3-D6,-(A7)		; 16 OFF STACK
	MOVE.L	24(A7),A2
	MOVE.L	20(A7),D5		; D5=READLENADR
	MOVEQ	#0,D6			; D6=MINUSFLAG
.5:	MOVE.B	(A2)+,D0		; reg d0,a2
	BEQ	VALER
	CMP.B	#33,D0
	BMI.S	.5
	SUBQ.L	#1,A2
	CMP.B	#"-",(A2)
	BNE.S	.NM
	ADD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#-1,D0
	RTS

      I_ODD:
	BTST	#0,7(A7)
	BNE.S	.1
	MOVEQ	#0,D0
	RTS
.1:	MOVEQ	#-1,D0
	RTS

      I_EVAL:
	MOVE.L	4(A7),A0
	JSR	(A0)			; ACTIONNES DANGEREUSES !!!
	RTS

      I_FORALL:
	MOVE.L	4(A7),A0		; code
	MOVE.L	8(A7),A1		; list
	MOVE.L	12(A7),A2		; VAR
	MOVEQ	#-1,D0			; TRUTH VALUE ->D1
	MOVE.W	-2(A1),D2		; COUNT
	BEQ.S	.1
	SUBQ.L	#1,D2
	MOVE.L	D0,D1
.L:	MOVE.L	(A1)+,(A2)
	MOVEM.L	D1-D2/A0-A2,-(A7)
	JSR	(A0)
	MOVEM.L	(A7)+,D1-D2/A0-A2
	TST.L	D0
	BEQ.S	.2
	DBRA	D2,.L
	BRA.S	.3
.2:	MOVEQ	#0,D1
	DBRA	D2,.L
.3:	MOVE.L	D1,D0
.1:	RTS

      I_EXISTS:
	MOVE.L	4(A7),A0		; code
	MOVE.L	8(A7),A1		; list
	MOVE.L	12(A7),A2		; VAR
	MOVEQ	#0,D0			; TRUTH VALUE ->D1
	MOVE.W	-2(A1),D2		; COUNT
	BEQ.S	.1
	SUBQ.L	#1,D2
	MOVE.L	D0,D1
.L:	MOVE.L	(A1)+,(A2)
	MOVEM.L	D1-D2/A0-A2,-(A7)
	JSR	(A0)
	MOVEM.L	(A7)+,D1-D2/A0-A2
	TST.L	D0
	BNE.S	.2
	DBRA	D2,.L
	BRA.S	.3
.2:	MOVEQ	#-1,D1
	DBRA	D2,.L
.3:	MOVE.L	D1,D0
.1:	RTS

      I_MAPLIST:
	MOVE.L	4(A7),A0		; code
	MOVE.L	8(A7),A3		; DESTLIST
	MOVE.L	12(A7),A1		; SRClist
	MOVE.L	16(A7),A2		; VAR
	MOVE.L	A3,-(A7)
	MOVE.W	-4(A3),D0
	CMP.W	-2(A1),D0
	BMI.S	.1
	MOVE.W	-2(A1),-2(A3)
	MOVE.W	-2(A1),D2		; COUNT
	BEQ.S	.1
	SUBQ.L	#1,D2
;	MOVE.L	D0,D1
.L:	MOVE.L	(A1)+,(A2)
	MOVEM.L	D2/A0-A3,-(A7)
	JSR	(A0)
	MOVEM.L	(A7)+,D2/A0-A3
	MOVE.L	D0,(A3)+
	DBRA	D2,.L
.1:	MOVE.L	(A7)+,D0
	RTS

      I_ABS:
	MOVE.L	4(A7),D0
	BPL.S	.1
	NEG.L	D0
.1:	RTS

      I_SHL:
	MOVE.L	8(A7),D0
	MOVE.L	4(A7),D1
	ASL.L	D1,D0
	RTS

      I_SHR:
	MOVE.L	8(A7),D0
	MOVE.L	4(A7),D1
	ASR.L	D1,D0
	RTS

      I_BOX:
	MOVE.L	D3,A3
	MOVE.L	-16(A4),A1		; rast
	MOVE.L	A1,D0
	BEQ.S	.1
	MOVE.L	-52(A4),A6
	MOVE.L	4(A7),D0
	JSR	-342(A6)		; setapen
	MOVE.L	-16(A4),A1
	MOVE.L	20(A7),D0
	MOVE.L	16(A7),D1
	MOVE.L	12(A7),D2
	MOVE.L	8(A7),D3
	JSR	-306(A6)		; rectfill
.1:	MOVE.L	A3,D3
	RTS

      I_DISP:
	MOVE.L	4(A7),D0
	BEQ.S	.1
	SUBQ.L	#8,D0
	LEA	-20(A4),A1
.L:	MOVE.L	(A1),D1
	BEQ.S	.1
	MOVE.L	A1,A2			; ADR TO LINK BACK TO
	MOVE.L	D1,A1
	CMP.L	D1,D0
	BNE.S	.L
	MOVE.L	4(A1),D0		; MEMSIZE
	MOVE.L	(A1),(A2)		; LINK BACK
	MOVE.L	4.W,A6
	JSR	-210(A6)
.1:	RTS

      I_DISPL:
	MOVE.L	4(A7),A3		; A3=STRING
.ML:	MOVE.L	A3,D0
	BEQ.S	.1
	MOVE.L	-8(A3),A3
	SUBQ.L	#8,D0
	SUBQ.L	#8,D0			; D0=MEM
	LEA	-20(A4),A1
.L:	MOVE.L	(A1),D1
	BEQ.S	.ML
	MOVE.L	A1,A2			; A2=ADR TO LINK BACK TO
	MOVE.L	D1,A1
	CMP.L	D1,D0
	BNE.S	.L
	MOVE.L	4(A1),D0		; MEMSIZE
	MOVE.L	(A1),(A2)		; LINK BACK
	MOVE.L	4.W,A6
	JSR	-210(A6)
	BRA.S	.ML
.1:	RTS

      I_LINK:
	MOVE.L	8(A7),A0
	MOVE.L	A0,D0
	BEQ.S	.1
	MOVE.L	4(A7),-8(A0)
.1:	RTS

      I_NEXT:
	MOVE.L	4(A7),D0
	BEQ.S	.1
	MOVE.L	D0,A0
	MOVE.L	-8(A0),D0
.1:	RTS

      I_FORWARD:
	LEA	8(A7),A0		; LIST
	MOVE.L	4(A7),D1		; NUM
	ADDQ.L	#1,D1
.L:	MOVE.L	(A0),D0
	BEQ.S	.1
	MOVE.L	D0,A0
	SUBQ.L	#8,A0
	SUBQ.L	#1,D1
	BNE.S	.L
.1:	RTS

      I_SETSTR:
	MOVE.W	6(A7),D0
	MOVE.L	8(A7),A0
	CMP.W	-4(A0),D0
	BHI.S	.1
	MOVE.W	D0,-2(A0)
	MOVE.B	#0,0(A0,D0.W)
.1:	RTS

      I_SETLIST:
	MOVE.W	6(A7),D0
	MOVE.L	8(A7),A0
	CMP.W	-4(A0),D0
	BHI.S	.1
	MOVE.W	D0,-2(A0)
.1:	RTS

      I_WAITMSG:
	MOVE.L	4(A7),A0
	MOVE.L	$56(A0),A2		; A2=PORT
	MOVE.L	4.W,A6
	MOVE.L	A2,A0
	JSR	-372(A6)		; GETMSG
	MOVE.L	D0,A3			; A3=MES
	TST.L	D0
	BNE.S	.1
.2:	MOVE.L	A2,A0
	JSR	-384(A6)		; WAITPORT
	MOVE.L	A2,A0
	JSR	-372(A6)		; GETMSG
	MOVE.L	D0,A3
	TST.L	D0
	BEQ.S	.2
.1:	MOVE.L	28(A3),-72(A4)
	MOVE.L	24(A3),-68(A4)
	MOVE.L	20(A3),D2
	MOVE.L	A3,A1
	JSR	-378(A6)		; REPLY
	MOVE.L	D2,D0			; CLASS
	RTS

      I_MSGCODE:
	MOVEQ	#0,D0
	MOVE.W	-68(A4),D0
	RTS

      I_MSGQUAL:
	MOVEQ	#0,D0
	MOVE.W	-66(A4),D0
	RTS

      I_MSGIADR:
	MOVE.L	-72(A4),D0
	RTS

      I_RND:				; rand16:=RangeRand(max16)
	MOVE.L	4(A7),D2		; 6(a7) was E(a7) ????
	BMI.S	.SET
	MOVE.W	D2,D1			; RangeRand(1000) --> 0..999
	SUBQ.W	#$1,D1
	MOVE.L	.S(PC),D0		; randnr:=Rnd(max)
.2:	ADD.L	D0,D0
	BHI.S	.3
	EORI.L	#$1D872B41,D0
.3:	LSR.W	#$1,D1
	BNE.S	.2
	LEA	.S(PC),A0
	MOVE.L	D0,(A0)
	TST.W	D2
	BNE.S	.4
	SWAP	D0
	BRA.S	.5
.4:	MULU	D2,D0
.5:	CLR.W	D0
	SWAP	D0
	RTS
.SET:	NEG.L	D2
	LEA	.S(PC),A0
	MOVE.L	D2,(A0)
	RTS
.S:	DC.L	0

      I_RNDQ:				;	seed32:=FastRand(seed32)
	MOVE.L	$0004(A7),D0
	ADD.L	D0,D0			;	seed:=RndQ(seed)
	BHI.S	.1
	EORI.L	#$1D872B41,D0
.1:	RTS      

      I_MOD:
	MOVE.L	8(A7),D0
	DIVS	6(A7),D0
	MOVE.L	D0,D1
	SWAP	D0
	EXT.L	D0
	EXT.L	D1
	RTS

      I_EOR:
	MOVE.L	4(A7),D0
	MOVE.L	8(A7),D1
	EOR.L	D1,D0
	RTS

; see also NEWR(), Throw() and ReThrow()

      I_CAUSE:
	MOVE.L	4(A7),-84(A4)		; FILL "EXCEPTION" VAR
	MOVE.L	-76(A4),D0
	BEQ.S	.1
	MOVE.L	D0,A0			; A0=CODE TO JUMP TO
	MOVE.L	-80(A4),A7		; STACK BACK
	MOVE.L	-88(A4),A5
	MOVE.L	(A7)+,-88(A4)		; (A5)
	MOVE.L	(A7)+,-76(A4)		; PUT PREVIOUS HANDLER BACK (CODE)
	MOVE.L	(A7)+,-80(A4)		; (STACK)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(A3)+		; RDF DUMP
	RTS
.2:	LEA	.4(PC),A0
	MOVE.L	A0,D1			; OPEN CON
	MOVE.L	#1006,D2
	MOVE.L	-44(A4),A6
	JSR	-30(A6)
	MOVE.L	D0,-12(A4)
	MOVE.L	D0,-8(A4)
	TST.L	D0
	BNE.S	.3
	MOVEQ	#20,D0
	MOVE.L	D0,-28(A4)
	MOVE.L	-24(A4),A0
	JMP	(A0)
.4:	DC.B	"CON:0/11/640/80/Output",0
	EVEN

      I_WAITLEFTMOUSE:
	MOVE.L	4(A7),A3		; A3=WIN
	MOVE.L	82(A3),D0
	BTST	#3,D0
	BNE.S	.3			; CHECK IDCMP CONTAINS MOUSE
	BSET	#3,D0
	MOVE.L	-48(A4),A6
	MOVE.L	A3,A0
	JSR	-150(A6)		; MODIFYIDCMP
.3:	MOVE.L	$56(A3),A2		; A2=PORT
	MOVE.L	4.W,A6
	MOVE.L	A2,A0
	JSR	-372(A6)		; GETMSG
	MOVE.L	D0,A3			; A3=MES
	TST.L	D0
	BNE.S	.1
.2:	MOVE.L	A2,A0
	JSR	-384(A6)		; WAITPORT
	MOVE.L	A2,A0
	JSR	-372(A6)		; GETMSG
	MOVE.L	D0,A3
	TST.L	D0
	BEQ.S	.2
.1:	MOVE.L	A3,A1			; MES
	MOVE.L	20(A1),D2
	JSR	-378(A6)		; REPLY
	MOVE.L	D2,D0			; CLASS
	BTST	#3,D0
	BEQ.S	.2
	RTS

      I_LEFTMOUSE:
	MOVE.L	4(A7),A3		; A3=WIN
	MOVE.L	82(A3),D0
	BTST	#3,D0
	BNE.S	.3			; CHECK IDCMP CONTAINS MOUSE
	BSET	#3,D0
	MOVE.L	-48(A4),A6
	MOVE.L	A3,A0
	JSR	-150(A6)		; MODIFYIDCMP
.3:	MOVE.L	$56(A3),A2		; A2=PORT
	MOVE.L	4.W,A6
	MOVE.L	A2,A0
	JSR	-372(A6)		; GETMSG
	TST.L	D0
	BNE.S	.1
	RTS
.1:	MOVE.L	D0,A1			; MES
	MOVE.L	20(A1),D2
	JSR	-378(A6)		; REPLY
	MOVE.L	D2,D0			; CLASS
	BTST	#3,D0
	BEQ.S	.2
	MOVEQ	#-1,D0
	RTS
.2:	MOVEQ	#0,D0
	RTS

      I_SETIN:
	MOVE.L	-8(A4),D0
	MOVE.L	4(A7),D1
	BEQ.S	.1
	MOVE.L	D1,-92(A4)
.1:	RTS

      I_THROW:
	MOVE.L	8(A7),-84(A4)		; FILL "EXCEPTION" VAR
	MOVE.L	4(A7),-96(A4)		; FILL "EXCEPTIONINFO" VAR
	MOVE.L	-76(A4),D0
	BEQ.S	.1
	MOVE.L	D0,A0			; A0=CODE TO JUMP TO
	MOVE.L	-80(A4),A7		; STACK BACK
	MOVE.L	-88(A4),A5
	MOVE.L	(A7)+,-88(A4)		; (A5)
	MOVE.L	(A7)+,-76(A4)		; PUT PREVIOUS HANDLER BACK (CODE)
	MOVE.L	(A7)+,-80(A4)		; (STACK)
	JMP	(A0)
.1:	MOVE.L	-24(A4),A0		; PERFORM CLEANUP(0)
	JMP	(A0)
	RTS

      I_RETHROW:
	TST.L	-84(A4)			; NO RETHROW() IF EXC=0
	BEQ.S	.2
	MOVE.L	-76(A4),D0
	BEQ.S	.1
	MOVE.L	D0,A0			; A0=CODE TO JUMP TO
	MOVE.L	-80(A4),A7		; STACK BACK
	MOVE.L	-88(A4),A5
	MOVE.L	(A7)+,-88(A4)		; (A5)
	MOVE.L	(A7)+,-76(A4)		; PUT PREVIOUS HANDLER BACK (CODE)
	MOVE.L	(A7)+,-80(A4)		; (STACK)
	JMP	(A0)
.1:	MOVE.L	-24(A4),A0		; PERFORM CLEANUP(0)
	JMP	(A0)
.2:	RTS

      I_SELECTLIST:
	MOVE.L	4(A7),A0		; code
	MOVE.L	8(A7),A3		; DESTLIST
	MOVE.L	A3,A6
	MOVE.L	12(A7),A1		; SRClist
	MOVE.L	16(A7),A2		; VAR
	MOVE.W	-2(A1),D2		; COUNT
	BEQ.S	.1
	SUBQ.L	#1,D2
.L:	M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5ac
	DC.L	$350637bd,$3356bf95,$31abcc77
.TAB:	DC.L	$41200000,$42c80000,$447a0000	; same here
	DC.L	$461c4000,$47c35000,$49742400
	DC.L	$4b189680,$4cbebc20	; ,$4cbebc20
.ADD:	MOVE.L	D1,-(A7)
	JSR	-90(A6)			; FLOOR
	JSR	-30(A6)			; FIX, D0=INT
	MOVE.L	(A7)+,D1
	LEA	-32(A7),A7
	MOVE.L	A7,A3
	LEA	.PROC(PC),A2
	LEA	16(A3),A0
	MOVE.B	#"%",(A0)+
	TST.L	D1
	BMI.S	.2
	MOVE.L	4+4+32(A7),D1
	ADD.W	#$30,D1
	MOVE.B	#"0",(A0)+
	MOVE.B	D1,(A0)+
	MOVE.B	#".",(A0)+
	MOVE.B	D1,(A0)+
.2:	MOVE.B	#"l",(A0)+
	MOVE.B	#"d",(A0)+
	CLR.B	(A0)+
	LEA	16(A3),A0
	LEA	28(A3),A1
	MOVE.L	D0,(A1)
	MOVE.L	4.W,A6
	JSR	-522(A6)
	MOVE.L	4+12+32(A7),A2		; A2=STRING
	MOVE.L	A7,A3
.L:	MOVE.B	(A3)+,D0
	BEQ.S	.O
	BSR.W	.ADDS
	BRA.S	.L
.O:	LEA	32(A7),A7
	RTS

      I_REALVAL:
	MOVE.L	D3,A3
	MOVE.L	4(A7),A0		; A0=STR
.L:	MOVE.B	(A0)+,D0
	CMP.B	#33,D0
	BMI.S	.L
	MOVEQ	#0,D1
	CMP.B	#"-",D0
	BNE.S	.NNEG
	MOVEQ	#-1,D1
	MOVE.B	(A0)+,D0
.NNEG:	MOVE.W	D1,A6			; A6=SIGN
	MOVEQ	#0,D2			; D2=DOTFLAG
	MOVEQ	#1,D1			; D1=DIVDOT
	MOVEQ	#0,D3			; D3=RESULT SOFAR
	SUB.L	A1,A1			; A1=COUNT
.L2:	CMP.B	#"9"+1,D0
	BPL.S	.D
	CMP.B	#".",D0
	BEQ.S	.DOT
	CMP.B	#"0",D0
	BMI.S	.D
	EXT.W	D0
	EXT.L	D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E.L	-60(A4),A6
	JSR	-84(A6)
	RTS

      I_FPOW:
	MOVE.L	4(A7),D0
	MOVE.L	8(A7),D1
	MOVE.L	-60(A4),A6
	JSR	-90(A6)
	RTS

      I_FSQRT:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-96(A6)
	RTS

      I_FLOG10:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-126(A6)
	RTS

      I_FASTDISPOSE:			; SEE ALSO: FASTDISPOSELIST!!!!!
	MOVE.L	8(A7),D0		; parms(ptr,size)
	BEQ.S	.oute
	MOVE.L	D0,A0
	MOVE.L	4(A7),D0
	CMP.L	#257,D0
	BPL.S	.free
	ADDQ.L	#3,D0
	AND.W	#%1111111100,D0
	LEA	GLOBOFFNEWTAB(A4),A1
	ADD.L	D0,A1
	MOVE.L	(A1),(A0)
	MOVE.L	A0,(A1)
.oute:	RTS
.free:	SUBQ.L	#8,A0
	LEA	-20(A4),A1
.loop:	MOVE.L	(A1),D1
	BEQ.S	.out
	MOVE.L	A1,A2			; ADR TO LINK BACK TO
	MOVE.L	D1,A1
	CMPA.L	D1,A0
	BNE.S	.loop
	MOVE.L	4(A1),D0		; MEMSIZE
	MOVE.L	(A1),(A2)		; LINK BACK
	MOVE.L	$4.W,A6
	JSR	-210(A6)		; FREEMEM
.out:	RTS

      I_FASTNEW:
	MOVE.L	4(A7),D0		; 1st arg = size 0..
	CMP.L	#257,D0
	BPL.S	.mem
	ADDQ.L	#3,D0
	AND.W	#%1111111100,D0
	BEQ.S	.outn
	MOVE.L	D0,A3
	LEA	GLOBOFFNEWTAB(A4),A0
	ADD.L	A3,A0
	MOVE.L	(A0),D0
	BEQ.S	.chop
	MOVE.L	D0,A1
	MOVE.L	(A1),(A0)
	MOVE.L	A3,D1
	LSR.W	#2,D1
	SUBQ.L	#1,D1
	MOVEQ	#0,D2
.clrl:	MOVE.L	D2,(A1)+
	DBRA	D1,.clrl
.outn:	RTS
.chop:	MOVE.L	CHO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TS
.4:	MOVEQ	#-1,D0
	RTS

      I_ASTRCOPY:
	MOVEQ	#0,D0
	MOVE.W	6(A7),D0
	BEQ.S	.x2
	MOVE.L	8(A7),A1
	MOVE.L	12(A7),A0
	ADDQ.L	#1,D0
.al:	SUBQ.L	#1,D0
	BEQ.S	.x
	MOVE.B	(A1)+,(A0)+
	BNE.S	.al
	BRA.S	.x2
.x:	CLR.B	-(A0)
.x2:	RTS


; Yet Another MileStone:
;
; Conservative Mark-Sweep Garbage-Collected Lisp-Cells in E
;
; speed of nrev500_10 test on 128k space (includes 1 collection):
;
; 4.5 x BinProLog, 15.5 x SBP, 26 x Gofer
;
; TODO:
; + stack checking?
; + chunk changable -> own chunksize var. only change if <>0
; + DBRA limit? -> now DBL. should be able to do >2meg
; + collect delegates? -> no.
; + request non-empty mem.
; + previous freelist is added ok now in new.
; + Cell() function
; - multiple args
; - special syntax + pattern matching
; - Root(x) etc.
; - 25% not ideal with small spaces and growing cell usage.


CELLSMEM	= -108
CELLSFREE	= -112
CHUNKSIZE	= -116
CHUNK		= 128*1024		; must be multiple of 256, >1024

; mem layout:
;
; OBJECT cellmem
;   next:PTR TO cellmem			; 0
;   end:PTR TO cellmem+SIZEOF cellmem	; 4
;   cells[n]:ARRAY OF cell		; 8
; ENDOBJECT
;   bits[n]:ARRAY OF BIT

      I_CELL:
	MOVE.L	4(A7),D0
	BEQ.S	.false			; NIL
	MOVE.L	D0,D1
	AND.W	#%111,D1
	BNE.S	.false			; not cell-aligned
	MOVE.L	CELLSMEM(A4),A0
.cloop:	CMP.L	A0,D0
	BMI.S	.cnext			; lower than bottom
	CMP.L	4(A0),D0
	BPL.S	.cnext			; higher than top
	MOVEQ	#-1,D0
	RTS
.cnext:	MOVE.L	(A0),A0
	MOVE.L	A0,D1
	BNE.S	.cloop
.false:	MOVEQ	#0,D0
	RTS

      I_FREECELLS:
	LEA	CELLSFREE(A4),A0
	MOVEQ	#0,D0
.ccl:	MOVE.L	(A0),D1
	BEQ.S	.cco
	ADDQ.L	#1,D0
	MOVE.L	D1,A0
	BRA.S	.ccl
.cco:	RTS

      I_SETCHUNKSIZE:
	TST.L	CHUNKSIZE(A4)
	BNE.S	.chd
	MOVE.L	4(A7),D0
	MOVEQ	#10,D1
	LSL.L	D1,D0
	MOVE.L	D0,CHUNKSIZE(A4)
.chd:	RTS

      I_CAR:
	MOVE.L	4(A7),A0
	MOVE.L	(A0),D0
	RTS

      I_CDR:
	MOVE.L	4(A7),A0
	MOVE.L	4(A0),D0
	RTS

      I_CONS:
	MOVE.L	CELLSFREE(A4),D0	; Yep, this is IT!
	BEQ.S	.gc
	MOVE.L	D0,A0
	MOVE.L	(A0),A2
	MOVE.L	12(A7),(A0)
	MOVE.L	8(A7),4(A0)
	MOVE.W	6(A7),D1
	BEQ.S	.1
	LSR.W	#2,D1
	SUBQ.W	#1,D1
	LEA	16(A7),A1
.2:	MOVE.L	A2,D2
	BEQ.S	.gc
	EXG	D0,D2
	MOVE.L	(A2),A3
	MOVE.L	D2,4(A2)
	MOVE.L	(A1)+,(A2)
	MOVE.L	A3,A2
	DBRA	D1,.2
.1:	MOVE.L	A2,CELLSFREE(A4)
	RTS

.gc:	CLR.L	CELLSFREE(A4)
	MOVE.L	CELLSMEM(A4),D0
	BEQ	.new
	MOVEM.L	D3-D7,-(A7)		; roots too
	MOVE.L	D0,D7			; D7=space
	MOVE.L	A7,A0			; A0=roots
.grab:	CMPA.L	A0,A4			; grab roots until A4
	BLE	.sweep
	MOVE.L	(A0)+,D0
	PEA	.grab(PC)
.trace:	BEQ.S	.ex			; NIL
	MOVE.L	D0,D1
	AND.W	#%111,D1
	BNE.S	.ex			; not cell-aligned
	MOVE.L	D7,A2
.tloop:	CMP.L	A2,D0
	BMI.S	.tnext			; lower than bottom
	CMP.L	4(A2),D0
	BPL.S	.tnext			; higher than top
	MOVE.L	D0,A1
	SUB.L	A2,D0
	LSR.L	#3,D0
	MOVE.L	D0,D1
	LSR.L	#3,D0
	MOVE.L	4(A2),A3		; mark the sucker
	BSET	D1,0(A3,D0.L)		; already marked? great!
	BNE.S	.ex
	MOVE.L	4(A1),-(A7)		; save cdr for later
	MOVE.L	A7,D0
	SUBQ.L	#8,D0
	CMP.L	-64(A4),D0
	BMI	.raises
	MOVE.L	(A1),D0			; go do car now
	BSR.S	.trace			; OOPS! stack!!!
	MOVE.L	(A7)+,D0
	BRA.S	.trace
.tnext:	MOVE.L	(A2),A2
	MOVE.L	A2,D1
	BNE.S	.tloop
.ex:	RTS

.sweep:	MOVEQ	#0,D0			; D0=num cells collected
	MOVE.L	CELLSFREE(A4),A6	; A6=freelist
.sl:	MOVE.L	D7,A0			; A0=space
	MOVE.L	4(A0),A1		; A1=endspace
	MOVE.L	(A0),D5			; D5=next
	MOVEQ	#0,D1			; D1=current bit
.sloop:	ADDQ.L	#8,A0
	ADDQ.L	#1,D1
	CMPA.L	A0,A1
	BEQ.S	.snext
	MOVE.L	D1,D2
	LSR.L	#3,D2
	BCLR	D1,0(A1,D2.L)
	BNE.S	.sloop
	ADDQ.L	#1,D0
	MOVE.L	A6,(A0)			; sweep the sucker!
	MOVE.L	A0,A6
	BRA.S	.sloop
.snext:	MOVE.L	D5,D7
	BNE.S	.sl
	MOVE.L	A6,CELLSFREE(A4)
	MOVEM.L	(A7)+,D3-D7
	MOVE.L	CHUNKSIZE(A4),D1
	LSR.L	#5,D1			; /4 = 25% must be empty
	CMP.L	D1,D0
	BMI.S	.new
	BRA	I_CONS

.new:	MOVE.L	CHUNKSIZE(A4),D0
	BNE.S	.cs
	MOVE.L	#CHUNK,D0
	MOVE.L	D0,CHUNKSIZE(A4)
.cs:	MOVE.L	D0,D1
	LSR.L	#6,D1			; markspace
	ADD.L	D1,D0
	BSR	.alloc
	MOVE.L	D0,A0
	MOVE.L	CELLSMEM(A4),(A0)	; previous cellspace
	ADD.L	CHUNKSIZE(A4),D0
	MOVE.L	D0,4(A0)		; end_of_cells
	MOVE.L	D0,A2			; markspace
	MOVE.L	A0,CELLSMEM(A4)
	MOVE.L	CHUNKSIZE(A4),D0	; now chop free cells
	LSR.L	#5,D0
	SUBQ.L	#2,D0			; numcells
	MOVE.L	CELLSFREE(A4),A1
	ADDQ.L	#8,A0
	MOVE.L	A1,(A0)
.chop:	LEA	8(A0),A1		; freelist in new cell
	MOVE.L	A0,(A1)			; loop unrolled!!!
	LEA	8(A1),A0		; 20 cycles per cell!!!
	MOVE.L	A1,(A0)			; 4 cells in one loop
	LEA	8(A0),A1
	MOVE.L	A0,(A1)
	LEA	8(A1),A0
	MOVE.L	A1,(A0)
	DBRA	D0,.chop
	SUB.L	#$10000,D0
	BCC.S	.chop
	MOVE.L	A0,CELLSFREE(A4)
	MOVE.L	CHUNKSIZE(A4),D0	; now clear mark space
	LSR.L	#8,D0
	SUBQ.L	#1,D0
	MOVEQ	#0,D1
.clmark:MOVE.L	D1,(A2)+
	DBRA	D0,.clmark
	SUB.L	#$10000,D0
	BCC.S	.clmark
	BRA	I_CONS			; try again!

.alloc:	ADDQ.L	#8,D0
	MOVE.L	D0,D2			; COPY OF New()
	MOVEQ	#0,D1			; MOVE.L	#$10000,D1
	MOVE.L	$4.W,A6
	JSR	-198(A6)
	TST.L	D0
	BEQ.S	.raise
	MOVE.L	D0,A0
	MOVE.L	-20(A4),(A0)
	MOVE.L	D2,4(A0)
	MOVE.L	D0,-20(A4)
	ADDQ.L	#8,D0
	RTS

.raises:MOVE.L	#"STCK",-84(A4)
	BRA.S	.rraise
.raise:	MOVE.L	#"MEM",-84(A4)		; COPY OF Raise()
.rraise:MOVE.L	-76(A4),D0
	BEQ.S	.clean
	MOVE.L	D0,A0
	MOVE.L	-80(A4),A7
	MOVE.L	-88(A4),A5
	MOVE.L	(A7)+,-88(A4)
	MOVE.L	(A7)+,-76(A4)
	MOVE.L	(A7)+,-80(A4)
	JMP	(A0)
.clean:	MOVE.L	-24(A4),A0
	JMP	(A0)

      I_FASTDISPOSELIST:		; ALMOST SAME AS FASTDIPOSE!!!!!
	MOVE.L	4(A7),D0		; parms(ptr)
	BEQ.S	.oute
	MOVE.L	D0,A0
	MOVE.L	-(A0),D0
	EXT.L	D0
	LSL.L	#2,D0
	ADDQ.L	#4,D0
	CMP.L	#257,D0
	BPL.S	.free
	ADDQ.L	#3,D0
	AND.W	#%1111111100,D0
	LEA	GLOBOFFNEWTAB(A4),A1
	ADD.L	D0,A1
	MOVE.L	(A1),(A0)
	MOVE.L	A0,(A1)
.oute:	RTS
.free:	SUBQ.L	#8,A0
	LEA	-20(A4),A1
.loop:	MOVE.L	(A1),D1
	BEQ.S	.out
	MOVE.L	A1,A2			; ADR TO LINK BACK TO
	MOVE.L	D1,A1
	CMPA.L	D1,A0
	BNE.S	.loop
	MOVE.L	4(A1),D0		; MEMSIZE
	MOVE.L	(A1),(A2)		; LINK BACK
	MOVE.L	$4.W,A6
	JSR	-210(A6)		; FREEMEM
.out:	RTS

      I_FATAN:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-30(A6)
	RTS

      I_FSINCOS:
	MOVE.L	8(A7),A0
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-54(A6)
	RTS

      I_FSINH:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	60(A6)
	RTS

      I_FCOSH:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-66(A6)
	RTS

      I_FTANH:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-72(A6)
	RTS

      I_FTIEEE:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-102(A6)
	RTS

      I_FFIEEE:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-108(A6)
	RTS

      I_FASIN:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-114(A6)
	RTS

      I_FACOS:
	MOVE.L	4(A7),D0
	MOVE.L	-60(A4),A6
	JSR	-120(A6)
	RTS

      I_CODEEND:


;xxx:
;	lea	.1(pc),a0
;	HASH	a0,d0,d1
;	rts
;.1:	dc.b	"left",0,0



; '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	;
;	UnInitialized DataSection for E Compiler		;
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,	;

		SECTION EDATA,BSS
FIB:		DS.B	300
		EVEN
NAMEBUF:	DS.B	300
		EVEN
SRCDIRBUF:	DS.B	300
		EVEN
DIRNAME:	DS.B	300
		EVEN
PRINTBUF:	DS.B	300
		EVEN
WORKBUF:	DS.B	MAXIDENT+2
		EVEN
ESTACKBUF:	DS.B	MAXSTACK+2
		EVEN
EFUNCBYTE:	DS.B	NREFUNC+10
		EVEN
EFUNCRAISE:	DS.B	(NREFUNC+10)*10
		EVEN
LIBRAISE:	DS.B	MAXLIBRAISE*10
		EVEN
BRACKETSBUF:	DS.B	MAXBRACK*4
		EVEN
HASHBUFS:				; CONTIGUOUS BLOCKS
KEYHASH:	DS.B	1024
ASMHASH:	DS.B	1024
CONSTHASH:	DS.B	1024
IDENTHASH:	DS.B	1024
MACROHASH:	DS.B	1024
ENDHASHBUFS:

END
