
IF2 [	.MLLIT=1
	$PURE==0
IFN PURESW,[
	$PURLC==$PURBG	;RESET BOTH LOCATION COUNTERS.
	$VARLC==$VARBG
]]
IF2 .INEOF

.MLLIT=1	;MULTI-LINE MODE.
IFN 0,[
.AUXIL		;DON'T CREF THIS FILE'S SYMBOLS UNLESS THEY'RE ACTUALLY USED ELSEWHERE.
]
IFNDEF %TOOVR,.INSRT SYSTEM;TTYDEF >
IFNDEF %PIMPV,.INSRT SYSTEM;BITS >

;AC DEFS.
F==0		;FLAGS.
A=1		;THESE USED FOR ARGS.
B=2
C=3
D=4
E=5
G=6		;RARELY SAVED IF USED.
H=7
I=10		;CHARACTER IO THRU HERE.
J=11		;-> FILE BLOCK.
K=12
M=13		;OUTPUT PATH.
N=14		;INPUT PATH.
R=15
S=16
P=17		;PDL POINTER.

SAVE=PUSH P,
REST=POP P,
CALL=PUSHJ P,
RET=POPJ P,

SIGN=400000	;IT SAVES A LITTLE TYPING
JRSTF=JRST 2,
JOV=JFCL 10,
JCRY0=JFCL 4,
JCRY1=JFCL 2,
JFOV=JFCL 1,
.FORMAT 30,2704_24.	;MAKE A, FORMAT TREAT A LIKE AC
.FORMAT 34,00222704_12.	;CHANGE A,B FORMAT TO TREAT A LIKE AC
.AOP .OPER@ 0,.RDATIM	;GET DATE AND TIME OF ASSEMBLY
ASTIME=.AVAL1	;TIME (SIXBIT /HHMMSS/) OF ASSEMBLY
ASDATE=.AVAL2	;DATE (SIXBIT /YYMMDD/) OF ASSEMBLY


;SWDEF NAME=EXPR	;SET "NAME" TO "EXPR" IFF "NAME" NOT DEFINED

DEFINE SWDEF ASSGT/
IRPS DUMMY,,[ASSGT]
IFNDEF DUMMY,ASSGT
.ISTOP
TERMIN
TERMIN

	;FOLLOWING MACROS TAKE ADVANTAGE
	;OF ARGUMENT EVALUATION AT EXPANSION TIME

DEFINE CONCAT A,B
A!B!TERMIN

DEFINE DEF A,B,C,D,E,F,G,H,I,J,K
DEFINE A!B!C!D!E!F!G!H!I!J!K!TERMIN
TERMIN

