
BRS Loader

	define
	write A
	tslr wr
	tra A
	term

tc1,	cyl
	sto cw
	llr mrl
	trn rbk
	llr rlc

rbk,	slr t		|read block
rb1,	r3c
	alr
	add cks
	sto cks
	lac
	add t
fa,	xx		|store
fc,	llr fa
	lac
	add one
	sto fa
	add la
bsw,	xx		|block switch

rck,	r3c		|read checksum
	add cks
	add la
	trn rc1

rce,	write rcf
	text |Checksum
|
rcf,	clc
	alr+hlt-opr

r,	r3c		|first word of block
	trn neg
	add (add
	trn hpr
	add (slr
	trn rel

abs,	move tr, rbx	|absolute block
	load bsw, trn rb1
	com+lro-opr
	add (llr
	com
	sto fa
	sto cks
	r3c
	sto la
	tra rbk

rel,	add (-trn+slr	|relocatable block
	add rlc
	sto cks
	add (-slr
	sto fa
	alo
	add pci
	trn np

re1,	load bsw, trn cwt
	load rbx, tra re2
	r3c
	add mrl
	sto la

cwr,	r3c+cyr-opr	|read code word
	sto cw
	cyl
	add cks
	sto cks
	llr fa
	lcc
	add (-7
	sto cwc

tcb,	llr cw		|test code bits
	lal+lro-opr
	trn tc1
	cyl
	sto cw
	tra rbk

re2,	llr fa
	slr fa1
tr,	tra r

cwt,	lac
	add cwc
	trn tcb
	tra cwr

np,	stz pci		|new program
npb,	xx		|slr tvt
	tra re1

rc1,	add one
	trn rce
	cal
rbx,	xx		|read block exit

|Program card

pcd,	load rbx, tra pct
	clad pci
	trn pcb
	tac
	trn pcs
	add (add
	trn pcu
	clad fa1

pce,	sto rlc
	com
	sto mrl

pcb,	load bsw, trn cwt
	move syx, fa
	r3c+lcd-opr
	com
	sto la
	lac+lro-opr
	add (opr
	sto cks
	tra cwr

pct,	opr
pc1,	clad pci
	trn pck
	add tvx
	add one
	sto npb
	add one
	sto tvx

pck,	clc
	sto pci
	add fa
	add mon
	sto syx
	add (llr-sto
	sto pc2
pc2,	xx		|llr=get tvn
tvx,	xx		|slr tvt+1
	tra r

pcu,	add fa
pcs,	llr (17777
	ana
	tra pce

|Read library tape

sts,	add pci
	trn r
stw,	tra ste

st1,	add pci
	trn pc1
ste,	move vpw, vps
	clad (tra st2
	subr sca, str

st2,	add fa
	add (add-3
	tra st3

st4,	cla
stc,	xx		|add symbol table appendix
	lpd
	trn sti
	amz
	trn stg
sti,	clad stc
	add (-2

st3,	sto stc
	com
	add syx
	add (add
	trn st4
	tra vpi

stg,	move fc, re2	|set to pick up required program
	load pct, tra st1
	tra pc1

str,	move tr, re2	|skip program not needed
	load pct, tra sts
	tra r

|Start block

neg,	add (-add
	trn pcd
hpr,	cal+hlt-opr

|Diagnostic for missing programs

dia,	move vpw, vps
	clad (tra di1
	subr sca, pat

di1,	load scx, tra di3
	llr dib
	slr evx
	tslr wr
dib,	tra di2
	text |
Missing

|
di2,	xx		|llr symbol
	lac
	call mpc
	add crt
	pno
vpw,	tra vpi

di3,	clc
dix,	alr+hlt-opr

|Patch transfer vectors

pat,	tbr
	trn sm
paa,	load vps, add (tra
	clad (tra pa1
	call sca

sad,	0
	clc
	tra .-2

pa1,	add dix
	tra vp4

|Initiation sequence and entries

ini,	move fc, re2
	load tvx, slr tvt+1
	load syx, sto syt
	load rlc, 20
	slr fa1
	lcc+lro-opr
	sto mrl
	slr sad
	slr pci
	tra hpr

ent,	tra rs
	tra ini
	llr stw
	tra .+2
rs,	llr pc1
	slr pct
	tra r

|Scan transfer vectors

sca,	slr scx
	sto evx
	clad tvx
	add (add-slr
	tra scb

scl,	move one, t
	cal
sc1,	xx		|add tvt=get t. v. origin
	tra vpe

|Process transfer vector

vpg,	xx		|add syt+1=value
vps,	xx		|diagnostic switch, add (tra or tra vpi.
vp4,	xx		|store transfer over name
vpi,	clad vp4
	add one
vpe,	sto vp4
	add (llr
	sto vp3
	sto di2
	clad t
	add mon
	sto t
vp9,	xx		|add tvt+1=no. of t. v. entries
	trn scr
vp3,	xx		|llr t. v. name

|Evaluate symbol

evl,	clad syx
	add (add-1
	tra eve

eva,	cla
ev1,	xx		|add syt=symbol
	lpd
	trn evi
	amz
	trn vpg
evi,	clad ev1
	add mon
eve,	sto vpg
	add mon
	sto ev1
	add (-add-syt+trn
	trn eva
	clc
evx,	xx		|undefined symbol exit

scr,	add sc1
	add mon
scb,	sto vp9
	add mon
	sto sc1
	add (-add-tvt+trn
	trn scl
	cal
scx,	xx

|Storage map

sm,	write sma
	text |
Name	Origin	Entry

|
sma,	add (add syt
	tra sme

sml,	cla
sm1,	xx		|add syt=symbol
	call mpc
	add tab
	pno
	sto t
	add tvx
	add (llr-1-slr
	tra sms

sm4,	xx		|llr tvt=origin
	lcc
sm2,	xx		|add syt+1=value
	add one
	trn smi
	lcc
	add t
	trn .+2
	tra smi
	slr t

smi,	clad sm4
	add (-2
sms,	sto sm4
	add (-llr-tvt+trn
	trn sm4

	call opt+1
	add tab
	pno
sm3,	xx		|add syt+1=value
	call opt
	add crt
	pno
	clad sm3
	add one
sme,	sto sm1
	add one
	sto sm2
	sto sm3
	com
	add syx
	add (add+trn
	trn sml
	write smw
	text |end=|
smw,	add fa1
	call opt
	add crt
	pno
	tra dix

|Octal print subroutine.

opt,	sto t
	slr opx
	load opu, trn opj

opq,	llr t
	lal
	cyl
	cyl
	sto t
	llr (7
	ana
	llr opj+2
	add (add fch
	sto .+1
	xx

opu,	xx
	slr opu
	pno

opj,	clad opc
	cyr
	sto opc
	trn opq
	cyl
	trn opq-1
	cal
opx,	xx

opc,	171717

fch,	flex  0t-add-fch
	flex 11 -add-fch-1
	flex 22 -add-fch-2
	flex 33 -add-fch-3
	flex 44 -add-fch-4
	flex 55 -add-fch-5
	flex 66 -add-fch-6
	flex 77 -add-fch-7

|Main program

mpc,	slr mpx
	trn mpa
	amz
	trn mp1
mpa,	type
mpx,	xx

mp1,	write mp2
	text |main|
mp2,	tra mpx

|Write subroutine.

wr,	lac
	add (2
	sto wr1
	add (add 1-llr
	sto wr2
wr1,	xx
	slr wrx
	lcc
	add (tra-add+1
	sto wr1

	cal
wr2,	xx
	type
	step wr2
	add wr1
	trn wr2-1
	cal
wrx,	xx

|Constants

tab,	char r	
crt,	char r

one,	1
mon,	-1
la,	0
cks,	0
fa1,	0
rlc,	0
mrl,	0
cw,	0
cwc,	0
pci,	0
t,	0
syx,	0

constants

tvt|	sto sad	1

start add ini
0