                 
executive routine part 2

/dispatch table for user

d7,	jmp tot	/io
	jmp ill	/illegal
	jmp wa	/wat
	jmp ra	/rpa
	jmp rb	/rpb
	jmp to	/tyo
	jmp ti	/tyi
	jmp pa	/ppa
	jmp pb	/ppb
	jmp di	/dia
	jmp db	/dba
	jmp dc	/dcc
	jmp da	/dra
	jmp bp	/bpt
	jmp ar	/arq
	jmp ds	/dsm
	jmp rr	/rrb
	jmp xe0	/proceed trap

/dispatch table for ID

d9,	jmp tot
	jmp .	/illegal
	jmp .	/wat
	jmp ra	/rpa
	jmp rb	/rpb
	jmp to	/tyo
	jmp ti	/tyi
	jmp pa	/ppa
	jmp pb	/ppb
	jmp di	/dia
	jmp loc	/dba=lock
	jmp dc	/dcc
	jmp unl	/dra=unlock
	jmp .	/bpt
	jmp ar	/arq
	jmp id3	/dsm
	jmp .	/rrb
	jmp .	/crock
                
                                
/entry from interrupts

tot,	rpf
	dio i pf1
	clf 7
	jsp srv
	jmp rm1
	stf 5
	jmp .-3

rm1,	0
	jmp pac	/get next user
	jsp cbk
pf1,	ior .
	lia
	lpf
rm3,	ad1
	lac 0
	lio 2
	jmp i 1

dms,	ior i jfm	/dismiss for io
	dac i jfm

wa,	cla	/dismiss this user
	dip i act
	lac i rf0	/release core fields
	dap . 2
	cla
	dip .
	lac i rf1
	dap . 3
	cli>>05<<swp
	spi
	dip .
wa1,	rpf
	dio i pf1
	clf 7

pac,	lac 0
	dac i ac1
	lac 1
	dac i pc1
	lac 2
	dac i io1
	rbe
	dio i be
