File: M1.PA of Disk: Disks/MyPDP/m8-blue-rka1-rkb1
(Source file text) 

/M1.PA 25-SEP-80
/**UASEM VERSION**
/******************************************************
/******************************************************
/****************  M U L T I   8   ********************
/******************************************************
/******************************************************

/	REALTIME-FOREGROUND / TIMESHARING BACKGROUND
/	      OPERATING  SYSTEM FOR THE PDP8
/		        COMPUTERS
/
/
/		ORIGINATOR:
/		FLOOR ANTHONI
/		MEDICAL BIOLOGICAL LAB TNO
/		RIJSWIJK,THE NETHERLANDS
/
/		MAINTAINERS:
/		ERNST LOPES CARDOZO
/		WESTVRIES COMPUTER CONSULTING
/
/		WILLEM VAN DER MARK
/		DATAPLAN GMBH
/
/	(C)	COPYRIGHT AND DISTRIBUTION BY:
/		WESTVRIES COMPUTER CONSULTING BV,
/		RIJKSSTRAATWEG 19A, 1969 LB HEEMSKERK
/		NETHERLANDS	  PHONE 0031-2510-43244
/		AND
/		DATA-PLAN COMPUTER-VERTRIEBSGESELLSCHAFT MBH
/		POSTFACH 140, OBERLAUDAER STRASSE 34
/		6970 LAUDA	  PHONE 0049-9343-8045
/		BUNDESREPUBLIK DEUTSCHLAND

IFNDEF SINGL8 <
	VERSHI="7
	VERSLO="B	/ >
IFDEF SINGL8 <
	VERSHI="1
	VERSLO=" 	/ >
XLIST XLISTX	/LIST ONLY IF XLISTX=0 (=ALL)
/THE SYMBLS PASS1, PASS2 AND PASS3 ARE USED TO DISTINGUISH
/THE VARIOUS ASSEMBLER PASSES. EACH SYMBOL IS NONZERO ONLY
/DURING THAT PASS.
IFNZRO PASS2 <
	PASS3=1
	PASS2=0		/ >
IFNZRO PASS1 <
	PASS2=1
	PASS1=0		/ >
IFNDEF PASS1 <
	PASS1=1
	PASS2=0
	PASS3=0		/ >
/NOTE THAT UP TO THIS POINT THE USE OF PASS# WILL GIVE TROUBLE.


/TO ENNABLE SWITCHING OF FIELD DURING ASSEMBLY, THE SYMBOLS
/DOTF## ARE USED TO REMEMBER HOW FAR EACH FIELD HAS BEEN FILLED.


/EQUATES FOR CONFIGURATION MNEMONICS

/EQUATES FOR TASK COMMUNICATION:
PROGER=1	/PROGRAMMING ERROR CODE
TIMEOUT=2	/TIMEOUT CODE
HRDERR=4	/UNRECOVERABLE I/O ERROR
EOMERR=10	/END-OF-MEDIUM WARNING
EOFERR=20	/END-OF-FILE WARNING (^Z)
OS8DAT=7666	/ADDRES OF DATE WORD IN OS8 FIELD 1

/EQUATES FOR LISTING CONTROL:
LZERO=3777	/LIST PAGE ZERO CODE
LSKIPS=5777	/LIST SKIPCHIAN ETC.
LMONIT=6777	/LIST THE MONITOR PART
LEMULA=7377	/LIST THE BG-EMULATOR
LRESMOD=7577	/LIST THE RESIDENT TASKS (TASKS)
LSYSDRV=7677	/LIST THE SYSTEM DRIVER CODE
LPWRUP=7737	/LIST THE POWERUP PROGRAM
LDATA=7757	/LIST THE DATAAREA
LCONFG=7767	/LIST THE CONFIGURATION PART
LLOCAL=7773	/LIST ALL LOCAL INSERTED CODE
LFPP=7775	/LIST FPP EMULATOR
/INSTRUCTIONS THAT ARE MISSING IN PAL8
CINT=6204
SINT=6254
SUF=6274
CUF=6264
SCL=7403
SCA=7441
ASC=7403
SCL=7403
SWAB=7431
SWBA=7447
DPSZ=7451
SAM=7457
AC0001=CLA CLL IAC
AC0002=CLA STL RTL
AC0003=CLA STL IAC RAL	/
AC0004=CLA CLL IAC RTL	/
AC0006=CLA STL IAC RTL	/
AC0100=CLA IAC BSW
AC2000=CLA STL RTR
AC3777=CLL STA RAR
AC4000=CLA STL RAR
AC5777=CLL STA RTR	/
AC6000=CLA STL IAC RTR	/
AC7775=CLL STA RTL
AC7776=CLL STA RAL
AC7777=STA
ACM1=STA
ACM2=AC7776
ACM3=AC7775
XLIST -LCONFG-1&XLISTX
/NOTATIONS:

///	=(TRHEE SLASHES)PROGRAM RUNS WITH INTERRUPT OFF.
//	=(TWO SLASHES)DATAFIELD NOT EQUAL INSTRUCTION FIELD
/TCB	=TASK CONTROL BLOCKLET
/TCBP	=TASK CONTROL BLOCK POINTER
/	 =(ONE SPACE AFTER TAB)NOT ALWAYS EXECUTED
/	   =(THREE SPACES)ARGUMENT OF SUBROUTINE

/CONFIGURATING LOGIC:

IFNZRO PASS1 <	/ASSEMBLE IN FIRST PASS ONLY !
IFDEF SINGL8 <	/SOME FIXED PARAMETERS FOR SINGL8
BGCORE=4	/16K BACKGROUNDS
BGMAX=2		/TWO OF THEM
FIELDS=2	/AN 8K FOREGROUND
BGFLDS=6	/MUST BE A 32K MACHINE
IFDEF KL8E2 <???/JUST ONE TERMINAL !>
		/END OF IFDEF SINGL8 >

/DEFAULTS:
IFNDEF FIELDS	<FIELDS=2	/NORMALLY THAT WILL DO>
IFNDEF BGFLDS	<BGFLDS=10-FIELDS/ASSUME 32K MACHINE>
IFNDEF OS8	<OS8=3		/STANDARD DEC VERSION 3DEXT >
IFNDEF GERMAN	<GERMAN=0	/NORMAL IS ENGLISH >
IFNDEF BGMAX	<BGMAX=1>
IFNDEF MAXNAM	<MAXNAM=BGMAX^5+24
 IFDEF LE8E	<MAXNAM=MAXNAM+3>
 IFDEF PP8E	<MAXNAM=MAXNAM+2>
 IFDEF PR8E	<MAXNAM=MAXNAM+2>
 IFDEF TC08	<MAXNAM=MAXNAM+2>
 IFDEF TD8E	<MAXNAM=MAXNAM+2>
 IFDEF CR8E	<MAXNAM=MAXNAM+1>
 IFDEF CM8E	<MAXNAM=MAXNAM+1>
 IFDEF TM8E	<MAXNAM=MAXNAM+2>
 IFDEF TC58	<MAXNAM=MAXNAM+2>
 IFDEF KLPLOT	<MAXNAM=MAXNAM+3>
 IFDEF XY8E	<MAXNAM=MAXNAM+3>
 IFDEF DP8E	<MAXNAM=MAXNAM+2>
 IFDEF OLINK	<MAXNAM=MAXNAM+1>
 IFDEF VENUS	<MAXNAM=MAXNAM+2>
 IFDEF DVM	<MAXNAM=MAXNAM+1>
 IFDEF SCV	<MAXNAM=MAXNAM+1>
 IFDEF Z80	<MAXNAM=MAXNAM+1>
 IFDEF KLEXTR	<MAXNAM=MAXNAM+2>
 IFDEF RX01	<MAXNAM=MAXNAM+2>
 IFDEF RX02	<MAXNAM=MAXNAM+2>
 IFDEF NSRK8E	<MAXNAM=MAXNAM+2>
 IFDEF NSRK08	<MAXNAM=MAXNAM+2>
 IFDEF NSRL01	<MAXNAM=MAXNAM+2>
 IFDEF NS3010	<MAXNAM=MAXNAM+2>
 IFDEF NS3040	<MAXNAM=MAXNAM+2>
 IFDEF UDEV1	<MAXNAM=MAXNAM+2>
 IFDEF UDEV2	<MAXNAM=MAXNAM+2>
 IFDEF UDEV3	<MAXNAM=MAXNAM+2>
 IFDEF UDEV4	<MAXNAM=MAXNAM+2>
 IFDEF KIMIO	<MAXNAM=MAXNAM+2>
			/ >
IFNDEF SOFSLOT <SOFSLOT=MAXNAM%2>
IFNDEF DGNTICK <DGNTICK=12>
IFNDEF HWTICK <
	DECIMAL
	IFDEF DK8EP <HWTICK=10>
	IFDEF DK8EA <HWTICK=100>
	IFDEF DK8EB <HWTICK=100>
	IFDEF DK8EC <HWTICK=50>
	IFDEF DKC8AA <HWTICK=100>
	IFDEF DKC8AB <HWTICK=400	/DP MOD OF DKC8AA FOR 600 BAUD REC
	DKC8AA=DKC8AB>
	OCTAL		/ >
IFNDEF GIGAMX <GIGAMX=30>
IFNDEF ASEMMX <ASEMMX=10>	/**UASEM VERSION**
IFDEF SYRF08 <RFORDF=1>
IFDEF SYDF32 <RFORDF=1>
IFDEF TC08 <TAPE=10>
IFDEF TD8E <TAPE=2>
IFDEF SYRK08 <TRACK=10>
IFDEF SYRK8E <TRACK=20>
IFDEF SYRL01 <TRACK=20>
IFDEF SYRX02 <TRACK=1 >
IFDEF SY3040 <TRACK=20>
IFDEF SY3010 <TRACK=20>
IFDEF RFORDF <TRACK=10>

BGFLD=FIELDS^10
IFNDEF BGCORE <BGCORE=BGFLDS>
DGNCNT=HWTICK%DGNTICK
IFZERO DGNCNT <DGNCNT=1>
IFDEF SYRF08 <
	IFDEF RFCLOCK <RFINTS=300/FOTOCEL INT ENABLE>
	IFNDEF RFCLOCK <RFINTS=100/FOTOCEL INT DISABLE>>
IFNDEF XLISTX <XLISTX=0 	/DEFAULT LIST ALL >
IFNDEF BRKCHR <BRKCHR=206 /SYSTEM BREAK CHAR. CTRL/F >
IFNDEF T1CHAR <T1CHAR=0;T1FILL=0>
IFNDEF T1ESCP <T1ESCP=233>
IFNDEF T1BACK <T1BACK=210>
IFNDEF T2CHAR <T2CHAR=0;T2FILL=0>
IFNDEF T2ESCP <T2ESCP=233>
IFNDEF T2BACK <T2BACK=210>
IFNDEF T3CHAR <T3CHAR=0;T3FILL=0>
IFNDEF T3ESCP <T3ESCP=233>
IFNDEF T3BACK <T3BACK=210>
IFNDEF T4CHAR <T4CHAR=0;T4FILL=0>
IFNDEF T4ESCP <T4ESCP=233>
IFNDEF T4BACK <T4BACK=210>
IFNDEF T5CHAR <T5CHAR=0;T5FILL=0>
IFNDEF T5ESCP <T5ESCP=233>
IFNDEF T5BACK <T5BACK=210>
IFNDEF T6CHAR <T6CHAR=0;T6FILL=0>
IFNDEF T6ESCP <T6ESCP=233>
IFNDEF T6BACK <T6BACK=210>
IFNDEF T7CHAR <T7CHAR=0;T7FILL=0>
IFNDEF T7ESCP <T7ESCP=233>
IFNDEF T7BACK <T7BACK=210>
IFNDEF C0CHAR <C0CHAR=0;C0FILL=0>
IFNDEF C0BACK <C0BACK=210>
IFNDEF C0ESCP <C0ESCP=233>
IFNDEF C1CHAR <C1CHAR=0;C1FILL=0>
IFNDEF C1BACK <C1BACK=210>
IFNDEF C1ESCP <C1ESCP=233>
IFNDEF C2CHAR <C2CHAR=0;C2FILL=0>
IFNDEF C2BACK <C2BACK=210>
IFNDEF C2ESCP <C2ESCP=233>
IFNDEF C3CHAR <C3CHAR=0;C3FILL=0>
IFNDEF C3BACK <C3BACK=210>
IFNDEF C3ESCP <C3ESCP=233>
IFNDEF SYLNGT	</LENGTH OF SYSTEM DISK UNITS IN BLOCKS
IFDEF SYRK8E	<SYLNGT=6260>
IFDEF SYRL01	<SYLNGT=7761
		 SCLNGT=3751>
IFDEF SYRX02	<SYLNGT=1734>
IFDEF SYRK08	<SYLNGT=6260>
IFDEF SY3040	<SYLNGT=6260>
IFDEF SY3010	<SYLNGT=6260>
IFDEF SYRF08	<SYLNGT=SYRF08^2000>
IFDEF SYDF32	<SYLNGT=SYDF32^200>>

IFNDEF SIZE0	<SIZE0=SYLNGT>
IFNDEF USYS1	<USYS1="S^100+"Y&3777>
IFNDEF UNIT1	<UNIT1=1>
IFNDEF FROM1	<FROM1=0>
IFNDEF SIZE1	<SIZE1=SYLNGT>
IFNDEF USYS2	<USYS2="S^100+"Y&3777>
IFNDEF UNIT2	<UNIT2=2>
IFNDEF FROM2	<FROM2=0>
IFNDEF SIZE2	<SIZE2=SYLNGT>
IFNDEF USYS3	<USYS3="S^100+"Y&3777>
IFNDEF UNIT3	<UNIT3=3>
IFNDEF FROM3	<FROM3=0>
IFNDEF SIZE3	<SIZE3=SYLNGT>
IFNDEF USYS4	<USYS4="S^100+"Y&3777>
IFNDEF UNIT4	<UNIT4=4>
IFNDEF FROM4	<FROM4=0>
IFNDEF SIZE4	<SIZE4=SYLNGT>
IFNDEF USYS5	<USYS5="S^100+"Y&3777>
IFNDEF UNIT5	<UNIT5=5>
IFNDEF FROM5	<FROM5=0>
IFNDEF SIZE5	<SIZE5=SYLNGT>
IFNDEF USYS6	<USYS6="S^100+"Y&3777>
IFNDEF UNIT6	<UNIT6=6>
IFNDEF FROM6	<FROM6=0>
IFNDEF SIZE6	<SIZE6=SYLNGT>
IFNDEF USYS7	<USYS7="S^100+"Y&3777>
IFNDEF UNIT7	<UNIT7=7>
IFNDEF FROM7	<FROM7=0>
IFNDEF SIZE7	<SIZE7=SYLNGT>
IFZERO "S^100+"Y&3777-USYS1 < IFZERO UNIT1-1 < IFZERO FROM1 <
 IFZERO SYLNGT-SIZE1	<USESY1=1>>>>
IFZERO "S^100+"Y&3777-USYS2 < IFZERO UNIT2-2 < IFZERO FROM2 <
 IFZERO SYLNGT-SIZE2	<USESY2=1>>>>
IFZERO "S^100+"Y&3777-USYS3 < IFZERO UNIT3-3 < IFZERO FROM3 <
 IFZERO SYLNGT-SIZE3	<USESY3=1>>>>
IFZERO "S^100+"Y&3777-USYS4 < IFZERO UNIT4-4 < IFZERO FROM4 <
 IFZERO SYLNGT-SIZE4	<USESY4=1>>>>
IFZERO "S^100+"Y&3777-USYS5 < IFZERO UNIT5-5 < IFZERO FROM5 <
 IFZERO SYLNGT-SIZE5	<USESY5=1>>>>
IFZERO "S^100+"Y&3777-USYS6 < IFZERO UNIT6-6 < IFZERO FROM6 <
 IFZERO SYLNGT-SIZE6	<USESY6=1>>>>
IFZERO "S^100+"Y&3777-USYS7 < IFZERO UNIT7-7 < IFZERO FROM7 <
 IFZERO SYLNGT-SIZE7	<USESY7=1>>>>

IFNDEF USESY1 <DKUSED=1>
IFNDEF USESY2 <DKUSED=1>
IFNDEF USESY3 <DKUSED=1>
IFNDEF USESY4 <DKUSED=1>
IFNDEF USESY5 <DKUSED=1>
IFNDEF USESY6 <DKUSED=1>
IFNDEF USESY7 <DKUSED=1>
IFNDEF TTYMAX <
IFNDEF KL8E2 <TTYMAX=1>
IFDEF KL8E2 <TTYMAX=2>
IFDEF KL8E3 <TTYMAX=3>
IFDEF KL8E4 <TTYMAX=4>
IFDEF KL8E5 <TTYMAX=5>
IFDEF KL8E6 <TTYMAX=6>
IFDEF KL8E7 <TTYMAX=7>
IFZERO TTYMAX-1 <
C0CHAR=T2CHAR;C0FILL=T2FILL;C0ESCP=T2ESCP;C0BACK=T2BACK
C1CHAR=T3CHAR;C1FILL=T3FILL;C1ESCP=T3ESCP;C1BACK=T3BACK
C2CHAR=T4CHAR;C2FILL=T4FILL;C2ESCP=T4ESCP;C2BACK=T4BACK
C3CHAR=T5CHAR;C3FILL=T5FILL;C3ESCP=T5ESCP;C3BACK=T5BACK >
IFZERO TTYMAX-2 <
C0CHAR=T3CHAR;C0FILL=T3FILL;C0ESCP=T3ESCP;C0BACK=T3BACK
C1CHAR=T4CHAR;C1FILL=T4FILL;C1ESCP=T4ESCP;C1BACK=T4BACK
C2CHAR=T5CHAR;C2FILL=T5FILL;C2ESCP=T5ESCP;C2BACK=T5BACK
C3CHAR=T6CHAR;C3FILL=T6FILL;C3ESCP=T6ESCP;C3BACK=T6BACK >
IFZERO TTYMAX-3 <
C0CHAR=T4CHAR;C0FILL=T4FILL;C0ESCP=T4ESCP;C0BACK=T4BACK
C1CHAR=T5CHAR;C1FILL=T5FILL;C1ESCP=T5ESCP;C1BACK=T5BACK
C2CHAR=T6CHAR;C2FILL=T6FILL;C2ESCP=T6ESCP;C2BACK=T6BACK
C3CHAR=T7CHAR;C3FILL=T7FILL;C3ESCP=T7ESCP;C3BACK=T7BACK >
IFZERO TTYMAX-4 <
C0CHAR=T5CHAR;C0FILL=T5FILL;C0ESCP=T5ESCP;C0BACK=T5BACK
C1CHAR=T6CHAR;C1FILL=T6FILL;C1ESCP=T6ESCP;C1BACK=T6BACK
C2CHAR=T7CHAR;C2FILL=T7FILL;C2ESCP=T7ESCP;C2BACK=T7BACK
C3CHAR=T8CHAR;C3FILL=T8FILL;C3ESCP=T8ESCP;C3BACK=T8BACK >
IFZERO TTYMAX-5 <
C0CHAR=T6CHAR;C0FILL=T6FILL;C0ESCP=T6ESCP;C0BACK=T6BACK
C1CHAR=T7CHAR;C1FILL=T7FILL;C1ESCP=T7ESCP;C1BACK=T7BACK
C2CHAR=T8CHAR;C2FILL=T8FILL;C2ESCP=T8ESCP;C2BACK=T8BACK
C3CHAR=T9CHAR;C3FILL=T9FILL;C3ESCP=T9ESCP;C3BACK=T9BACK >
IFZERO TTYMAX-6 <
C0CHAR=T7CHAR;C0FILL=T7FILL;C0ESCP=T7ESCP;C0BACK=T7BACK
C1CHAR=T8CHAR;C1FILL=T8FILL;C1ESCP=T8ESCP;C1BACK=T8BACK
C2CHAR=T9CHAR;C2FILL=T9FILL;C2ESCP=T9ESCP;C2BACK=T9BACK
C3CHAR=0;C3FILL=0;C3ESCP=0;C3BACK=0 >

IFDEF KL8A1 <TTYMAX=TTYMAX+4>
IFDEF KL8A2 <TTYMAX=TTYMAX+4>>
/DEFAULT INTERRUPT PRIORIRIES:
IFNDEF TIMER <
	*1
IFDEF KP8E	<POWER,.	/POWER FAIL TRAP >
IFDEF UDEV1	<DEV1,.		/USER DEVICE 1 >
IFDEF UDEV2	<DEV2,.		/USER DEVICE 2 >
IFDEF AX08	<AX08AD,.	/AD CONVERTER
		AX08RC,.	/AX08 RC CLOCK
		AX08SM,.	/AX08 SMITT TRIGGERS >
IFDEF DK8EP <
 IFDEF DK8EA	<CLOCK,.	/PROGRAMMABLE CLOCK>
 IFDEF DK8EB	<CLOCK,.	/PROGRAMMABLE CLOCK>
 IFDEF DK8EC	<CLOCK,.	/PROGRAMMABLE CLOCK >
 IFDEF DKC8AA	<CLOCK,.	/PROGRAMMABLE CLOCK >
 IFDEF RFCLOCK	<CLOCK,.	/PROGRAMMABLE CLOCK >>
IFDEF TONCLK	<CLOCK,.	/PROGRAMMABLE CLOCK >
IFNZRO BGMAX	<TRAP,.		/TIMESHARE TRAP >
		TIMER,.		/LINE CLOCK
		SYS,.		/SYSTEM DISK
IFDEF NSRK8E	<DSK,.		/RK8E NON-SYS>
IFDEF NSRK08	<DSK,.		/RK08 NON-SYS>
IFDEF NSRL01	<DSK,.		/RL01 NON-SYS>
IFDEF NS3010	<DSK,.		/SI3010 NON-SYS>
IFDEF NS3040	<DSK,.		/SI3040 NON-SYS>
IFDEF CR8E	<CRD,.		/CARDREADER
  IFDEF CM8E	<DBLDEF, _ >>
IFDEF CM8E	<CRD,.		/MARK SENSE >
IFDEF OLINK	<LINK,.		/OMNILINK >
IFDEF PR8E	<PTR,.		/PAPERTAPE READER >
IFDEF KLPLOT	<PLOT,.		/PLOTTER >
IFDEF XY8E	<PLOT,.		/PLOTTER >
IFDEF TC58	<MTA,.		/MAGTAPE >
IFDEF TM8E	<MTA,.		/MAGTAPE >
IFDEF TC08	<DTA,.		/TC08 DECTAPE >
IFDEF VC8E	<DPL,.		/DISPLAY >
IFDEF DP8E	<DP8ECD,.	/CHARACTER DETECT FLAG
		DP8ERO,.	/RECEIVE WORDCOUNT OVERFLOW
		DP8ETO,.	/TRANSMIT WORDCOUNT OVERFLOW
		DP8ECA,.	/CARRIER ON/OFF
		DP8ERG,.	/RING FLAG
		DP8EBE,.	/BUS ERROR FLAG >
IFDEF SCV	<SCHP,.		/SC VOLTMETER >
IFDEF VENUS	<VENUSI,.	/INPUT FROM VENUS
		VENUSO,.	/OUTPUT TO VENUS >
IFDEF DVM	<DVMHP,.	/HP DVM-COUNTER
		DVMERR,.	/ERROR FLAG
		DVMCNT,.	/RUBBISH FLAG >
IFDEF Z80	<Z80IN,.	/INPUT FROM Z80
		Z80OUT,.	/OUTPUT TO Z80 >
IFDEF KLEXTR	<EXTR,.		/AN EXTRA KL8E >
IFDEF RX01	<RXA,.		/RX01 FLOPPY DISK >
IFDEF RX02	<RXA,.		/RX02 FLOPPY DISK >
IFDEF UDEV3	<DEV3,.		/USER DEVICE 3 >
IFDEF UDEV4	<DEV4,.		/USER DEVICE 4 >
IFDEF KIMIO	<KIM, ZBLOCK 2	/KL8E KIM LINK >
	INTDEV=.
IFDEF LE8E	<LPT,.		/LINEPRINTER >
IFDEF PP8E	<PTP,.		/PAPERTAPE PUNCH >
		KB1,.
IFDEF KL8E2	<KB2,.		/ >
IFDEF KL8E3	<KB3,.		/ >
IFDEF KL8E4	<KB4,.		/ >
IFDEF KL8E5	<KB5,.		/ >
IFDEF KL8E6	<KB6,.		/ >
IFDEF KL8E7	<KB7,.		/ >
		TTY1,.
IFDEF KL8E2	<TTY2,.		/ >
IFDEF KL8E3	<TTY3,.		/ >
IFDEF KL8E4	<TTY4,.		/ >
IFDEF KL8E5	<TTY5,.		/ >
IFDEF KL8E6	<TTY6,.		/ >
IFDEF KL8E7	<TTY7,.		/ >
IFDEF KL8A1	<MUX,.		/KL8A MULTIPLEXER(S) >
IFDEF AX08	<AX08ER,.	/ADC ERROR FLAG
		AX08XT,.	/XTAL CLOCK >
IFDEF LE8E <
 IFZERO LE8E&1	<LPTER,.	/LINEPRINTER ERROR >>
		SKPDEV=.
IFDEF KL8A1 <	MUX1TT,ZBLOCK 4	/EVENTS FOR KL8A1 OUT
		MUX1KB,ZBLOCK 4	/EVENTS FOR KL8A1 IN >
IFDEF KL8A2 <	MUX2TT,ZBLOCK 4	/EVENTS FOR KL8A2 OUT
		MUX2KB,ZBLOCK 4	/EVENTS FOR KL8A2 IN >
		MAXDEV=.
		/ >
MAXSLOT=MAXDEV+SOFSLOT
IFZERO BGMAX <TOTSLOT=MAXSLOT>
IFNZRO BGMAX <TOTSLOT=MAXSLOT+BGMAX+1>
		/END OF PASS1 ONLY CODE >
		*0
/SOME RANDOM TESTS:
IFDEF RX01 < IFNZRO RX01&700-700 <RXERR,XERROR>>
IFDEF RX02 < IFNZRO RX02&700-700 <RXERR,XERROR>>
IFDEF XY8E < IFNZRO XY8E&700-500 <XYERR,XERROR>>
IFNZRO TOTSLOT&7600 <SLTERR,XERROR	/SORRY, THAT'S TOO MUCH >
IFDEF RFCLOCK <
 IFNZRO SYS-TIMER&4000 <RFCERR,XERROR>>
IFZERO FIELDS-1 <NOCORE, XERROR>
IFZERO BGFLDS-1 <NOCORE, XERROR>
IFZERO BGFLDS-2 <
 IFNZRO BGCORE-2 <NOCORE, XERROR>>
/********************************************************
/***************** P A G E   Z E R O ********************
/********************************************************

XLIST -LZERO-1&XLISTX
	FIELD 0
	*0

///INTERRUPT ENTRY POINT
	0		///JUST FOR FUN
	JMP INT		///
/MONITOR CALLING SEQUENCE:
/
/	TAD AC
/	JMS MONITOR
/	   FUNCTION (OPTIONS)
/	   PARAMETER		(OPTIONAL)
/	 ERROR RETURN		(OPTIONAL)
/	NORMAL RETURN
/
MONITOR,0		/MONITOR ENTRY POINT
	DCA MONAC	/SAVE CALLERS AC
	TAD MYCDF	/INDICATE FROM WHICH FIELD WE COME
C6202,	CIF 0		/PREPARE JUMP TO TRUE MONITOR CODE
	JMP I .+1	/GO !
	XMONITR		/ADDRESS OF TRUE MONITOR CODE
IFNZRO .-10 <ZEROER, XERROR>
*10
AUTO10,	0	/
AUTO11,	0	/
AUTO12,	0	/
AUTO13,	0	///*** INTERRUPT ROUTINES ONLY ! ***
AUTO14,	0	/
AUTO15,	0	/
AUTO16,	0	/
AUTO17,	0	/
/GENERAL STORAGE LOCATIONS FOR THE USER AND THE MONITOR
X,	CDF CIF BGFLD	/INITIALISATION
ZTEM1,	JMP I ZTEM2
ZTEM2,	PWRUP
ZTEM3,	0
ZTEM4,	0
ZTEM5,	0
ZTEM6,	0
ZTEM7,	0
BASE,	0	/BASE REGISTER FOR 'SETBASE', 'GET' AND 'PUT'

INTAC,	0	///SAVED AC DURING INTERRUPT PROCESSING
INTFLD,	0	///SAVED FLAGS DURING INTERRUPT PROCESSING
EVENTFL,0	///SIGNIFICANT EVENT FLAG

ZMYCDF,	MYCDF	/POINTER TO 'CDF THISFIELD'
ZMYCIF,	MYCIF	/POINTER TO 'CIF THISFIELD'
ZMYCDIF,MYCDIF	/POINTER TO 'CDF CIF THISFIELD'
ZSOFINT,SOFINT	///GENERATE SOFT INTERRUPT
ZFSTEXT,FSTEXT	///IMMEDIATE RETURN FROM INTERRUPT
/USEFULL CONSTANTS
/C1,	1
C2,	2
C3,	3
C4,	4
C7,	7
C17,	17
C37,	37
C70,	70
C77,	77
C100,	100
C177,	177
C200,	200
C212,	212
C215,	215
C240,	240
C260,	260
C3700,	3700
C6201,	6201
M1000,
C7000,	7000
M400,
C7400,	7400
M215,	-215
C7600,
M200,	-200
C7700,
M100,	-100
C7770,
M10,	-10
C7771,
M7,	-7
C7774,
M4,	-4
C7775,
M3,	-3
C7776,
M2,	-2
C7777,
M1,	-1
/ABORT ROUTINE:
/
/	JMS ALARM	/ABORT CURRENT TASK
/
ALARM,	0
C6203,	CDF CIF 00
	JMP I .+1
	ALARM0

/CHANGE DATA FIELD TO AC 6-8: CDTOAC
CDTOAC=JMS .
	0
	AND C70
	TAD C6201
	DCA .+1
XACCDF,	 CDF
	JMP I .-5

/CHANGE DATA FIELD TO THE CURRENT INSTRUCTION FIELD
IFDEF PROTOT <
	CDTOIF=JMS .
	0
MYCDF,	CDF 00		/ADAPTED BY POWERUP FOR EACH FIELD
	JMP I .-2	/SET DF TO THIS FIELD >
IFNDEF PROTOT <
IFZERO BGMAX <
	CDTOIF=JMS .
	0
MYCDF,	CDF 00		/ADAPTED BY POWERUP FOR EACH FIELD
	JMP I .-2	/SET DF TO THIS FIELD >
IFNZRO BGMAX <
CDTOIF=6200		/NEW HARDWARE INSTRUCTION IN MMU !
MYCDF,	CDF 00		/ADAPTED BY POWERUP FOR EACH FIELD >>
MYCIF,	CIF 00		/ADAPTED BY POWERUP
MYCDIF,	CIF CDF 00	/FOR EACH FIELD

/THE DEFER ROUTINE DOES AN EXTRA INDIRECT REFERENCING CYCLE
/
DEFER,	0		/ROUTINE TO FETCH CONTENTS OF LOCATION
	DCA X		/ADDRESSED BY AC
	TAD I X		/*** USES X ! ****
	JMP I DEFER
/*****************************************************************
/************* END OF COMMON PAGE ZERO ***************************
/*****************************************************************

COMPNT=.	/FROM THIS POINT ON, ALL LOCATIONS IN ALL FOREGRND
		/FIELDS OTHER THEN 00 ARE FREE FOR USE BY TASKS.

DOTF00=.
DOTF10=.
DOTF20=.
DOTF30=.
DOTF40=.
DOTF50=.
DOTF60=.
DOTF70=.

HNGCNT,	0	///INTERRUPT LOOP DETECTOR COUNTER
ZHRDINT,HRDINT	///COMMON INTERRUPT PROCESSOR
ZBREAKR,BREAKR	///KEYBOARD BREAK CHARACTER DETECTION ROUTINE
ZDISPATCH,DISPATCH /DISPATCHER
IFNZRO BGMAX <
XJOB,	BG1	/POINTER TO REGISTERS OF DEFAULT JOB
LJOB,	BG1	/PNTR TO REGISTERS OF CURRENT LONG BG
SJOB,	BG1	/PNTR TO REGISTERS OF CURRENT INTERACTIVE BG >
CURTSK,	0	/HAS  3 MEANINGS: =0 THERE IS NO TASK
		/RUNNING; LT 0:FOREGROUND TASK RUNNING;
		/GT 0:BACKGROUND JOB RUNNING.
CONTAB,	ZBLOCK INTDEV-1	/CONNECTED INTERRUPT ADDRESSES
*CONTAB+TIMER-1
	CLKINT		///LINECLOCK INTERRUPT HANDLER
*CONTAB+INTDEV-1	/END OF CONTAB

/ HEADS AND TAILS:
/
FHEAD,	LOADPT		/HEAD OF FREECORE CHAIN

IHEAD,	0		/INTERRUPT Q
ITAIL,	IHEAD

MHEAD,	0		/MAIN QUEUE
MTAIL,	MHEAD

CHEAD,	0		/CORE-WAITERS Q
CTAIL,	CHEAD
XLIST -LSKIPS-1&XLISTX
IFZERO .-200&4000 <ZEROER,XERROR /PAGE ZERO EXCEEDED ! >
*177
INT,	DCA INTAC	///
	JMP X		///' INITIALIZATION; BECOMES GTF
	DCA INTFLD	///
SKP0,	CLA CLL		///
		/TEST THE KEYBOARD FLAGS.
*KB1^4+INT
	KSF		///TEST KEYBOARD FLAG
	 JMP .+3	///
	KRB		///READ THE CHARACTER, CLEAR THE FLAG
	JMS I ZBREAKR	///GO LOOK FOR BREAK CHARACTER
IFDEF KL8E2 <
*KB2^4+INT
	6001+KL8E2	///TEST SECONDARY KEYBOARD FLAG
	 JMP .+3	///
	6006+KL8E2	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
IFDEF KL8E3 <
*KB3^4+INT		///TEST THIRD KEYBOARD
	6001+KL8E3	///
	 JMP .+3	///
	6006+KL8E3	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
IFDEF KL8E4 <
*KB4^4+INT		///TEST FOURTH KEYBOARD
	6001+KL8E4	///
	 JMP .+3	///
	6006+KL8E4	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
IFDEF KL8E5 <
*KB5^4+INT		///TEST FIFTH KEYBOARD
	6001+KL8E5	///
	 JMP .+3	///
	6006+KL8E5	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
IFDEF KL8E6 <
*KB6^4+INT		///TEST SIXTH KEYBOARD
	6001+KL8E6	///
	 JMP .+3	///
	6006+KL8E6	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
IFDEF KL8E7 <
*KB7^4+INT		///TEST SEVENTH KEYBOARD
	6001+KL8E7	///
	 JMP .+3	///
	6006+KL8E7	///READ CHARACTER, CLEAR FLAG
	JMS I ZBREAKR	///CHECK FOR BREAK CHAR >
	/TEST THE TELETYPE FLAGS.

*TTY1^4+INT
	TSF		///TEST TELETYPE FLAG
	 JMP .+3	///
	TCF		///CLEAR TELEPRINTER FLAG
	JMS I ZHRDINT	///
IFDEF KL8E2 <
*TTY2^4+INT
	6011+KL8E2	///TEST SECONDARY TELETYPE FLAG
	 JMP .+3	///
	6012+KL8E2	///CLEAR TTY FLAG
	JMS I ZHRDINT	/// >
IFDEF KL8E3 <
*TTY3^4+INT
	6011+KL8E3	///TEST TELETYPE 3 FLAG
	 JMP .+3	///
	6012+KL8E3	///
	JMS I ZHRDINT	/// >
IFDEF KL8E4 <
*TTY4^4+INT
	6011+KL8E4	///TEST TELETYPE 4 FLAG
	 JMP .+3	///
	6012+KL8E4	///
	JMS I ZHRDINT	/// >
IFDEF KL8E5 <
*TTY5^4+INT
	6011+KL8E5	///TEST TELETYPE 5 FLAG
	 JMP .+3	///
	6012+KL8E5	///
	JMS I ZHRDINT	/// >
IFDEF KL8E6 <
*TTY6^4+INT
	6011+KL8E6	///TEST TELETYPE 6 FLAG
	 JMP .+3	///
	6012+KL8E6	///
	JMS I ZHRDINT	/// >
IFDEF KL8E7 <
*TTY7^4+INT
	6011+KL8E7	///TEST TELETYPE 7 FLAG
	 JMP .+3	///
	6012+KL8E7	///
	JMS I ZHRDINT	/// >
IFNZRO BGMAX <
*TRAP^4+INT
	SINT		///TEST USER INTERRUPT FLAG
	 JMP .+3	///
	JMP I .+1	///
	RSAVE+1		///GOTO CENTRAL EMULATOR >
IFDEF LE8E <
*LPT^4+INT
IFZERO LE8E&1 <
	6661		///TEST LINEPRINTER FLAG
	 JMP .+3	///
	6662		///CLEAR PRINTER FLAG
	JMS I ZHRDINT	///
*LPTER^4+INT
IFZERO LE8E&400 <	///FOR NORMAL INTERFACE
	6663		///SKIP ON LINEPRINTER ERROR
	 JMP .+3	///
	6667		///DISABLE LPT INTERRUPTS >
IFNZRO LE8E&400 <	///FOR KL8E INTERFACE
	6651		///SKIP ON INPUT FLAG
	 JMP .+3	///
	6652		///CLEAR INPUT FLAG >
	JMS I ZHRDINT	/// >
IFNZRO LE8E&1 <
	6570		///SKIP ON FLAG
	 JMP .+3	///
	NOP		///
	JMS I ZHRDINT	/// >>
IFDEF PR8E <
*PTR^4+INT
	RSF		///TEST PAPERTAPE READER FLAG
	 JMP .+3	///
	RRB		///CLEAR READER FLAG
	JMS I ZHRDINT	/// >
IFDEF PP8E <
*PTP^4+INT
	PSF		///TEST PUNCHER FLAG
	 JMP .+3	///
	PCF		///CLEAR PUNCHER FLAG
	JMS I ZHRDINT	/// >
IFDEF TC08 <
*DTA^4+INT
	NOP		///HANDLER WILL DROP DTSF HERE
	 JMP .+3	///
	NOP		///CAN'T CLEAR FLAG
	JMS I ZHRDINT	/// >
IFDEF RFCLOCK <
*TIMER^4+INT
	6616		///READ DISK FLAGS
	SMA CLA		///PHOTOCEL ?
	 SKP		///
	JMP I CONTAB+TIMER-1 /// >
IFDEF SYRF08 <
*SYS^4+INT
	6623		///DISK INTERRUPT ?
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF SY3010 <
*SYS^4+INT
	DSDD		///DISK READY ?
	 JMP .+3	///NO
	JMP I .+1	///
	SYSINT		/// >
IFDEF NS3010 <
*DSK^4+INT
	6501		///(DSDD) DISK READY ?
	 JMP .+3	///NO
	6504		///(DCSR) CLEAR STATUS
	JMS I ZHRDINT	/// >
IFDEF SY3040 <
*SYS^4+INT
	DSDD		///DISK READY ?
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF NS3040 <
*DSK^4+INT
	6501		///(DSDD) DISK READY ?
	 JMP .+3	///NO
	6504		///(DCSR) CLEAR STATUS
	JMS I ZHRDINT	/// >
IFDEF SYDF32 <
*SYS^4+INT
	6622		///DISK INTERRUPT ?
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF SYRK8E <
*SYS^4+INT
	DSKP		///DONE FLAG ?
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF NSRK8E <
*DSK^4+INT
	6741		///(DSKP) DONE FLAG ?
	 JMP .+3	///
	6742		///(DCLR) DISK CLEAR
	JMS I ZHRDINT	/// >
IFDEF SYRL01 <
*SYS^4+INT
	6601		///SKIP IF DONE
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF SYRX02 <
*SYS^4+INT
	6755		///SKIP IF DONE AND CLEAR
	 JMP .+3	///
	CLA		///
	JMS I ZHRDINT	/// >
IFDEF NSRL01 <
*DSK^4+INT
	6601		///(RLSD) SKIP IF DONE
	 JMP .+3	///
	6600		///(RLDC) CLEAR DEVICE
	JMS I ZHRDINT	/// >
IFDEF SYRK08 <
*SYS^4+INT
	DSKD		///DONE ?
	 JMP .+3	///
	JMP I .+1	///
	SYSINT		/// >
IFDEF NSRK08 <
*DSK^4+INT
	6745		///(DSKD) DONE ?
	 JMP .+3	///
	6751		///(DCLA) CLEAR ALL
	JMS I ZHRDINT	/// >
IFDEF TM8E <
*MTA^4+INT
	6723		///
	 JMP .+3	///
	6725		///
	JMS I ZHRDINT	/// >
IFDEF TC58 <
*MTA^4+INT
	6701		///MTF OR ERROR FLAG ?
	 JMP .+3	///NEITHER
	6712		///YES, CLEAR FLAGS
	JMS I ZHRDINT	///AND SIGNAL EVENT >
IFDEF VC8E <
*DPL^4+INT
	6052		///
	 JMP .+3	///
	6051		///CLEAR FLAG
	JMS I ZHRDINT	/// >
IFDEF CR8E <
*CRD^4+INT
	6675		///INTERRUPT BEING GENERATED ?
	 JMP .+3	///
	6635		///READ CONDITIONS OUT: INHIBBIT INT
	JMS I ZHRDINT	///(USE CARDREADER CONNECTED) >
IFDEF CM8E <
*CRD^4+INT
	6542		///INTERRUPT FOR CARD DONE OR DATA ?
	 JMP .+3	///
	6540		///INHIBIT INTERRUPT ( 2 INSTR. CLEAR ! )
	JMS I ZHRDINT	///(USE MARK-SENSE READER CONNECTED) >
IFDEF DK8EP <
IFDEF DK8EA <
*CLOCK^4+INT		/// >
IFDEF DK8EB <
*CLOCK^4+INT		/// >
IFDEF DK8EC <
*CLOCK^4+INT		/// >
IFDEF DKC8AA <
*CLOCK^4+INT		/// >
IFNDEF DK8EA < IFNDEF DK8EB < IFNDEF DK8EC < IFNDEF DKC8AA <
*TIMER^4+INT		/// >>>>
	DK8EP+6001	///CLOCK INT ?
	 JMP .+3	///
	DK8EP+6005	///
IFNDEF DK8EA < IFNDEF DK8EB < IFNDEF DK8EC < IFNDEF DKC8AA <
	JMP I CONTAB+TIMER-1 /// >>>>
IFDEF DK8EA <
	JMS I ZHRDINT	/// >
IFDEF DK8EB <
	JMS I ZHRDINT	/// >
IFDEF DK8EC <
	JMS I ZHRDINT	/// >
IFDEF DKC8AA <
	JMS I ZHRDINT	///THIS IS A REAL CLOCK INTRPT >>
IFDEF DK8EA <
*TIMER^4+INT
	6003+DK8EA	///SKIP ON CLOCK FLAG AND CLEAR FLAG
	 JMP .+3	///
	6001+DK8EA	///ENABLE INTERRUPTS FOR SURE
	JMP I CONTAB+TIMER-1 ///THIS IS A REAL CLOCK INTERRUPT >
IFDEF DK8EB <
*TIMER^4+INT
	6001+DK8EB	///SKIP ON CLOCK FLAG AND CLEAR FLAG
	 JMP .+3	///ETH CLOCK
	6003+DK8EB	///ENABLE INTERRUPTS FOR SURE
	JMP I CONTAB+TIMER-1 ///THIS IS A REAL CLOCK INTERRUPT >
IFDEF DK8EC <
*TIMER^4+INT
	DK8EC+6003	///SKIP ON CLOCK FLAG AND CLEAR FLAG
	 JMP .+3	///
	DK8EC+6001	///ENABLE INTERRUPTS FOR SURE
	JMP I CONTAB+TIMER-1 ///THIS IS A REAL CLOCK INT >
IFDEF DKC8AA <
*TIMER^4+INT
	DKC8AA+6007	///LINE CLOCK FLAG ?
	 JMP .+3	///
	DKC8AA+6006	///CLEAR THE CLOCK FLAG
	JMP I CONTAB+TIMER-1 /// >
IFDEF KP8E <
*POWER^4+INT
	6102		///SKIP ON POWER LOW
	 JMP .+3	///
	HLT		///NOT YET IMPLEMENTED
	NOP		/// >
IFDEF XY8E <
*PLOT^4+INT
	XY8E+6001	///SKIP ON PLOTTER FLAG
	 JMP .+3	///
	XY8E+6002	///CLEAR PLOTTER FLAG
	JMS I ZHRDINT	/// >
IFDEF AX08 <
*AX08XT^4+INT
	6321		///SKIP ON CRYSTAL CLOCK FLAG
	 JMP .+3	///SHOULD NOT BE ENABLED
	6352		///CLEAR XTAL CLOCK FLAG
	JMP I ZFSTEXT	///100 MICROSEC IS REALLY TOO FAST
*AX08RC^4+INT
	6341		///SKIP ON RC CLOCK
	 JMP .+3	///
	6354		///CLEAR RC-FLAG
	JMS I ZHRDINT	///
*AX08AD^4+INT
	6332		///SKIP ON ADC DONE
	 JMP .+3	///
	6362		///READ ADC TO CLEAR FLAG
	JMS I ZHRDINT	///
*AX08ER^4+INT
	6322		///SKIP ON ADC TIMING ERROR
	 JMP .+3	///
	6351		///CLEAR ERROR FLAG
	JMP I ZFSTEXT	///DON'T USE DISCONNECTED
*AX08SM^4+INT
	6335		///READ AND CLEAR SMITT TRIGGERS
	AND C7400	///MASK OF LEVEL INPUTS
	SZA		///SMITT TRIGGERS FIRED ?
	 JMS I ZHRDINT	///YES >
IFDEF TONCLK <		///SPECIAL FYSIOLOGY CLOCK
*CLOCK^4+INT
	6161		///SKIP ON SPECIAL CRYSTAL CLOCK
	 JMP .+3	///
	6162		///CLEAR FLAG
	JMS I ZHRDINT	/// >
IFDEF AD8EA <
*ADC^4+INT
	6534		///SKIP ON A/D DONE FLAG
	 JMP .+3	///
	6533		///CLEAR FLAG, READ BUFFER
	JMS I ZHRDINT	///BETTER US IT CONNECTED >
IFDEF DP8E <
*DP8ECD^4+INT
	6400		///SKIP ON CHARACTER DETECT FLAG
	 JMP .+3	///
	6401		///CLEAR DP8E (USE CONNECTED !)
	JMS I ZHRDINT	///
*DP8ERO^4+INT
	6402		///RECIEVE WC OVERFLOW
	 JMP .+3	///
	6401		///CLEAR DP8E
	JMS I ZHRDINT	///
*DP8ETO^4+INT
	6403		///TRANSMIT WC OVERFLOW
	 JMP .+3	///
	6401		///CLEAR DP8E
	JMS I ZHRDINT	///
*DP8ERG^4+INT
	6410		///SKIP ON RING FLAG
	 JMP .+3	///
	6401		///CLEAR DP8E
	JMS I ZHRDINT	///
*DP8ECA^4+INT
	6411		///SKIP ON CARRIER ON/OFF
	 JMP .+3	///
	6401		///CLEAR DP8E
	JMS I ZHRDINT	///
*DP8EBE^4+INT
	6416		///SKIP ON BUS ERROR
	 JMP .+3	///
	6401		///
	JMS I ZHRDINT	/// >
IFDEF MF8E <
*DPL^4+INT
	6571		///SKIP ON SCOPE FLAG, CLEAR FLAG
	 JMP .+3	///
	NOP		///
	JMS I ZHRDINT	/// >
IFDEF KLPLOT <
*PLOT^4+INT
	KLPLOT+6001	///SKIP ON OUTPUT FLAG
	 JMP .+3	///
	KLPLOT+6002	///CLEAR OUTPUT FLAG
	JMS I ZHRDINT	/// >
IFDEF DR8EA1 < IFDEF IREG1 <
*IREG1^4+INT
	DR8EA1+6001	///SKIP ON INPUT FLAG
	 JMP .+3	///
	DR8EA1+6000	/// ???
	JMS I ZHRDINT	/// >>
IFDEF DR8EA2 < IFDEF IREG2 <
*IREG2^4+INT
	DR8EA2+6001	///SKIP ON INPUT FLAG
	 JMP .+3	///
	DR8EA2+6000	/// ???
	JMS I ZHRDINT	/// >>
IFDEF OLINK <
*LINK^4+INT
	OLINK+6001	///SKIP IF READY
	 JMP .+3	///NOT READY
	OLINK+6000	///CLEAR OMNILINK
	JMS I ZHRDINT	///AND SIGNAL EVENT >
IFDEF KLEXTR <
*EXTR^4+INT
	KLEXTR+6015	///INTERRUPT PENDING ?
	 JMP .+3	///
	KLEXTR+6005	///DISABLE INTERRUPT
	JMS I ZHRDINT	/// >
IFDEF SCV <
*SCHP^4+INT
	SCV+6002	///FLAG ?
	 JMP .+3
	SCV+6003	///YES, CLEAR FLAG
	JMS I ZHRDINT	/// (CONNECTED) >
IFDEF VENUS <
*VENUSI^4+INT
	VENUS+6001	///INPUT FLAG ?
	 JMP .+3	///
	VENUS+6002	///CLEAR INPUT FLAG
	JMS I ZHRDINT	///
*VENUSO^4+INT
	VENUS+6011	///OUTPUT FLAG ?
	 JMP .+3	///
	VENUS+6012	///CLEAR FLAG
	JMS I ZHRDINT	/// >
IFDEF DVM <
*DVMHP^4+INT
	DVM+6011	///DVM FLAG ?
	 JMP .+3
	DVM+6013	///CLEAR DVM
	JMS I ZHRDINT	/// (MUST USE CONNECTED)
*DVMERR^4+INT
	DVM+6012	///DVM ERROR FLAG ?
	 JMP .+3
	DVM+6013	///CLEAR DVM
	JMS I ZHRDINT	/// (WILL GIVE TIMOUT ON DONE)
*DVMCNT^4+INT
	DVM+6000	///DVM CNT FLAG ?
	 JMP .+3
	DVM+6001	///CLOCK STATUS TO AC, CLEAR
	JMS I ZHRDINT	/// >
IFDEF Z80 <
*Z80IN^4+INT
	Z80+6001	///INPUT FLAG ?
	 JMP .+3	///
	Z80+6002	///CLEAR INPUT FLAG
	JMS I ZHRDINT	///
*Z80OUT^4+INT
	Z80+6011	///OUTPUT FLAG ?
	 JMP .+3	///
	Z80+6012	///CLEAR FLAG
	JMS I ZHRDINT	/// >
IFDEF KL8A1 <
*MUX^4+INT
	CLL		///ZERO LINK SIGNALS KL8A1
	KL8A1+6001	///BRANCH ON KL8A1
IFDEF KL8A2 <
	STL		///SET LINK SIGNALS KL8A2
	KL8A2+6001	///BRANCH ON KL8A2 >
IFNDEF KL8A2 <
	SKP		///HURY TO NEXT SKIP
	NOP		/// >>
IFDEF RX01 <
*RXA^4+INT
	RX01+6005	///SKIP IF FLOPPY DONE
	 JMP .+3	///
	NOP		///
	JMS I ZHRDINT	/// >
IFDEF RX02 <
*RXA^4+INT
	RX02+6005	///SKIP IF FLOPPY DONE
	 JMP .+3	///
	NOP		///
	JMS I ZHRDINT	/// >
IFDEF UDEV1 <
*DEV1^4+INT
	SKPDV1		///SKIP-IOT
	 JMP .+3	///
	CLRDV1		///CLEAR-IOT
	JMS I ZHRDINT	/// >
IFDEF UDEV2 <
*DEV2^4+INT
	SKPDV2		///SKIP-IOT
	 JMP .+3	///
	CLRDV2		///CLEAR-IOT
	JMS I ZHRDINT	/// >
IFDEF UDEV3 <
*DEV3^4+INT
	SKPDV3		///SKIP-IOT
	 JMP .+3	///
	CLRDV3		///CLEAR-IOT
	JMS I ZHRDINT	/// >
IFDEF UDEV4 <
*DEV4^4+INT
	SKPDV4		///SKIP-IOT
	 JMP .+3	///
	CLRDV4		///CLEAR-IOT
	JMS I ZHRDINT	// >
IFDEF KIMIO <
*KIM^4+INT
	6341		///INPUT FROM KIM ?
	 JMP .+3	///NO
	6342		///Y: CLEAR FLAG
	JMS I ZHRDINT	///
	6351		///OUTPUT TO KIM DONE ?
	 JMP .+3	///NO
	6352		///Y:CLEAR FLAG
	JMS I ZHRDINT	/// >
/^^^^^^ INSERT NEW SKIPCHAIN ELEMENTS HERE ^^^^^^^^^^^^^^^^
/NOW COME A FEW THINGS AT THE VERY END OF THE SKIPCHAIN:
	*SKPDEV^4+INT

			///TRY TO KILL ILLEGAL INTERRUPTS -
IFDEF TC08 <6766	///DISABLE TC08 INTERRUPTS AND KILL FLAGS >
IFDEF DKC8AA <6103	///CLEAR 8/A POWER FAIL FLAG >
	JMP I ZFSTEXT	///
O=52	/SPACE FOR CLOCK HANDLER
O=O+21		/BREAK ROUTINE FOR CONSOLE TERMINAL
IFDEF KL8E2 <O=O+15>
IFDEF KL8A1 <O=O+44+7>
IFDEF KL8A2 <O=O+14>
IFNZRO .&177+O&200 <PAGE >

CLKINT,	CLA CLL		///CLOCK INTERRUPT HANDLER
	TAD TIME	///GET NUMBER OF MILLISEC'S
	TAD (MSEC	///ADD ONE CLOCK TICK
	DCA TIME	///AND UPDATE MSEC COUNTER
	SNL		///OVERFLOW ?
	 JMP CLKIN1	///NO, READY
	TAD (-MSEC^HWTICK ///YES, RESET TO -1000 (DECIMAL)
	DCA TIME	///
	ISZ TIME+1	///INCREMENT SECONDS COUNTER
	 JMP CLKIN1	///NO OVERFLOW, READY
		 DECIMAL
	TAD (-60    /	///RESET SECONDS TO -60 (DECIMAL)
	DCA TIME+1  /	///
	ISZ TIME+2  /	///INCREMENT MINUTES COUNTER
	 JMP CLKIN1 /	///NO OVERFLOW, READY
	TAD (-60    /	///RESET MINUTES COUNTER TO -60
	DCA TIME+2  /	///
	ISZ TIME+3  /	///INCREMENT HOURS COUNTER
	 JMP CLKIN1 /	///NO OVERFLOW, READY
	TAD (-24    /	///MIDNIGHT ! RESET HOURS TO -24
		  OCTAL
	DCA TIME+3	///(DECIMAL)
	CDF 10		///DATE IS IN FIELD 10
	TAD I (OS8DATE	///DATE IN OS8 FORMAT
	TAD (10		///ADD ONE DAY (MONTH'S OF 32 DAY'S)
	DCA I (OS8DATE	///
CLKIN1,	CDF 0		///
	ISZ I (TIMER^2+HRDLST ///
	JMP I ZFSTEXT	///
	TAD (TIMER	///
INSOF,	JMS I ZSOFINT	///START DIAGNOSTIC TIMER TASK
	   0		///STATUS 0

	 DECIMAL
MSEC=1000%HWTICK    /
TIME,	-MSEC^HWTICK/	///MILLISECONDS-1000
	-60	    /	///SECONDS-60
	-60	    /	///MINUTES-60
	-24	    /	///HOURS-24
	OCTAL
BREAKR,	0		///ROUTINE CHECKS FOR BREAKCHAR INPUT
	SNA		///IGNORE NULL'S
	 JMP I ZFSTEXT	///
	AND C177	///
	TAD C200	///
	DCA BRK1	///STORE THE CHARACTER
	TAD BRK1	///NOW PICK IT UP AGAIN AND
	TAD (-BRKCHR	///COMPARE WITH THE SYSTEMS BREAK CHAR.
	SZA CLA		///IS IT OR NOT ?
	 JMP BREAK1	///IT'S NOT
IFDEF KL8E2 <
	TAD BREAKR	///IT IS. COMPUTE NAME OF THIS KB HANDLER
	KBBASE=KB1^4+INT+4
	TAD (-KBBASE	///
	CLL RTR		/// DEVIDE BY 4
	TAD ("K^100+"1&3777 ///MAKE PROPER TASK NAME
	DCA BRK3	///AND PASS IT AS STATUS >
	JMS I ZSOFINT	///SIGNAL EVENT ZERO
BRK3,	   "K^100+"1&3777 ///STATUS=NAME OF HANDLER TASK
BREAK1,	IFDEF KL8E2 <
	TAD BREAKR	///COMPUTE EVENT # FOR THIS KB
	TAD (-KBBASE	///
	CLL RTR		///DEVIDE BY 4 >
	TAD (KB1	///OFFSET FROM EVENT OF FIRST KB
	JMS I ZSOFINT	///SIGNAL EVENT WITH CHAR AS STATUS
BRK1,	   0		///STATUS=CHARACTER

IFDEF KL8A1 <
IFNDEF KL8E2 <KL8NAM="K^100+"2&3777>
IFDEF KL8E2 <KL8NAM="K^100+"3&3777>
IFDEF KL8E3 <KL8NAM="K^100+"4&3777>
IFDEF KL8E4 <KL8NAM="K^100+"5&3777>
IFDEF KL8E5 <KL8NAM="K^100+"6&3777>
IFDEF KL8E6 <KL8NAM="K^100+"7&3777>
IFDEF KL8E7 <KL8NAM="K^100+"8&3777>
/DISPATCH TABLE FOR KL8A(S)
	*.+10&7770	/MUST START AT XXX0
KL8TAB,	JMP KL8ATT
	JMP KL8ATT
	JMP KL8ATT
	JMP KL8ATT
	JMP KL8AKB
	JMP KL8AKB
	JMP KL8AKB
	JMP KL8AKB

KL8ATT,
IFDEF KL8A2 <SZL	///WHICH KL8A ?
	 TAD (MUX2TT-MUX1TT ///SECOND ONE, ADJUST EVENT # >
	TAD (MUX1TT	///COMPUTE EVENT # AND POST EVENT
	JMS I ZSOFINT	///
	   0		///STATUS=0
KL8AKB,
IFDEF KL8A2 <
	SZL		///WHICH KL8A ?
	TAD (MUX2KB-MUX1KB ///SECOND ONE, ADJUST EVENT # >
	TAD (MUX1KB	///
	DCA KL8NUM	///EVENT # FOR THIS KB
IFDEF KL8A2 <
	SZL		///MAKE SURE YOU READ THE PROPER THING
	 KL8A2+6005	///READ THE CHARACTER
	SNL		///AND JUST ONE OF THESE >
	 KL8A1+6005	///READ THE CHARACTER
	AND (377	///DROP LINE NUMBER
	SNA		///NULL ?
	 JMP I ZFSTEXT	///YES, QUIT
	AND C177	///
	TAD C200	///FORCE PARITY ON
	DCA KL8CHR	///AND STORE AWAY
	TAD KL8CHR	///NOW SEE IF IT WAS BREAK
	TAD (-BRKCHR	///
	SNA CLA		///IS IT ?
	 JMP KL8BRK	///YES, WAKE CD
	TAD KL8NUM	///NO, GET EVENT #
	JMS I ZSOFINT	///AND CALL OUT EVENT FOR THIS KB
KL8CHR,	   0		///WITH CHAR AS STATUS
KL8BRK,	TAD KL8NUM	///YES, COMPUTE NAME OF HANDLER TASK
IFDEF KL8A2 <
	SNL		///LINK HAS BEEN COMPLEMENTED !
	 TAD (MUX1KB-MUX2KB+4 ///ADJUST FOR SECOND KL8A >
	TAD (KL8NAM-MUX1KB ///
	DCA KL8NUM	///
	JMS I ZSOFINT	///CALL OUT EVENT 0
KL8NUM,	   0		///WITH HANDLER TASK NAME AS STATUS
			///END OF IFDEF KL8A1 >

PAGE			/RESERVE A LOT OF ROOM FOR LONG SKIPCHAINS
/ENTRYPOINT TO GIVE A SOFT INTERRUPT. ENTER WITH:
/	IOF		///
/	TAD (SLOT NUMBER///
/	CDF CURRENT FIELD///
/	CIF 00		///
/	JMS I ZSOFINT	///
/	   STATUS
/
/THE STATUS WILL BE RETURNED TO THE TASK AFTER A WAIT

SOFINT,	0		///
	CLL RAL		///
	AND C177	///
	TAD (HRDLST	///
	DCA HRDINT	///
	AC3777		///
	AND I SOFINT	///FETCH STATUS (MUST BE POSITIVE ! )
	DCA SOFINT	///
	CDF 0		///
	TAD SOFINT	///FETCH STATUS
	JMP HRD2	///

/THIS IS THE COMMON INTERRUPT HANDLER WHICH TRANSLATES A
/HARDWARE INTERRUPT INTO A SOFTWARE EVENT. THE EVENT NUMBER IS
/COMPUTED FROM THE CALL-ADDRESS OUT OF THE SKIPCHAIN. EVENT-STATUS
/IS ZERO

HRDINT,	0		///COMPUTE DEVICE # FROM RETURN
	CLA		///YOU NEVER KNOW
	DCA SOFINT	///CLEAR STATUS
	TAD HRDINT	///
HRD1,	TAD (-SKP0	///
	CLL RAR		///DEVIDE BY 2
	TAD (HRDLST	///AC IS DEVICE # *2
	DCA HRDINT	///
HRD2,	DCA I HRDINT	///
	ISZ HRDINT	///
	TAD I HRDINT	///
	SPA		///IOWAIT ?
	 JMP INT1	///YES
	CLA IAC		///AC:=1
	DCA I HRDINT	///MAKE SLOT "INTERRUPTED"
	JMP FSTEXT+1	///RESUME RUNNING PROGRAM
INT1,	TAD M3		///
	DCA I ITAIL	///SCHEDULE WAITER IN INTQ
	TAD I ITAIL	///
	DCA ITAIL	///
	DCA I ITAIL	///CLEAR THREAD
	DCA I HRDINT	///MAKE SLOT "FREE"
	AC0004		///
	TAD ITAIL	///
	DCA AUTO13	/// PTR TO AC OF WAITER
	TAD SOFINT	///FETCH STATUS
	DCA I AUTO13	///
	ISZ EVENTFL	///DON'T FORGET IF MORE INT'S
FSTEXT,	CDF 00		///SKIP DOESN'T HURT
			///JUMP INTO THE INTERRUPT-
	SRQ		///CHAIN ONLY WHEN NECESSARY.
	 JMP SKPEND	///NO MORE INTERRUPTS NOW
	ISZ HNGCNT	///ANOTHER INTERRUPT IS PENDING. TOO MUCH ?
	 JMP I (SKP0	///NO, REENTER THE SKIPCHAIN
	JMP I (HELP	///YES, EMERGENCY ! TRY TO RECOVER ...
SKPEND,	CLA CLL		///
	DCA HNGCNT	///RESET LOOP DETECTOR COUNTER
	TAD EVENTFL	///
	SNA CLA		///
	 JMP INTEXT+1	///NO EVENTS, RETURN TO MAIN PROGRAM.
	DCA EVENTFL	///RESET EVENTFLAG
	TAD CURTSK	///
IFZERO BGMAX <
	SPA CLA		///
	 JMP INTEXT+1	///DON'T INTERRUPT FG >
IFNZRO BGMAX <
	SPA		///
	 JMP INTEXT	///DON'T INTERRUPT FG
	SZA CLA		///
	 JMS I (RSAVE	///SAVE STATUS OF BG >
	ION		///
/THIS MUST BE FOLLOWED IMMEDIATELY BY DISPATCH,
/(WITHOUT A JMP), OR ELSE YOU WILL HAVE ERRORS
DISPATCH,DCA CURTSK	///SET IN NULLTSK MODE
	TAD IHEAD	/
	SZA		/INTQ ?
	 JMP DISP1	/
	TAD MHEAD	/
	SZA		/MAINQ ?
	 JMP DISP2	/
IFNZRO BGMAX <
	CDF 10		//
	TAD I SJOB	//LOOK AT STATUS OF INTERACTIVE BG
	SNA CLA		//RUNNABLE ?
	 JMP DISP3	//YES
	TAD I LJOB	//LOOK AT STATUS OF LONG JOB
	AND (-LONG-1
	SNA CLA
	 JMP DISP4	//YES
	TAD M10 /(-BGMAX //SET COUNTER FOR NUMBER OF BACKGROUNDS
	DCA ZTEM1	//
DISPLP,	TAD I XJOB
	AND (-LONG-1
	SNA CLA
	 JMP DISP5	//FOUND RUNNABLE BG
	TAD XJOB
	TAD (UNEXT
	JMS DEFER
	DCA XJOB
	ISZ ZTEM1	//ALL BG TESTED ?
	 JMP DISPLP	//NO, CYCLE >
NULL,	JMP NULL	//YES, WAIT......
DISP1,	TAD C3		/MAKE CURTSK
	DCA CURTSK	/
	CIF 00		///IOF
	TAD I IHEAD	///
	SZA		///Q EMPTY ?
	JMP .+3		///
	 TAD (IHEAD	///
	 DCA ITAIL	///ADJUST ITAIL
	DCA IHEAD	/
	JMP I (START	/

DISP2,	TAD C3		/
	DCA CURTSK	/
	TAD I MHEAD	/
	SZA		/
	JMP .+3		/
	 TAD (MHEAD	/
	 DCA MTAIL	/
	DCA MHEAD	/
	JMP I (START	/

IFNZRO BGMAX <
DISP3,	TAD SJOB
	JMP .+4		//
DISP4,	TAD LJOB
	SKP		//
DISP5,	TAD XJOB	//
	CIF 10		//
	JMP I (DISP6	//START HIM! >

INTEXT,	CLA		///
	TAD INTFLD	///
	RTF		///
	CLA		/// (WHY SO SILLY ?)
	TAD INTAC	///
	JMP I 0		///

PAGE
XLIST -LMONIT-1&XLISTX
/********************************************************
/**************   M O N I T O R   ***********************
/********************************************************

/PAGE ZERO ASSIGNMENTS:
MONPC=ZTEM2	/CALLERS PC
MONAC=ZTEM3	/CALLERS ACCUMULATOR
MONLDF=ZTEM4	/CALLERS LINK +	CDF
FUNCTION=ZTEM5	/FUNCTION WORD
PARAM=ZTEM6	/PARAMETER
NEWTSK=ZTEM7	/CURTSK	OF NEW TSK

/FUNCTION EQUATES:

PRECEDE=0000	/NO OPTIONS OR PARAMETERS
SIGNAL=0004	/OPTIONS:'RELEASE', 'HALT','SWPOUT', 'CLEAR'
		/PARAM=DEV#,AC=STATUS
HALT=0010	/OPTIONS:'RELEASE', 'SIGNAL', 'SWPOUT', 'CLEAR'
RESERV=20	/NO PARAM, NO OPTIONS; MAY BE COMBINED WITH RETURN
CALL=0024	/PARAM=NAME OR PCBP, OPTION: RELEASE, SWPOUT
RESTRT=0030	/PARAM=NAME OR PCBP
STOP=0034	/PARAM=NAME OR PCBP
RETURN=0040	/OPTIONS:'RELEASE',
		/'CLEAR, 'CONTINUE', 'SWPOUT'
WAIT=0044	/OPTIONS:'RELEASE','SWPOUT', PARAM=DEV #
REQBLK=0050	/PARAM=#PAGES
RELBLK=0054	/AC+DATAFLD POINT TO FIRST PAGE OF BUFFER
STALL=0064	/PARAM IS NUMBER OF TICKS. OPTIONS: RELEASE, SWPOUT
SUSPND=0070	/STOP CURRENT TASK, NO PARAM, NO OPTIONS
BREAK=0074	/PARAM IS TASK NAME; IF ZERO, TEST BREAK FLAG

/OPTION BITS:

CLEAR=1000
CONTINUE=0001
RELEASE=4000
SWPOUT=4002

/STANDARD COMBINATIONS:

EXIT=RETURN+CLEAR
RUN=CALL+CONTINUE
XMONITR,DCA MONCDF	/SAVE USERS CALLING FIELD
	TAD C6201
	RDF		/FETCH USERS DATAFIELD
	RAR		/ROTATE	IN LINK
	DCA MONLDF
MONCDF,	CDF		//CHANGE TO CALLERS FIELD
	TAD I (MONAC	//GET HIS AC INTO THIS FIELD
	DCA MONAC	//
	TAD I (MONITOR
	DCA MONPC
	TAD I MONPC	//FETCH FUNCTION WORD
	DCA FUNCTION
	ISZ MONPC
	TAD I MONPC	//FETCH PARAMETERWORD
	CDF 00
	DCA PARAM
	TAD FUNCTION
	CLL RTR
	AND C17		/STRIP OPTION BITS
	TAD (FUNTAB	/INDEX IN FUNCTION DISPATCH TABLE
	DCA ZTEM1
	TAD I ZTEM1
	DCA ZTEM1	/FETCH ENTRY ADDRESS
	JMP I ZTEM1	/GOTO FUNCTION CODING

/'RETURN' FUNCTION: OPTIONS: 'RELEASE', 'CLEAR', 'CONTINUE'
/THERE IS A RETURN ONLY WHEN 'CONTINUE IS REQUESTED
/NO ERRORRETURN

RETRN0,	TAD CURTSK
	TAD M4
	DCA ZTEM6	/POINTS	TO BLNK
	CLA CMA		/BCKLNK IS BIASED !
	TAD I ZTEM6
	SNA		/RETURN	FROM 'RUN' OR 'CALL' ?
	 JMP RETRN1	/'RUN', AC=0
	DCA NEWTSK
	JMS BLDNEW	/BUILD NEW CHECKPOINT FOR NEW TASK
	TAD NEWTSK
	JMS I (MAININ	/SCHEDULE NEW TASK
RETRN1,	TAD FUNCTION
	RTL
	SPA CLA		/'CLEAR' ?
	JMP .+3		/YES, ZERO BACKLINK
	CLA CMA		/SUBSTRACT ONE FROM BACKLINK
	TAD I ZTEM6	/TO REOPEN IT FOR PREVIOUS CALLER
	DCA I ZTEM6	/CLEAR BACKLINK
	JMS I (RELESE	/TEST FOR RELEASE OPTION
	TAD FUNCTION
	RAR
	SNL CLA		/'CONTINUE' ?
	 JMP I ZDISPATCH /NO
	ISZ I ZTEM6	/MAKE HIM BUSY AGAIN
	JMP MONRTN+1	/YES
MONRTN,	ISZ MONPC	/SKIP OVER ERRORRETURN
	TAD IHEAD
	SZA CLA		/IF INTERRUPT TASKS ARE WAITING ...
	 JMP I (PRECE	/... LET THEM GO FIRST.
	TAD MONLDF
	STL RAL		/LOAD LINK, MAKE CDF
	DCA MONCIF-1
	TAD MONCDF
	IAC		/MAKES A 'CIF'
	DCA MONCIF
	TAD MONAC	/LOAD AC
	CDF
MONCIF,	CIF
	JMP I MONPC	/DIRECT RETURN TO USER

/FUCTION 'WAIT': OPTIONS: 'RELEASE', 'SWPOUT'
/NO ERRORRETURN
/AFTER RETURN THE AC CONTAINS THE STATUS
/WAIT RETURNS WITH AC=0 IF ALL OK. HOWEVER, NORMALLY
/AC=STATUS:
/1:	THERE WAS SOMEBODY ALREADY WAITING:PROGR. ERROR
/2:	TIMED OUT
/4:	HARD ERROR

WAIT0,	ISZ MONPC	/THERE IS A PARAMETER INDEED
	TAD PARAM
	SPA		/NEGATIVE SLOT # IS NOP
	 JMP WAIT3	/CLEAR AC AND RETURN
	CLL RAL		/ * 2
	TAD (HRDLST	/INDEX IN HRDLST
	DCA X
	TAD X
	IAC
	DCA ZTEM1
	IOF		///NO TRICKERY HERE
	TAD I ZTEM1	///
	SPA		///SLOT ALREADY IN WAIT ?
	 JMP WAIT2	///YES
	CLL RAR		///
	SNL CLA		///IS SLOT 'INTERRUPTED' ?
	 JMP WAIT1	///NO
	DCA I ZTEM1	///YES,MAKE IT FREE
	ION		///
	TAD I X		///FETCH STATUS
	DCA MONAC	/DROP IN USERS AC
	JMP MONRTN+1	/BACK TO CALLER

WAIT1,	TAD CURTSK	///
	DCA I ZTEM1	///PUT SLOT IN 'WAIT'
	TAD MONAC	/// TIMEOUT VALUE
	DCA I X		///
	JMS BLDCUR	///
	ION		///
	JMS I (RELESE	/RELEASE OPTION
	JMP I ZDISPATCH	/WHO'S NEXT ?
WAIT2,	ACM2		///TAD (-PROGER-1
IFNZRO PROGER-1 <PROGRR,XERROR>
WAIT3,	CMA		/FOR NEG SLOTNO GIVE COMPLEMENT AS STATUS
	DCA MONAC	/
	JMP I (PRECE	/QUIETLY RETURN

BLDNEW,	0		/BUILD A NEW CHECKPOINT FOR NEWTSK
	TAD NEWTSK
	SMA		/TCBP MUST BE NEGATIVE !
	 HLT		/* DON'T ALLOW SYSTEM TO FORGET ERROR *
	DCA AUTO14	/SET UP	POINTER
	TAD MONLDF	/
	DCA I AUTO14	/PASS L	+ CDF OF CALLER
	TAD MONAC
	DCA I AUTO14	/AND PASS CALLERS AC
	JMP I BLDNEW	/RETURN

BLDCUR,	0		/BUILD NEW CHECKPOINT FOR CALLER
	TAD CURTSK
	SMA		/TCBP SHOULD BE NEGATIVE !
	 HLT		/* DON'T ALLOW SYSTEM TO FORGET ERROR *
	DCA AUTO14	/SET UP	POINTER
	TAD MONLDF
	DCA I AUTO14	/SAVE L	+ CDF
	TAD MONAC
	DCA I AUTO14	/SAVE AC
	TAD MONPC	/
	DCA I AUTO14	/SAVE PC
	JMP I BLDCUR	/RETURN

PAGE
/GETNEW PUTS THE TCB POINTER OF A TASK INDICATED BY
/PARAM IN NEWTSK AND RETURNS THE BACKLINK OF THIS TASK.
/IF PARAM IS POSITIF, PARAM IS TAKEN AS THE
/REAL NAME AND A SEARCH IS MADE THROUGH NAMLST,
/ELSE PARAM IS TAKEN AS THE TCBP. WHEN A NAME HAS TO BE
/SEARCHED, THE RESULT IS PLUGGED IN THE REQUEST TO AVOID
/REPEATED SEARCHES FOR THE SAME THING.

GETNEW,	0
	TAD PARAM	/NAME OR TCBP ?
	SPA
	 JMP GETN2	/TCBP, DON'T SERACH
	SNA
	 JMS ALARM	/NAME SHOULDN'T BE ZERO !
IFNDEF EAE <
	CIA
	DCA ZTEM1	/ >
IFDEF EAE <
	SWAB		/LOAD NAME IN MQ, SET MODE B >
	TAD (NAMLST-1
	DCA AUTO14	/INITIALISE POINTER
	TAD PARAM
	DCA I (LASTNM	/DROP NAME AT END OF NAME LIST
IFNDEF EAE <
GETN1,	TAD ZTEM1	/9.0 USEC SEARCH LOOP
	TAD I AUTO14	/COMPARE WITH NEXT ENTRY >
IFDEF EAE <
GETN1,	TAD I AUTO14	/7.6 USEC SEARCH LOOP
	SAM		/SUBSTRACT FROM MQ >
	SZA CLA
	 JMP GETN1	/MISMATCH
	TAD AUTO14	/MATCHED !
	TAD (-LASTNM	/
	SNA CLA		/FOUND AT END OF TABLE ?
	 JMP MONER1	/YES, NAME NOT IN SYSTEM
	TAD I (MONCDF
	DCA GETCDF	/CDF TO CALLERS FIELD
	TAD AUTO14
	TAD (-NAMLST	/COMPUTE INDEX IN NAMELIST
	CLL RAL		/MULTIPLY BY 8 (LENGTH OF TCB)
	RTL
	TAD (TCBTAB+4	/THIS IS THE CURTSK !
GETCDF,	CDF
	DCA I MONPC	//STORE IN USERS REQUEST
	TAD I MONPC	//
	CDF 00
GETN2,	DCA NEWTSK
	TAD NEWTSK
	TAD M4
	DCA ZTEM1	/POINTS	TO BLNK
	TAD I ZTEM1
	ISZ MONPC	/SKIP ERRORRETURN;OVFLO IMPOSSIBLE
	JMP I GETNEW
/FUNCTION 'CALL'
/ERRORRETURN IF NAME UNKNOWN OR TASK BUSY

CALL0,	JMS GETNEW
	SNA
	 JMP CALL1	/NOT BUSY
	CIA
	TAD CURTSK
	SZA CLA		/BUSY FOR ME ?
	 JMP MONERR	/NO
CALL1,	TAD FUNCTION	/RUN OR CALL ?
	RAR
	SNL CLA		/CONTINUE OPTION ?
	 JMP CALL2
	TAD CURTSK
	JMS MAININ	/RUN: SCHEDULE CALLER
	SKP CLA
CALL2,	TAD CURTSK
	IAC		/MAKE IT BUSY
	DCA I ZTEM1	/SET BACKLINK
	ISZ MONPC	/NORMAL RETURN
	JMS I (BLDCUR
	JMS I (BLDNEW
	ACM2		/AC:=-2
	TAD NEWTSK
	DCA ZTEM1	/POINTER TO 'SA'
	TAD I ZTEM1	/FETCH START ADDR
	DCA I AUTO14	/DROP IN PC (AUTO14 STILL
			/SET BY BLDNEW...)
	TAD NEWTSK
	JMS MAININ	/SCHEDULE NEW TASK
	JMS I (RELESE
	JMP I ZDISPATCH

MAININ,	0
	SMA		/TCBP SHOULD BE NEGATIVE !
	 HLT		/DON'T ALLOW SYSTEM TO FORGET ERROR *
	TAD M3		/MAKE PNTR TO THREAD
	DCA I MTAIL	/
	TAD I MTAIL	/
	DCA MTAIL
	DCA I MTAIL	/CLEAR THREAD
	JMP I MAININ	/RETURN

MONER1,	ISZ MONPC
MONERR,	CLA
PRECE,	JMS I (BLDCUR
SWPER1,	TAD CURTSK
	JMS MAININ	/SCHEDULE ERRORRETURN
	JMP I ZDISPATCH
START,	TAD I CURTSK	/STATUSBITS
	RTR
	SZL
	 JMP START1	/TASK HAS STOPBIT SET
	SPA		/TASK	IN CORE	?
	 JMP I (SWPIN	/NO
	RTL
START2,	AND C70
	TAD C6202
	DCA STACIF
	TAD CURTSK
	DCA AUTO14
	TAD I AUTO14	/L+CDF
	STL RAL		/LOAD LINK, MAKE CDF
	DCA STACDF
	TAD I AUTO14	/AC
	DCA ZTEM1
	TAD I AUTO14	/PC
/	SNA
/	 JMS ALARM	/PC=0 ??
	DCA ZTEM2
	TAD ZTEM1
STACDF,	CDF
STACIF,	CIF
	JMP I ZTEM2	/GO !

START1,	RAR
	STL RTL		/SET 'STOPPED'
	RAL
	DCA I CURTSK
	JMP I ZDISPATCH	/WHO'S NEXT ?
/FUNCTION 'STOP'
/ERRORRETURN: UNKNOWN NAME

STOP0,	JMS GETNEW
	CLA
	TAD I NEWTSK
	RTR
	STL RTL		/SET 'STOP'
	DCA I NEWTSK
	JMP I (MONRTN

PAGE
SUSPN0,	TAD I CURTSK
	AND C7771	/CLEAR STOP AND STOPPED
	TAD (6		/SET STOP AND STOPPED
	DCA I CURTSK
	JMS I (BLDCUR	/MAKE A CHECKPOINT
	JMP I ZDISPATCH	/

/FUNCTION 'RESTRT'
/ERRORRETURN: UNKNOWN NAME
RESTR0,	JMS I (GETNEW
	AC0004
	AND I NEWTSK
	SNA CLA		/WAS TASK ACTUALLY STOPPED ?
	 JMP REST1	/NO, CLEAR STOPBIT, DON'T SCHEDULE
	TAD NEWTSK
	JMS I (MAININ
REST1,	TAD I NEWTSK
	AND C7771	 /CLEAR 'STOP' AND 'STOPPED'
	DCA I NEWTSK
	JMP I (MONRTN

/FUNCTION RESERV
RESER0,	JMS I (RESRV	/GET HIM AN EVENT NUMBER
	 JMP I (STALL1	/BACKUP PC, PRECEDE
	DCA MONAC
	TAD FUNCTION
	BSW
	SPA CLA		/RETURN ?
	 JMP I (RETRN0	/THE REST IS LIKE RETURN
	JMP I (MONRTN+1	/IMMIDIATE RETURN TO CALLER
/FUNCTION 'SIGNAL' + 'HALT': OPTIONS 'RELEASE', 'CLEAR'
/FUNCTION 'SIGNAL'
/PARAM=DEV #, AC=STATUS

SIGHLT,
SIGNL0,	TAD PARAM
	AND C177	/DEFENCE !
	CLL RAL
	TAD (HRDLST	/INDEX IN HRDLST
	DCA ZTEM1
	AC3777		/JUST 11 BITS !
	AND MONAC	/FETCH STATUS
	IOF		///
	DCA I ZTEM1	///
	ISZ ZTEM1	///
	TAD I ZTEM1	///FETCH SLOT STATE
	SMA		///WAITING ?
	 JMP SIGNL1	///NO
	JMS I (MAININ	///YES, SCHEDULE WAITER
	AC0001		///
	TAD I ZTEM1	///
	DCA AUTO10	///POINTER TO AC IN TCB
	TAD MONAC	///FETCH STATUS
	DCA I AUTO10	///STORE IN WAITERS AC
	SKP		///
SIGNL1,	AC0001		///AC:=1
	ION		///
	DCA I ZTEM1	///MAKE SLOT INTERRUPTED/FREE
	TAD FUNCTION
	AND (HALT
	SNA CLA		/CHECK FOR 'HALT'
	 JMP I (MONRTN	/NO 'HALT'

/FUNCTION 'HALT: OPTIONS 'RELEASE', 'CLEAR'

HALT0,	TAD CURTSK
	TAD M4
	DCA ZTEM1
	TAD FUNCTION
	RTL
	SPA CLA		/CLEAR OPTION ?
	 JMP .+3	/YES
	ACM1		/NO, RESET BACKLINK TO NOT BUSY
	TAD I ZTEM1	/
	DCA I ZTEM1	/CLEAR THE BACKLINK
	JMS I (RELESE	/CHECK FOR RELESE OPTION
	JMP I ZDISPATCH
/REQUEST A NUMBER OF PAGES:
/PARAM=- NUMBER OF PAGES
/ON RETURN AC + DATAFIELD POINT TO FIRST PAGE

REQPA0,	ISZ MONPC	/THERE IS A PARAMETER
	TAD PARAM
	SPA		/PARAM MUST BE NEGATIVE !
	 JMS I (HOLE
	  JMP I (MONERR	/NOT SO MUCH AVAILABLE
	DCA ZTEM1
	ACM1
	TAD ZTEM1
	DCA AUTO10	/POINTS IN COREMAP
	JMP REQPA2
REQPA1,	ACM2		/AC:=-2
	DCA I AUTO10	/SET THIS PAGE OCUPIED
REQPA2,	ISZ PARAM
	 JMP REQPA1	/NEXT ONE PLEASE
	ACM1		/LAST SLOT := -1
	DCA I AUTO10
	TAD ZTEM1
	TAD (-CORMAP
	AND C37		/PAGEBITS
	BSW
	CLL RAL
	DCA MONAC	/POINTS TO FIRST WORD OF BLOCK
	TAD ZTEM1
	TAD (-CORMAP
	CLL RTR
	AND C70
	TAD C6201
	CLL RAR
	DCA MONLDF
	JMP I (MONER1	/RETURN WITH IMPLICIT PRECEDE
FUNTAB,	PRECE
	SIGNL0
	HALT0
	SIGHLT
	RESER0
	CALL0
	RESTR0
	STOP0
	RETRN0
	WAIT0
	REQPA0
	RELPA0
	RESER0
	STALL0
	SUSPN0
	BREAK0

PAGE
/RELEASE A COREAREA:
/MONAC IS ADDRESS IN FIRST PAGE OF AREA
/DATAFIELD IS FIELD OF AREA

RELPA0,	TAD MONLDF
	RAL
	AND C70
	CLL RTL
	DCA ZTEM1	/FIELD^40
	TAD I (MONCDF
	CLL RAR
	DCA MONLDF	/RESET USERS FIELD TO HIS
			/INSTRUCTION FIELD
	TAD MONAC
	AND C7600
	BSW
	CLL RAR		/
	TAD ZTEM1
	TAD (CORMAP
	DCA MONAC
	JMP .+4
	ISZ I MONAC
	 JMP RELPA1	/ERROR !
	ISZ MONAC
	ISZ I MONAC
	 JMP .-4
	DCA MONAC
	JMS I (RELSUB	/ACTIVATE WAITERS IN COREQ
	JMP I (MONRTN+1
RELPA1,	ACM2
	TAD I MONAC	/RESET MODIFIED LOCATION
	DCA I MONAC
	JMS ALARM	/ABORT THIS DIRTY BOY

ALARM0,	CLA CLL
	ION		/JUST FOR SURE
	TAD CURTSK
	DCA ERRTSK
	JMP I ZDISPATCH
ERRTSK,	0
BREAK0,	TAD PARAM	/
	SNA CLA		/SET OR TEST ?
	 JMP BRKTST	/TEST MY OWN FLAG
	JMS I (GETNEW	/WHO'S THAT ?
	CLA		/NOT INTERRESTED IN HIS BACKLINK
	TAD I NEWTSK	/GET HIS STATE WORD
	RAL		/AND SET
	STL RAR		/HIS BREAK FLAG
	DCA I NEWTSK	/
	JMP I (MONRTN	/AND CONTINUE THIS TASK

BRKTST,	TAD I CURTSK	/GET MY OWN STATE WORD
	SMA		/BREAK FLAG SET ?
	 ISZ MONPC	/NO, SKIP
	AND (3777	/CLEAR BREAK FLAG IN CASE IT WAS SET
	DCA I CURTSK	/
	JMP I (MONRTN	/AND CONTINUE PROCESSING

/MONITOR 'STALL' MAY BE ENTERED WITH PARAM G.T.0
/OR PARAM L.T.0
STALL0,	TAD PARAM
	SMA		/NEGATE IF POSITIVE
	 CIA
	SNA
	 ACM1		/MINIMUM DELAY IS ONE TICK
	DCA MONAC
	JMS RESRV
	 JMP STALL1	/NO MORE SLOTS AVAILABLE
	DCA PARAM
	JMP I (WAIT0
STALL1,	ACM2		/RESET CALLERS PROGRAM COUNTER SO
	TAD MONPC	/HE MAKES A SECOND TRY AFTER A
	DCA MONPC	/PRECEDE
	JMP I (PRECE
/RESRV RESERVES A FREE SLOT IN HRDLST
/THE INDEX IS RETURNED IN THE AC
/ZTEM REGISTERS REMAIN UNALTERED.
/
/	JMS I (RESRV
/	 JMP ERROR	/NO SLOTS AVAILABLE;AC=0
/	NORMAL RETURN	/AC=SLOT NUMBER
/
/NOTE: UNLIKE PREVIOUS VERSIONS, THE LINK IS NOT (!) PRESERVED.

RESRV,	0
	CLA CLL
	TAD (HRDLST+MAXDEV+MAXDEV
	DCA AUTO10	/POINTS TO FIRST ASSIGNABLE SLOT
	TAD (-MAXSLOT+MAXDEV
	DCA RESTM1
RES1,	TAD I AUTO10
	SNA CLA
	 JMP RES2
	ISZ AUTO10
	ISZ RESTM1
	 JMP RES1
	JMP RESEXT	/NO SLOT AVAILABLE
RES2,	ISZ RESRV
	TAD AUTO10
	DCA RESTM2
	AC0002
	DCA I RESTM2	/MAKE SLOT RESERVED (=2)
	TAD RESTM1
	TAD (MAXSLOT	/COMPUTE DEV #
RESEXT,	JMP I RESRV

RESTM1,	0		/TEMP COUNTER
RESTM2,	0		/PNTR TO SLOT TO BE RESERVED

IFNZRO BGMAX <
RSAVE,	0
	CDF 10		//GO SAVE COMPLETE MACHINE STATUS
	TAD I (BJOB	//
	DCA AUTO13	//
IFDEF EAE <
	SCA		//GET STEPCOUNTER IN AC
	BSW		//TO BITS 1-5
	SWP		//SWAP AC AND MQ
	DCA I AUTO13	//STORE MQ
/    MODE A     MODE B	//
     SCL        ASC	//
     7330       AC4000	//SET BIT 0 IF MODE B
	RIB		//GET VIRTUAL INSTRUCTION FIELD
	AND (4070	//IN BITS 6-8
	MQA		//STEPCOUNTER IN 1-5
	DCA I AUTO13	// >
IFNDEF EAE <
	SWP		//GET MQ IN AC
	DCA I AUTO13	//AND STORE AWAY
	RIB		//GET VIRTUAL INSTRUCTION FIELD
	DCA I AUTO13	// >
	TAD 0		//PC
	DCA I AUTO13	//
	TAD INTFLD	//
	DCA I AUTO13	//
	TAD INTAC	//
	DCA I AUTO13	//
	CDF 0		/
	SINT		/CALLED BY TRAP ?
	 JMP I RSAVE	/NO, RETURN
	CIF CDF 10	//
	JMP I (TRAPINT	//YES, ENTER CENTRAL EMULATOR >

PAGE