DEFINE PRINTA A,B,C,D,E,F
IF1,[PRINTC Á!B!C!D!E!F
Ý
TERMIN


DEFINE PRINTB A,B,C,D,E,F
PRINTC Á!B!C!D!E!F
Š
TERMIN

	;(RIGHT) BYTE POINTER, POS ARG IS # BITS TO RIGHT OF BYTE

DEFINE POINTR POS,SIZ
<POS>_12.+<SIZ>_6,,TERMIN

	;(LEFT) BYTE POINTER, 1STBIT ARG IS # BITS TO LEFT OF BYTE

DEFINE POINTL 1STBIT,SIZ
<36.-<SIZ>-<1STBIT>>_12.+<SIZ>_6,,TERMIN

	;BYTE POINTER TO BYTE BEFORE FIRST IN WORD

DEFINE POINTZ SIZ
36.-<36./<SIZ>*<SIZ>>_12.+<SIZ>_6,,-1 TERMIN

;BYTE POINTER TO THE WORD BUT OFF THE LEFT END (EG 440700,,)
DEFINE POINTW SIZ
36._12.+<SIZ>_6,,TERMIN

	;(PLURAL) BYTE POINTER ARRAY TO LDB FROM INDEXED

DEFINE POINTS SIZ
REPEAT 36./<SIZ>,<36.-<SIZ>*<.RPCNT+1>>_12.+<SIZ>_6,,TERMIN

	;(ILDB) BYTE POINTER ARRAY TO ILDB FROM

DEFINE POINTI SIZ
REPEAT 36./<SIZ>,<36.-<SIZ>*.RPCNT>_12.+<SIZ>_6,,TERMIN

	;ASSEMBLE INTO A CERTAIN LOCATION

DEFINE TMPLOC LCTN,CRUFT/
.ZZ==.
LOC LCTN
CRUFT
.=.ZZ
TERMIN

	;DECREMENT A 7 BIT BYTE POINTER

DEFINE DBP7 AC
ADD AC,[070000,,0]
TLNE AC,400000
SUB AC,[430000,,1]
TERMIN

	;DECREMENT 7 BIT BYTE POINTER AND JUMP

DEFINE DBP7J AC,ADR
ADD AC,[70000,,0]
JUMPGE AC,ADR
SUB AC,[430000,,1]
JRST ADR
TERMIN

	;IFNEED FOOSW,FOO,[FOO:BAR]
	;ASSEMBLES IF FOO NEEDED OR FOOSW NONZERO.

DEFINE IFNEED A,B
SWDEF A==0
IF1 [IRPS X,,[B]
IFE 3-.TYPE X ,A==1
TERMIN ]
IFN A,TERMIN


	;REPEAT AN INSTRUCTION WITH VARIOUS ADDRESSES

DEFINE INSIRP A,B
IRPS %%ADR,,[B]
A,%%ADR
TERMIN
TERMIN

	;TAKE ACTION WHEN A BUG IS DETECTED.
	;(MIGHT BE REDEFINED AFTER THIS FILE)
DEFINE	BUG A/
.VALUE
TERMIN

	;PAUSE IF IN DEBUG MODE. SHOULD HAPPEN BEFORE THE PROGRAM
	;FINALIZES ITS MAIN ACTION OR KILLS ITSELF.
DEFINE DPAUSE
	SKIPE DEBUG
	 .VALUE
TERMIN

	;1ST ARG NAME OF SYSTEM CALL,
	;2ND LIKE A LITERAL HAS ARGS TO CALL.
DEFINE SYSCAL A,B
	.CALL [SETZ ? SIXBIT/A/ ? B ((SETZ))]
TERMIN

DEFINE INSERT LINE/
  IRPS %NAME,,[LINE]
    DEFINE %NAME DEFALT/
      .INSRT DSK:DEFALT  LINE
    TERMIN
  .ISTOP
  TERMIN
TERMIN

DEFINE INSERT DEFALT/GENSYM
  IRPS %NAME,,[DEFALT]
    IFNDEF %NAME,[
      DEFINE %NAME
	.INSRT DSK:!TERMIN
    ]
    DEFINE GENSYM
      EXPUNG GENSYM
      %NAME!!TERMIN
    .ISTOP
    TERMIN
  GENSYM DEFALTîTERMIN
SWDEF PURESW==0
IFE PURESW,[
DEFINE	VBLK
IFE $PURE, .ERR CONSEC. VBLK'S
$PURE==0
TERMIN

DEFINE PBLK
IFN $PURE, .ERR CONSEC. PBLK'S
$PURE==1
TERMIN

DEFINE $PUREND	;SETS $PURMX, $VARMX IF PURESW.
TERMIN
]

IFN PURESW,[
DEFINE	VBLK	;START IMPURE CODING.
IFE $PURE, .ERR CONSEC. VBLK'S
IFN $PURE, $PURLC==. ? .=$VARLC
$PURE==0
TERMIN

DEFINE	PBLK	;START PURE CODING.
IFN $PURE, .ERR CONSEC. PBLK'S.
IFE $PURE, $VARLC==. ? .=$PURLC
$PURE==1
TERMIN

SWDEF $VARBG==.	;DEFINE STARTS OF SEGMENTS.
SWDEF $PURBG==20*2000
$PURLC==$PURBG	;INITIALIZE LOC. CNTRS.
$VARLC==$VARBG

DEFINE $PUREND	;PUT THIS AFTER END OF BOTH SEGS.
IFN $PURE, VBLK	;FORCE BOTH $PURLC AND $VARLC TO BE RIGHT.
PBLK
$PURMX==$PURLC
$VARMX==$VARLC
TERMIN
]	;END IFN PURESW,

$PURE==0

DEFINE VARS X
VBLK
X
PBLK
TERMIN

;UUO DEFINITION MACROS:

F"UUONUM==0	;USED TO ASSIGN VALUES TO UUOS.

;DEFINE UUO NAMED A, DISPATCH ENTRY B.
DEFINE UUODEF A,B
	F"UUONUM==F"UUONUM+1
	A=F"UUONUM_33
	TMPLOC  UUOTAB+A_-33, B
TERMIN

;DEFINE AN OUTPUT UUO, TO CALL AT CURRENT LOCATION.
DEFINE OUTUUO A
UUODEF .M"A,\.,,F"OUTUOH
TERMIN

;ARRANGE FOR SOME THINGS TO BE DONE AT END OF ASSAMBLY.
EQUALS $END,END

DEFINE END ADDR
F"UUOMAX==F"UUONUM		;LARGEST UUO NUM. USED.
F"CHNMAX==F"CHNNUM		;LARGEST ASSIGNED CHANNEL NUM.
IFN F"UUOMAX,[IFNDEF UUOTAB,[ VBLK
UUOTAB:	BLOCK F"UUOMAX  ]]
IFN PURESW, IFNDEF $PURMX, $PUREND	;(UNLESS ALREADY DONE)
$END ADDR
TERMIN
;ASSEMBLE A FILE BLOCK AND NAME THE WORDS IN IT.

DEFINE	FILDEF	NAM,CHNL,SIZ
NAM!CHN:	CHNL
NAM!DEV:	0
NAM!FN1:	0
NAM!FN2:	0
NAM!SNM:	0
NAM!BPT:	0+IFN NAM!BSZ,POINTZ SIZ,NAM!BUF
NAM!PNT:	0
NAM!CNT:	-1	;BUFFER NOT INITTED.
NAM!EPT:	0
NAM!BSB:	36./SIZ
NAM!LEN:	NAM!BSZ
NAM!MOD:	0
IFN NAM!BSZ,NAM!BUF: BLOCK NAM!BSZ+1
TERMIN

;NUMBER OF NEXT UNASSIGNED IO CHANNEL.
DEFINE FRECHN
F"CHNNUM+1
F"CHNNUM==F"CHNNUM+1
TERMIN

F"CHNNUM==0
