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ZSNXT
	STA 2 0,2
	MOV 3 0
	LDA 3 34,3
	JSR   0,3
	  1
FINISH:	.SYSTEM
	.RTN
	JMP .+1
ABORT:	JSR ABMSG
	JMP ERROR

LWB01:
LWB10:
SWB01:
SWB10:
NOTYET:	JSR NYMSG
	JMP ERROR

ERROR:	LDA 0 0,3
	MOVS 0 0, SNR
	JMP   FINISH
	STA 3 16
	.SYSTEM
	.PCHAR
	HALT
	MOVS 0 0, SNR
	JMP FINISH
	STA 3 16
	.SYSTEM
	.PCHAR
	HALT
	INC 3 3
	JMP ERROR

ABMSG:	JSR 0,3
	.TXT "<15><12>ABORT<15><12><0><0>"

KARG1:	FARG1

NYMSG:	JSR 0,3
	.TXT "<15><12>STRUCTURE ROUTINES NOT LOADED<15><12><0><0>"

GETFRM:	STA 3 FTEMP,2
	MOV 2 3
	LDA 2 ZSNXT
	STA 3 FLAST,2
	STA 0 FARG1,2
	STA 1 FARG2,2
	LDA 0 @FTEMP,3
	ADD 2 0
	STA 0 ZSNXT
	LDA 1 ZSMAX
	SUBZ# 0 1, SNC
	JMP GFOFL
	LDA 0 @FRET,3
	LDA 1 K3
	SUBL# 1 0, SNC
	JMP   GFGE3
GFLE2:	LDA 3 FTEMP,3
	JMP   2,3
GFGE3:	SUB 0 1, SZR
	JMP   GFGR3
GFEQ3:	LDA 1 FARGX,3
	STA 1 FARG3,2
	LDA 3 FTEMP,3
	JMP   2,3
GFGR3:	LDA 1 FARGX,3
	ADD 3 1
	LDA 3 FTEMP,3
	JMP   1,3

K3:	3

GFOFL:	JSR OFMSG
	JMP ERROR
OFMSG:	JSR 0,3
	.TXT "<15><12>FRAME SPACE OVERFLOW<15><12><0><0>"

RETURN:	STA 2 ZSNXT
	LDA 2 FLAST,2
	LDA 3 FRET,2
	JMP   1,3

STARGS:	STA 3 FRET,2
	MOV 1 3
	STA 0 FTEMP,2
	LDA 1 K3
	SUB 0 1
	LDA 0 3,3
	STA 0 FARG3,2
	LDA 0 4,3
	STA 0 FARG4,2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,2
	LDA 1 0,3
	AND 1 0
	LDA 3 FTEMP,2
	LDA 3 0,3
	COM 1 1
	AND 3 1
	ADD 1 0
	LDA 3 FTEMP,2
	STA 0 0,3
	LDA 3 FRET,2
	JMP   1,3

SNQ1:	STA 3 FRET,2
	STA 0 FTEMP,2
	LDA 0 0,3
	AND 0 1
	LDA 3 FTEMP,2
	LDA 3 0,3
	COM 0 0
	AND 3 0
	ADD 0 1
	LDA 3 FTEMP,2
	STA 1 0,3
	LDA 3 FRET,2
	JMP 1,3

LY01:	STA 3 FRET,2
	MOVL# 1 1, SZC
	MOVOR 1 3, SKP
	MOVZR 1 3, SKP
	ADDC  0 3, SKP
	ADD   0 3
	LDA 1 0,3
	LDA 0 K377R
	MOV# 0 0, SNC
	MOVS 0 0, SKP
	AND  1 0, SKP
	ANDS 1 0
	JMP  @FRET,2

SY01:	STA 3 FRET,2
	MOVL# 1 1, SZC
	MOVOR 1 3, SKP
	MOVZR 1 3, SKP
	ADDC  0 3, SKP
	ADD   0 3
	STA 3 FTEMP,2
	LDA 3 0,3
	LDA 1 FARGX,2
	LDA 0 K377R
	MOV# 0 0, SZC
	AND  0 1, SKP
	AND  0 3, SKP
	MOVS 0 0, SKP
	ANDS 1 0, SKP
	AND  3 0, SKP
	ADD  3 0, SKP
	ADD  1 0
	LDA 3 FTEMP,2
	STA 0 0,3
	JMP  @FRET,2

LY10:	STA 3 FRET,2
	MOVL# 0 0, SZC
	MOVOR 0 3, SKP
	MOVZR 0 3, SKP
	ADDC  1 3, SKP
	ADD   1 3
	LDA 0 0,3
	LDA 1 K377R
	MOV# 1 1, SNC
	MOVS 1 1, SKP
	AND  0 1, SKP
	ANDS 0 1
	JMP  @FRET,2

SY10:	STA 3 FRET,2
	MOVL# 0 0, SZC
	MOVOR 0 3, SKP
	MOVZR 0 3, SKP
	ADDC  1 3, SKP
	ADD   1 3
	STA 3 FTEMP,2
	LDA 3 0,3
	LDA 0 FARGX,2
	LDA 1 K377R
	MOV# 1 1, SZC
	AND  1 0, SKP
	AND  1 3, SKP
	MOVS 1 1, SKP
	ANDS 0 1, SKP
	AND  3 1, SKP
	ADD  3 1, SKP
	ADD  0 1
	LDA 3 FTEMP,2
	STA 1 0,3
	JMP  @FRET,2

K377R:	377

.END START