                                    
midas assembler_. extended memory, part 2.

es,	dap esx		/symbol lookup and define
	lac (400000-smk
	dac opt
	dzm sdadr
	lac sym r
	and (-600000
	dac sym r
	xor (355670
	add (355670
	rar 7s
	dac t4
	lac sym l
	and (-600000
	dac sym l
	xor t4
	xor (326434
	add (326434
	ral 5s
	spa
	cma
	mul (3
	div .+1
	3xsmk
	swap
	add (st
es4,	dac sp1
	add one
	dac sp2
	add one
	dac evp
	extend
	lac i sp2
	sza i
	jmp esxa
	and (-600000
	sas sym r
	jmp es3
	extend
	lac i sp1
	and (-600000
	sas sym l
	jmp es3
	idx esx
	lac sp1
	dac sdadr
	extend
	lio i evp
	dio num
	dio t3
	extend
	lio i sp1
	extend
	lac i sp2
	jmp esx
          
                                                                 
esxa,	lac sdadr
	sza i
	lac sp1
	dac sdadr
	extend
	lac i sp1
	sza i
esx,	jmp .

es3,	isp opt
	jsp sce
	idx evp
	sad (low
	lac (st
	jmp es4

vsm,	0
	dac vsx
	jsp es
	 nop
	lac i vsx
	and (600000
	add sym l
	extend
	dac i sdadr
	dac sym l
	idx sdadr
	lac vsm
	and (600000
	add sym r
	extend
	dac i sdadr
	dac sym r
	idx sdadr
	lio tvl
	extend
	dio i sdadr
	idx vsx
	jmp i vsx
vsx,	0
sdadr,	0
          
                                                                 
ln,	lac cfn		/letter-number-period logic
	sad (45
	jmp d
	sub (12
	spa
	jmp n
	clc
	dac let
	szf 6
	stf 2		/liu
ln1,	idx chc
	sas (4
	jmp ln3
	move sym r, sym l
	dzm sym r
ln3,	sub (6
	szm
	jmp rr
ln4,	lac sym r
	ral 2s
	add sym r
	ral 3s
	add cfn
	dac sym r
	jmp rr

n,	lac num
	ral 2s
	lio num
n1,	xx		/nop or jda ad
	ral 1s
	lio cfn
	jda ad
	dac num
	lac dnm
	ral 2s
	lio dnm
	jda ad
	ral 1s
	lio cfn
	jda ad
	dac dnm
	idx cfn
	jmp ln1
          
                                                                 
d,	lac loc
	add ofst
	and (7777
	swap
	lac chc
	sza
	move dnm, num
	dio dnm
	sza
	jmp ln1
	lac rli
	add ofstr
	dac nmr
	jmp ln1

q,	lac syl		/parameter assignment routine
	lio let
	spa>>05<<spi>>05<<szf 5 i
	jmp ipa
	szf 2
	dac gsj
	jsp sav
	 sym l
	 sym r
	 gsj
	jsp sts
	 ilf
	 qq
	jmp rsw

qq,	jsp evl
	 flex usp
	spq
	jsp udf
	spi
	jmp rst

q1,	jsp uns
	 jsp sts
	lac gsi
	sza
	jsp ilf
	jsp rlck
	 flex irp
	spi i
	jsp ilr
	lio gsj
	spi
	jmp q2
	lio wrd
	dio tvl
	xor (200000
	jda vsm
	 400000
	jmp rst
          
                                                                 
q2,	and (600000
	ior sym r
	dac gls r
	lac sym l
	dac gls l
	jsp pgs
	lio wrd
	extend
	dio i ts
	idx ts
	sub (pbf+100
	sma
	jsp pub
	dzm tvl
	lac (400000
	jda vsm
	 600000
	jmp rst

/address routines

abs,	load gls l, 400000		/16 bit address
	lac loc
	add ofst
	jmp ab1

c,	lac loc			/12 bit address
	add ofst
	dzm gls l
	and (7777
ab1,	dac tvl
	lac indef
cp,	spa
	jmp rsw
	lac syl
	lio let
	spa>>05<<spi i
	jmp ckp
	jsp es		/monos
	 jmp ckd
	and (600000
	ral 2s
	rcl 2s
	sad (13
	jmp cpaa
	sad (17
	jmp ckda
	extend
	lio i sp2
	jsp erk
	dac rlc
	extend
	lac i evp
	jmp ckt
          
                                                                 
ckp,	jsp evl
	 flex ust
	spq
	jsp udf
cspi,	spi		/used as constant in conditionals
	jmp rsw
	lac gsi
	sza
	jsp ilf
	lac wrd
ckt,	sas tvl
	sad loc
	jmp ckr
ckm,	lac syl
	cli
	spa
	lio sym r
	dio lus r	/mdt error stop
	move sym l, lus l
	law rsw
	jda sov
	 flex mdt

ckr,	lac rli
	add ofstr
	sas rlc
	jmp ckm
	lac syl
	sma
	jmp rsw
ckw,	dzm aml
	move2 sym, asm
	jmp rsw

ckd,	szf 2
	jmp ckda
	lac rli
	add ofstr
	rar 1s
	jda vsm
	 400000
	jmp ckw

ckda,	dzm tvl
	lac (400000
	jda vsm
	 600000
	jmp ckw
          
                                                                 
cpaa,	lac rli
	add ofstr
	rar 1s
	xor (200000
	ior sym r
	dac gls r
	lac sym l
	ior gls l
	dac gls l
	clc
	dac gsj
	jsp pgs
	lio tvl
	extend
	dio i ts
	idx ts
	sub (pbf+100
	sma
	jsp pub
	jmp ckw

/conditionals

if1|	law i 1
if0|	cma
	dac npa
	jsp rch
	dac idt
	sad (char rd
	jmp idf
	sad (char rp
	jmp ips
	sas (char rv
	jsp ilf
	jsp rch
	lio cz
	sad (char rz
	jmp iv1
	lio cp
	sas (char rp
	jsp ilf
iv1,	dio ivs
	jsp svs
	jsp sts
	 iv2
	 iv2
	law iv3
	dap bt
	jmp rsw
          
                                                                 
iv3,	law rr
	jmp .+2
iv2,	law cfr
	dap ifx
	jsp evl
	 flex usi
	lac idt
	spi>>05<<sza
	jsp udf
	cla
	add wrd
ivs,	xx		/sza, spa, or spi

iff,	idx npa
ift,	jsp uns
	 jmp svx
ifg,	jsp rss+1
	idx chc
	and npa
	dac num
ifx,	jmp .

ips,	idx npa
	add pss
	dac npa
	init ifx, rr
	jmp ifg

idf,	dzm idt
	lio cspi		/(spi
	jmp ir1

idt,	0		/if d indicator = 0

/pseudo-instructions octal, decimal, noinput, readin and relocatable

rdi|	dac rim
	dzm ini
	dzm rlp
	jmp cfr

oct|	lio (opr
	jmp .+2
dec|	load n1, jda ad
	jmp cfr

noi|	dzm ini
	jsp pub
	jsp rst+1
	dzm rim
	jmp cfr

rel|	dac rlp
	dac ini
	dzm wrd
	law 1
	dac rlc
	jmp b5
          
                                                                 
/pseudo-instructions concise and internal

conc|	dzm inc
	jmp cfr

int|	dac inc
	jmp cfr

/pseudo-instruction print

pf|	init al6, pf4
	lac (flexo pnt
	jmp ale
pf4,	jsp tb
	law pf2
	jmp .+2

pf0|	law rsw
	dap pf3
	jsp rch
	dac t2

pf1,	jsp rch
	sad t2
pf3,	jmp .
	lat
	rar 2s
	sma
	jsp tyc+1
	jmp pf1

pf2,	law 77
	jda tyc
	jmp rsw
          
                                                                 
/pseudo-instructions equals and opsyn

osn|	lac pss		/opsyn
	sza
	jmp itt

eq|	jsp sts		/equals
	 osa
	 ilf
	jmp rsw

osa,	lac syl
	lio let
	szf i 2
	spa>>05<<spi i 5
	jmp ipa
	jsp sav
	 sym l
	 sym r
	jsp sts
	 ilf
	 os1
	jmp rsw

os1,	lac syl
	lio let
	spa+spi i-skp
	jmp ipa
	jsp es
	 jmp uso
	lio t3
	dio tvl
	jsp uns
	 jsp sts
	extend
	lac i sp1
	and (600000
	dac os2
	extend
	lac i sp2
	jda vsm
os2,	 0
	jmp rst
          
                                                                 
/pseudo instruction repeat

rpt|	jsp svs
rqd,	jsp sts
	 rqa
	 rqa
	jmp rsc

rq4,	jsp gc
	 jsp sce
	jmp rpz

rqa,	jsp evl
	 flex usr
	spi
	jsp udf
	lac gsi
	sza
	jsp ilf

rpz,	law 1
	add mai
	dac wcp
	sub (mil+lmi-1
	sma
	jmp rq4
	jsp rch
	jsp mas
	 jmp maw
	 (mil+lmi
	sas (77
	jmp maw
	jsp wcl
	 (mil+lmi
          
                                                                 
rq1,	jsp svr
	 rce
	 rcp
	 rex
	 rqc
	 rqq
	law rqt
	dap rex
	lac wcp
	dac rce
	sub mai
	extend
	dac i mai
	idx mai
	dac rqq
	dac rcp
	idx wcp
	and (177777
	dac mai
	law i 1
	sub wrd
	dac rqc
	jsp rst+1
	jsp uns
	 jmp svx
	isp rqc
	jmp rr
	jsp unr
	 law rqt
	jmp rr

rqt,	isp rqc
	jmp rq3
rqx,	jsp unr		/done
	 law rqt
	jmp rchb+1

rq3,	lac rqq
	dac rcp		/go around again
	jmp rchb+1
          
                                                                 
/pseudo-instruction word

wd|	jsp sts
	 wd2
	 wd1
	jsp pub
	law rsw
	dap wd3
	jmp rsc

wd1,	init wd3, rst

wd2,	jsp evl
	 flex uwd
	spq
	jsp udf
	lac gsi
	sza
	jsp ilf
	lio wrd
	lac pss
	and pch
	sza
	jsp pnc
wd3,	jmp .

/pseudo-instruction character

ch|	jsp rch
	lio (jsp ilf
	sad (char rr
	lio (opr
	sad (char rm
	lio fxl
	sad (char rl
	lio fxr
	dio ch4
	jsp rich
ch4,	xx
	dac num
	jmp fxx
          
                                                                 
/pseudo-instruction flexo

fx|	dzm num
	setup t2, 3
	jsp rich

fxr,	rar 6s
	ior num
fxl,	ral 6s
	dac num
	count t2, srich

fxx,	idx chc
	spi
	jsp iic+1
	jmp rr

/pseudo-instruction text

txt|	jsp rch
	dac t2
	init richx, txa

txq,	dzm wrd
	setup t1, 3
txw,	jsp rch
	lio inc
	spi>>05<<szf 6 i
	sas t2
	jmp rrich
	law i 3
	sad t1
	jmp rst
	lio wrd
	isp t1
	ril 6s
	ril 6s
	dio wrd
	jmp tb4

txa,	rar 6s
	ior wrd
	ral 6s
	dac wrd
	count t1, trich
	law txq
	spi
	law txqa
	dap .+2
	jsp tb3
	jmp .
txqa,	dzm wrd
	lio (-3
	dio t1
          
                                                                 
trich,	spi i		/internal conversion routines
	jmp txw
srich,	spi i
	jmp fxr-1
nrich,	isp t4
	cli
	lac t3
	rar 6s
	dac t3
	and (77
	jmp richx

rich,	dap richx
	jsp rch
rrich,	lio inc
	spi i
richx,	jmp .
	add (ict
	dac pt6
	extend
	lac i pt6
	szf 6
	ral 9s
	and (77700
	dac t3
	rar 6s
	sub (100
	spa
	jmp nrich+1
	sub (100
	spa
	jmp rich2
	add (rich
	dap .+1
	jmp .

fx4,	jsp rch
	sad (72
rag,	jmp rch+1
	sad (char r.
	jmp fx5
	sas (char r,
	jmp fx2
	law 33
	jmp .+2
fx5,	law 32
	cli
	jmp richx

fx2,	jsp iic+1
	jmp nrich+1
          
                                                                 
rich2,	lac .+1
	jmp rich1

fx6,	lac (771512
	dac t3
	lac (400000-3
rich1,	dac t4
	law 77
	jmp richx

/restore

res,	dap resx
	expurgate
	dzm sym l
	lac (vco
	dac pt6

re1,	extend
	lac i pt6
	and (177777
	dac sym r
	idx pt6
	extend
	lac i pt6
	dac tvl
	lac (200000
	jda vsm
	 400000
	idx pt6
	sas (vco+ipt-ist
	jmp re1

re2,	extend
	lac i pt6
	and (177777
	dac sym l
	idx pt6
	extend
	lac i pt6
	and (177777
	dac sym r
	idx pt6
	extend
	lac i pt6
	dac tvl
	lac (400000
	jda vsm
	 200000
	idx pt6
	sas (vco+vce-ist
	jmp re2

	lac (mil
	dac mai
resx,	jmp .
          
                                                                 
/pseudo-instruction library

lib|	jsp sts
	 lib2
	 lib1
	jsp pub
	lac (pbf
	dac tpa
	dac tp1
	law rsw
	dap lib3
	jmp rsw

lib1,	init lib3, lib3+1

lib2,	lac syl
	lio let
	spa>>05<<spi>>05<<szf 5 i
	jsp ilf
	lac sym l
	extend
	dac i tpa
	idx tpa
	lac sym r
	extend
	dac i tpa
	idx tpa
lib3,	jmp .
	lac pss
	and pch
	spq
	jmp rst
	dzm t1
	law i 5
	jda fee
	lac (400000
	jda pnb
	lac tpa
	add (400000-pbf
	jda pnb
lib4,	extend
	lac i tp1
	jda pnb
	idx tp1
	sas tpa
	jmp lib4
	lac t1
	jda pnb
	law i 5
	jda fee
	jmp rst

/pseudo-instruction start

sta|	jsp pub
	jsp sts
	 ilf
	 s
	jmp rsc
          
                                                                 
s,	lio .+1
	dio 91r
	jsp evl
	 flex uss
	spq
	jsp udf
	jsp pgs
	lac pss
	spq
	jmp 1st

s2,	ondrum
	init sov, np2
	cla
	sad 91p
	jmp .-1
	hlt>>05<<cla>>05<<cli
	move loc, tpa
	jsp tb3
	law 3
	dac blt
	lac pch
	spq
	jmp s6
	lio rlp
	law s2a
	spi
	jmp pub
	law i 40
	jda fee
	lac (jmp
	add wrd
	jda pnb
s2a,	dzm blt
	law i 300
	jda fee
	init sov, ps1
	move tpa, loc
	dio org
	cla
	sad 91p
	jmp .-1

s6,	lio mze
	cla+hlt-opr
	jsp res
	jmp ps1

blt,	0

1st,	init sov, np2
	law i 500.
	add one
	spa
	jmp .-2
	hlt>>05<<cla>>05<<cli
	endrum jmp ps2
          
                                                                 
ps2,	law 1		/begin new pass
	dac pss
	dac pch
	dac tit
	move ini, inp
ps4,	jmp np1

ps5,	enter
	opr
	opr
	opr
	opr
	cbs
	esm
	jsp res
ps3,	init sov, ps2
s5,	dzm pss
	hlt+clc+cli-opr-opr

ps1,	dzm pss
	dzm pch
	dzm rim
	law 1
	dac ini
	dzm rlp

np1,	ondrum
	setup1
	dzm rim
	dzm nca
	lac (con
	dac nco
	dzm vct
	dzm mii
	dzm asm l
	dzm asm r
	dzm rli
	dzm inc
	lac (spl+1
	dac gst+4
	dac gst+5
	lac (spl+13
	dac gst+3
	law 4
	dac org
	dac loc
	dzm indef
	dzm ofst
	dzm ofstr
	load n1, opr
	lac (pd1+1
	dac sap
	lac (pd2+1
	dac sbp
          
                                                                 	lac (cor
	dac cn5
	lac (vor-1
	dac va4
	endrum jmp np2

np2,	ondrum
	setup2
	rrb
	tyi
	law i 2000
	lat+cma-cla
	sza i
	jmp np2a
	move .+1,91r
	move 92r,93r
np2a,	dzm api l
	dzm api r
	dzm rlw
	dzm igi
	lac (pbf
	dac srt
	lio rlp
	spi
	add one
	dac ts
	dzm rcp
	dzm rce
	init rex, rfb
	load rlm, 600000
	dzm blt
	lac (dsp
	dac dpx
	lac (dsv
	extend
	dac i dpx
	init cfx, cfx+1
	dzm mdi
	dzm irpdf
	load stops, lac rcp
	clf 7
	lac pss
	and pch
	and tit
	sza
	stf 5
	law i 40
	szf 5
	jda fee
          
                                                                 
ptl,	jsp rch		/print and punch title
	sad (13
	jmp ptl
	sad (77
	jmp pt5
	stf 3		/into title
	szf 6
	jmp .+3
	sad (40
	clf 5

pta,	lat
	rar 2s
	sma
	jsp tyc+1
	szf 5
	jsp ptb
	jmp ptl

ptb,	dap tpf
	cli		/prs title punch
	ppa
	lac (ftp
	szf 6
	lac (ftp+tpu-tpt

tpl,	dac tpa
	law i 1
	sub lsc
	dac tp1

tpaa,	extend
	lac i tpa
	sma
	jmp tpb	/left byte begins char.
tpy,	and (400
	sza i
	jmp tpc	/right byte begins char.
tpd,	idx tpa
	jmp tpaa

tpb,	isp tp1
	jmp tpz
	extend
	lio i tpa
	jmp tpm
          
                                                                 
tpz,	extend
	lac i tpa
	jmp tpy

tpc,	isp tp1
	jmp tpd
	extend
	lio i tpa
	jmp tpn

tpg,	extend
	lio i tpa
	spi i
tpf,	jmp .
tpm,	ril 9s
	ppa
	spi i
	jmp tpf
	ril 9s
tpn,	ppa
	idx tpa
	jmp tpg

tpa,	0
tp1,	0

pt5,	szf i 3
	jmp ptl
	dzm tit

/print pass 1 or pass 2

pps,	law 72
	szf 6
	jda tyc
	law 3554
	jda typ
	law flex  pa
	jda typ
	lac (flex ss 
	jda typ
	lac (347701
	add pss
	rar 6s
	jda typ
	endrum jmp pi

/punch input routine

pi,	ondrum
	lac pss
	and pch
	spq
	jmp rst
          
                                                                 
pi1,	law i 40
	jda fee
	lac inp
	dzm inp
	sza i
	jmp rst
	spa
	jmp pvdf

pi2,	law 7751
	dac pt6

pi3,	add (dio
	jda pnb
	lac i pt6
	jda pnb
	index pt6, (7776, pi3
	lac (jmp 7751
	jda pnb
	jmp pi1
	endrum

pnb,	0		/punch binary word
	lio pnb
pnc,	dap pnx
	lac loc
	ppb
	ril 6s
	ppb
	ril 6s
	ppb
	lac pnb
	add t1
	dac t1
	lio rim
pnx,	jmp .

fee,	0		/feed blank tape
	dap fex
	cli
	ppa
	isp fee
	jmp .-2
fex,	jmp .

pt6,	0		/useful as random counter
	dap pt7
	extend
	lac i pt6
	repeat 3, cli	rcl 6s	ppa
pt7,	jmp .
          
                                                                 
pvdf,	lac (jmp 7776
	jda pnb
	law i 40 
	jda fee
	load evp, st-1

pvdf1,	idx evp
	dac sp1
	add one
	dac sp2
	add one
	dac evp
	sad (low+2
	jmp rst
	extend
	lac i sp1
	and (600000
	sas (600000
	jmp pvdf1
	extend
	lac i sp2
	sza i
	jmp pvdf1
	and (600000
	sza
	jmp pvdf1
	extend
	lac i evp
	and (600000
	xor (200000
	extend
	ior i sp2
	dac gls r
	extend
	lac i sp1
	and (-600000
	dac gls l
	clc
	dac gsj
	jsp pgs
	law 7777
	extend
	and i evp
	extend
	dac i ts
	idx ts
	sub (pbf+100
	sma
	jsp pub
	jmp pvdf1
          
                                                                 
start
          
                                                                                                                                      