pam,	lac i pf1
	and (23000
	sad (21000
	clc
	dip i jfm

pan,	tlf

	jsp bsc
	law i ber-aas 1
	dac pli
                
                                
pai,	cli	/advance to next user
	lar
	scn
	szs 60
	jmp 5600
	idx aw1
	sad (lio ber
	jmp par
	idx be
	idx act
	idx jfm
	idx rst
	jmp aw1

par,	law aas
	dap aw1
	law ber
	dap be
	law dmi
	dap act
	law jdm
	dap jfm
	law pbb
	dap rst
	jsp bsc
	jsp srv
	jmp aw1
	jmp .-2

pa6,	idx plj
	lia
	isp pli
	jmp pai
	spi
	jmp pai
	dzm plj
	dzm pli
	lio i act
	spi i
	jmp pai
	jmp pa5	/low priority activation

pli,	0
plj,	0

aw1,	lio .	/check this user
	lar
be,	lio .
	lbe
	lac onn
	xor csi
	and (177
	and i act
	sza
	jmp onf
	lac i act
	and onn
	sza i
	jmp pa6
	and cbi
	sza
	jmp ube
	law i 2
	sad pli
	jmp pa6
	jsp cbk
	dac iss
	sza i
	jmp pa6

be2,	law i ber-aas-1	/high priority activation
	add pli
	sad (aas-ber aas-ber
	law i ber-aas
	dac plj
                
                                
pa5,	clc	/run this user
act,	dip .

rst,	lac .
	sad ors
	jmp bg0	/same user that ran last time
	law rf1	/set up new user

rsv,	dap rsx	/set up variables
	lac i rst
	dap aw2
	add (1
	dap df1
	add (1
	dap rr0
	add (1
	dap pp0
	add (1
	dap rf0
	add (1
	dap uf1
	dap rf1
	add (1
	dap xe1
	add (1
	dap ac1
	add (1
	dap io1
	add (1
	dap pc1
	add (1
	dap pf1
	add (1
	dap di1
	spa
	jmp id1	/ID
	add (1	/user
	dap bp1
	add (1
	dap bp2
	add (1
	dap bp3
	law 600
	dap ids
	law (d7
	dap 3
rsx,	jmp .

id1,	add (4
	dap rf0
	add (1
	dap rf1
	add (1
	dap id0
	lac c2
	dac i xe1
	cla
	dap ids
	law (d9
	dap 3
	lac i rf1
	sza
	dap rf1
	jmp rsx

rf1,	lac .	/bring user into core
	sza i
	jmp 4k	/4k user
	spa	/8k user
	jmp 1ok	/field 1 is in core
rf0,	lac .	/field 1 on drum
	spa
	jmp 0ok	/field 0 is in core
	lac rf0	/both on frum
	lio (add
	jda p
	lac rf1
	lio (add i
	jda p
	jmp c01

0ok,	lio rf1
lc7,	xor (i
	swp
	jda p
lc8,	lac i rf0
	ral 5s
	lio (106666
	sma
c01,	lio (016666
	lac (add
	dip uc0
	dip uc1
	jmp lcc
1ok,	lac i rf0
	spa
	jmp lc8 1	/both fields in core
	lac i rf1
	lio rf0
	jmp lc7

4k,	lac i rf0
	spa
	jmp 4k1	/user in core
	lio (add
	lac uc0
	sza i
	jmp 4k1-3	/core 0 empty
	lac uc1
	sma
	lio (add i	/core 1 not busy
	lac rf0
	jda p
	lac i rf0
4k1,	dap 4k2
	ral 5s
	lio (166666
	sma
	lio (066666
	lac (add
4k2,	dip .

lcc,	tln
	ldc

ids,	skp .	/skip if user
	jmp id2
bgn,	lac i rst
	dac ors
	lio (6374
	sdl i
	sir 6s
	lac db	/(soq i

bge,	dac rm1
	lqn
pc1,	lac .
	dac 1
ac1,	lac .
	dac 0
io1,	lac .
	dac 2
aw2,	lio .
	la2
	spn
	scn
	lac iss
	jmp pf1

iss,	0	/sequence break for next user
ors,	0	/last user

bg0,	tln
	szf 5
	jmp bgn
	cli
	lac c1
	jmp bge	/infinite Q
                
                                
id2,	lac i rst
	ral 1s
	sma
	jmp bgn	/ID running
	law 2200	/ID starting
	dac t
	lac ac1
	dap . 2
	eem
	lac .	/move user variables
	dac i t	/into ID
	idx .-2
	idx t
	sas (2207
	jmp .-5
	xct rst
	ral 6s
	and (7
	dac i (2207
	lem
	lac (add
	dip i rst
	law 2210
	dip i jfm
	dac i pc1
	dzm i pf1
	jmp bgn

id3,	cla	/start user from ID
	dip i rst
	law 2200
	dac t
	lac ac1
	dap . 3
	eem
	lac i t	/move user variables
	dac .	/from ID
	idx .-1
	idx t
	sas (2207
	jmp .-5
	lem
	law i 400
	and i pf1
	lio 0
	sni i
	ior (400
	dac i pf1
	lac c1
	sni i
	dac i xe1
	lac i rf0
	dap . 2
	cla
	dip .
	lac i rf1
	dap . 3
	cli>>05<<swp
	spi
	dip .
	jmp pam

ill,	xct ids	/illegal instruction
	jmp id4-1	/ID running
	law 63

id5,	rar 6s	/start ID from user
	dip i rst
	jmp wa 2

	law 2211
id4,	dac 1
	jmp rm3

bp,	siw i	/bpt
	jmp ill
	lio 1
	dio t
	ril 1s
	eem
b0,	lac i t	/find it
	sad (bpt
	jmp b2
b1,	dap t
	ral 5s
	sma
	jmp b0
	lac i t
	spi i
	jmp b1
	dac t
	jmp b0

b2,	lac t	/found it
	and (77777
	lia
bp1,	sad .
bp2,	isp .
	jmp b3	/not primary,or count expired
bp3,	lac .	/multiple proceed
	dac i t
	lem
	rpf
	lai
	ior (400
	jmp pf1 1

xe0,	xct ids	/proceed trap
	jmp .	/ID
	xct i xe1
	jmp . 2
	jmp .	/should not trap
	lac i bp1
	dac t
	lio (bpt
	eem
	lac i t
	dio i t
	lem
	dac i bp3
	rpf
	lai
	and (-400
	jmp pf1 1

b3,	lem	/go to ID
	dio i bp1
	law 61
	jmp id5

ds,	law 62	/dsm
	jmp id5
                
                                
p,	0	/drum swap
	dap dx
	dio cf
	law uc0
	ril 5s
	spi
	law uc1
	dap u
	dap u1
	dzm dec
	lac i u
	sza
	jmp u1-1
	law i 7777
	and wf
	ral 6s
	add (sd-1
	dac wf
	dzm i wf
	jmp u1 1

	lac wf
u1,	dip i .
	dra
	lac i p
	dip rf
	lai
	add (30
	dap wf
	dap cf
	lac wf
u2,	lia
	lac cf
	dip i p
	dia
	lio rf
	dcc
	jmp dre
	lac p
u,	dap .
	lac rf
	sad (250000
	lac nwf
	dac wf
	lac u
	dap i p
	jsp srv
dx,	jmp .
	jmp .-2

nwf,	0	/new field for ID
rf,	0	/last read field
wf,	010000	/last write field
cf,	0	/last core field

uc0,	0	/user in core 0
uc1,	0	/user in core 1

onf,	xor onn	/turned on or off
	dac onn
	and i act
	sza
	jmp on
	scn
	jsp sat
	jsp if0+1
	ben
	psf
of2,	dzm i be
	cla
	dip i act
	dip i rst
	dzm i jfm
	jsp rsv
	lac i aw2
	and (377777
	xor kbw
	dac kbw
	dzm i aw2
	lac err
	dac i rr0
	dac i pp0
	lac i act
	cma>>05<<lia
	dac t1
	and rw
	dac rw
	lai
	and pw
	dac pw
	lai
	and xrw
	dac xrw
	jsp daf
	jsp dxe
	law i 1
	add uf1
	jda crl	/dismiss user field 0
	lac uf1
	jda crl	/dismiss user field 1
	idx bp3
	jda crl	/dismiss ID field
	idx bp3
	dzm i bp3	/and ID reference
	dzm ors
	jmp pa6

on,	dzm ors
	lac (add
	dip i rst
	jsp rsv
	jsp gaf	/get ID field
	jmp noc
	lac (lac
	dac i afp
	lac afn
	dac nwf
	lac afp
	dac t2
	law i 1
	add uf1
	dap on3-1
	lio uc0
	sni
	jmp on0
	lio uc1
	sni
	jmp on1
	jsp gaf	/get user field 0
	jmp noc-1
	lac (lac
	dac i afp
	lac afn
	dac .
on3,	lac (250000
	dac i rf0
	dzm iss
	jmp idc

on0,	dap uc0
	lac (add uc0
	jmp on3-1
on1,	dap uc1
	lac (add i uc1
	jmp on3-1

	dzm i t2
noc,	lac i act	/can' turn on
	cma>>05<<lia
	and onn
	dac onn
	lai
	and csi
	dac csi
	jmp pa6

crl,	0
	dap crn
	lac i crl
	sza i
	jmp crn
	spa
	jmp . 4	/core
	ral 6s	/drum
	and (77
	add (sd-1
	dap . 1
	dzm .
	dzm i crl
crn,	jmp .

ube,	dzm iss	/hit call
	xor cbi
	dac cbi
	law i 7777
	and i rst
	sad (add
	jmp idc	/ID
	clc	/user
	dip i act
	lac . 2
	dip i rst
	jmp be2

idc,	law 11
	add i rst
	dap . 2
	law 2212
	dac .
	jmp be2
                
                                
/drum error recovery

dre,	dra
	spi i
	jmp .	/not parity error
	isp dec
	jmp de9	/try again
	spq
	jmp u-1	/accept whatever was read
	lsm
	tsf
	clc 20
	iot 3
	law dem
	dap de1
de1,	lac .
	lio .+3
	rcl 6s
	jda de5
	sas .
	jmp de1+2
	idx de1
	sas (lac dec
	jmp de1
	cli
	jda de5
	lac rf
	rcl 3s
	sni i
	jda de5
	cli
	rcl 3s
	sni
	lio .+2
	jda de5
	clc 20
	jda de5
de2,	tsn
	law i 20
	dac dec
de9,	law 7777
	and wf
	jmp u2

de5,	0
	dap de4
	dzm dec
	dio de3
de0,	cks
	ril 2s
	isp dec
	jmp de2
	spi i
	jmp de0
	lio de3
	iot 3
	lac de5
de4,	jmp .
de3,	0

dem,	text .
drum parity error field.

dec,	0
                
                                
/consoles

aas,	205200	405200	505200	605200
ber,	0	0	0	0
dmi,	40	10	4	2
jdm,	0	0	0	0
pbb,	pb2	pb4	pb5	pb6

/console 2
pb2,	0	/i aw2 - assgt 2
	dd2	/i df1 - drum field table
	jmp ill	/i rr0 - reader switch
	jmp ill	/i pp0 - punch switch
	0	/i uf0 - user field 0
	0	/i uf1 - user field 1
	skp i	/i xe1 - proceed switch
	0	/i ac1 - ac
	0	/i io1 - io
	0	/i pc1 - pc
	0	/i pf1 - flags
	0	/i di1 - dia word
	0	/i bp1 - location of breakpoint
	0	/i bp2 - proceed count
	0	/i bp3 - instruction at breakpoint
	0	/ID field 0
	0	/ID field 1
	0	/i id0 - reference field

/console 4
pb4,	0	/i aw2 - assgt 2
	dd4	/i df1 - drum field table
	jmp ill	/i rr0 - reader switch
	jmp ill	/i pp0 - punch switch
	0	/i uf0 - user field 0
	0	/i uf1 - user field 1
	skp i	/i xe1 - proceed switch
	0	/i ac1 - ac
	0	/i io1 - io
	0	/i pc1 - pc
	0	/i pf1 - flags
	0	/i di1 - dia word
	0	/i bp1 - location of breakpoint
	0	/i bp2 - proceed count
	0	/i bp3 - instruction at breakpoint
	0	/ID field 0
	0	/ID field 1
	0	/i id0 - reference field

/console 5
pb5,	0	/i aw2 - assgt 2
	dd5	/i df1 - drum field table
	jmp ill	/i rr0 - reader switch
	jmp ill	/i pp0 - punch switch
	0	/i uf0 - user field 0
	0	/i uf1 - user field 1
	skp i	/i xe1 - proceed switch
	0	/i ac1 - ac
	0	/i io1 - io
	0	/i pc1 - pc
	0	/i pf1 - flags
	0	/i di1 - dia word
	0	/i bp1 - location of breakpoint
	0	/i bp2 - proceed count
	0	/i bp3 - instruction at breakpoint
	0	/ID field 0
	0	/ID field 1
	0	/i id0 - reference field

/console 6
pb6,	0	/i aw2 - assgt 2
	dd6	/i df1 - drum field table
	jmp ill	/i rr0 - reader switch
	jmp ill	/i pp0 - punch switch
	0	/i uf0 - user field 0
	0	/i uf1 - user field 1
	skp i	/i xe1 - proceed switch
	0	/i ac1 - ac
	0	/i io1 - io
	0	/i pc1 - pc
	0	/i pf1 - flags
	0	/i di1 - dia word
	0	/i bp1 - location of breakpoint
	0	/i bp2 - proceed count
	0	/i bp3 - instruction at breakpoint
	0	/ID field 0
	0	/ID field 1
	0	/i id0 - reference field
                
                                
	repeat nuf,0
dd2,

	repeat nuf,0
dd4,

	repeat nuf,0
dd5,

	repeat nuf,0
dd6,

unl,	lac i rf1	/unlock
	dap . 3
	cli>>05<<swp
	spi
	dip .
	law 1
	add rf0
	dap rf1
	dzm i rf1
	jmp ret

loc,	law 1	/lock
	add rf0
	dap rf1
	dzm i rf1
	law 1
	and 0
	sas 0
	jmp .	/?
	add uf1
	sub (1
	dac t
	lio i t
	sni
	jmp ill
	lac 2
	sma
	spi
	jmp asg
	jsp ix1	/on drum
	lac i t
	dip i id0
	jmp ret

asg,	lac t	/in core
	dap i rf1
	dzm ors
rew,	jsp ix1
	xct i xe1
	jmp . 2
	jmp wa1

	xct ids
	jmp .
	lac i bp1
	dac t
	lio (bpt
	eem
	lac i t
	dio i t
	lem
	dac i bp3
	rpf
	lai
	and (-400
	lia
	jmp wa1 1

                
                                
/switch and button sense

bsc,	dap cb1
	rsb
	lai
	xor tsb
	ior tsb
	xor tsb
	dac t1
	xor tsb
	dio tsb
	xor tsb
	cma
	and csi
	ior t1
	dac csi
	lac t1
	sar 7s
	ior cbi
	dac cbi
cb1,	jmp .

t,	0
t1,	0

csi,	0
cbi,	0
onn,	0
tsb,	0

cbk,	dap cbx	/check status
	spn
	scn
	srs i
rs1,	skp
	cks
	cla
	rcl 6s
jfm,	and .
	sza
	jmp cb9	/status bit came back on
	lio i jfm
	spi
	sbr
cbx,	jmp .
	jmp . 3

cb9,	xor i jfm
	dac i jfm
	law 4000
	jmp cbx

constants
foo,
start b
                
                                          
