               
midas assembler_. extended memory, part 3.

/pseudo-instruction define

dfno,	jsp gc
	 jsp sce
dfn|	law 1
	add mai
	dac tvl
	sub (mil+lmi-2
	sma
	jmp dfno
	init cfx, df2
	clc
	extend
	dac i tvl
	lac (dsm
	dac dsk
	jmp rsw

df2,	lac chc
	sza i
	jmp rr
	move2 sym, api
	jsp sav
	 sym l
	 sym r
	law df4
	dap cfx
	lac lsc
	sas (77
	sad (36
	jmp .+2
	jmp rsw
	cla
	jmp dm3

df4,	lac lsc
	sas (77
	sad (36
	jmp dmi
	sad (char r,
	jmp dfc
	sad (char r/
	jmp dfs
	ior chc
	sza
	jsp ilf
	jmp rsw
          
                                                                 
dfs,	jsp dfd1
	extend
	dac i tvl
	jmp rsw

dfc,	law rsw

dfd,	dap dfx
	lio sym l
	extend
	dio i dsk
	idx dsk
	lio sym r
	extend
	dio i dsk
	idx dsk
	sad (dsm+nds+nds
	jsp tmp

dfw,	lac dsk
	sub (dsm
	sar 1s
dfx,	jmp .

dmi,	jsp dfd1
	extend
	lio i tvl
	spi i
	jmp dm2
	extend
	dac i tvl
dm2,	ral 6s
	extend
	add i tvl
dm3,	extend
	dac i tvl
	law 1
	dac mdi
	idx tvl
	dac wcp
	dac wfp
	jmp rsw

dfd1,	dap dfx
	lac chc
	sza
	jmp dfd+1
	jmp dfw
          
                                                                 
/pseudo-instruction terminate

ter|	jmp tsn
te5,	lac lsc
	sza i
	jmp te1

te2,	jsp uns
	 law df4
	lac mai
	dac tvl
	lac wfp
	sub mai
	extend
	dac i mai
	idx wfp
	and (177777
	dac mai
	cla
	jda vsm
	 200000
	jmp rst

te1,	init cfx, te3
	jmp rsw

te3,	lac chc
	sza i
	jmp rsw
	lac sym l
	sas api l
	jmp tee
	lac sym r
	sad api r
	jmp te2

tee,	move2 sym, lus
	error sov, te2, flexo mnd
          
                                                                 
/macro call

mac,	jsp ma0		/initialize argument scan
	idx t3

	law 77
	extend
	and i t3
	ral 1s
	dac t2		/origin generated symbols
	law 7700
	extend
	and i t3
	rar 5s
	dac t1
	sza i
	jmp mrc
	jsp mas
	 jsp rch
	 nco
	extend
	lac i dpa
	sas wcp
	jsp maa

mrc,	lac dpx
	sub dpa
	add t2
	spq
	jmp mrg
	jsp maa
	jmp mrc

mrg,	lac dpx
	sub dpa
	add t1
	spq
	jmp mrsss

gs,	init gsl, gst+5
	dap gsk

gsl,	idx .
	sad gst
	jmp gsc
	init gsg, gst

gsg,	lac i .
	jda wch
	 nco
	index gsg, (lac i gst+6, gsg
	jsp maa
	jmp mrg
          
                                                                 
gsc,	lac (spl+1

gsk,	dac .
	law i 1
	add gsl
	dac gsl
	dap gsk
	sas (idx gst+2
	jmp gsl
	jsp tmp

gst,	repeat 6, spl+45	/gst used as const

mrsss,	idx mii
	lac ma0a
	dac rmx
	jsp svr
	 dpx
	 arc
	 rce
	 rcp
	 rex
	idx t3
	dac rcp
	sub (2
	dac t3
	extend
	add i t3
	dac rce
	move dpx, arc
	move dpa, dpx
	init rex, mat
	jmp rr

mat,	jsp unr
	 idx t3
	law i 1
	add mii
	dac mii
	jmp rchb+1
          
                                                                 
/write arguments subroutine

ma0,	dap mxy
	lac rmx
	dac ma0a
	lac dpx
	dac dpa
	extend
	lac i dpx
	dac wcp
mxy,	jmp .

ma0a,	0

mas,	dap mxx
	dap ma7
	idx mxx
	dap .+1
	lac .
	dac ma8
	dac ma9
	idx mxx
masb,	lac lsc
	sza i
	jsp rch
	dzm ati
	move wcp, wfp
	sas (74
	szf i 6
	jmp ma5
	law 74
	jda wch
ma8,	 xx
	lac lsc
	jmp ma5

mal,	jsp rch
ma5,	sad (74		/u. c.
	jmp ma2
	szf i 6
	jmp ma6
	sad (char r)
	jmp mae
	sad (char r(
	jmp mad

ma6,	lac igi
	sza i
	jmp ma1

maw,	dzm wfp
ma3,	jsp wcl
ma9,	 xx
	jmp mal

ma2,	move wcp, wfp
	jmp ma3
          
                                                                 
mad,	idx igi		/[
	sub one
	jmp mae+3

mae,	law i 1		/]
	add igi
	dac igi
	sza
	jmp maw
	lac wfp
	sza i
	jmp mal		/no preceding upper case
	jsp rch
	sas (72
	jmp ma5
	move wfp, wcp	/delete preceding upper case
	jmp mal

ma1,	lac lsc
	sas (77
	sad (36
mxx,	jmp .		/end of arguments
	szf i 6
	sas (char r,
	jmp maw
ma7,	xct .
	law masb

maa,	dap max		/terminate argument subroutine
	dzm wfp
	idx dpa
	lio wcp
	extend
	dio i dpa
	idx dpa
	sub sap
	sma
	jsp tmp
	extend
	dio i dpa
max,	jmp .

dpa,	0
ati,	0
          
                                                                 
/pseudo-instructions irpc and irp

irc|	cla
ir|	dac tvl
	jsp ma0
	jsp mas
	 jsp rch
	 nco
	jsp maa
	jsp svr
	 rcp
	 rce
	 rex
	 dpx
	 arc
	law cfx
	dap rex
	load dsk, dsm
	lac dpx

ir1,	dac arc
	extend
	lac i dpx
	dac rcp
	idx dpx
	extend
	lac i dpx
	dac rce
	init cfx, ir2
	jmp rsw

ir2,	jsp dfd
	init cfx, ir3
	jmp rsw

ir3,	jsp dfd
	lac rcp
	extend
	dac i arc
	idx dpx
	sas dpa
	jmp ir1
	jsp unr
	 law cfx
ir4,	law 1
	dac irpdf
	add mai
	dac wcp
	dac wfp
	sub (mil+lmi-1
	spa
	jmp rst
	jsp gc
	 jsp sce
	jmp ir4

irpdf,	0
irpci,	0
          
                                                                 
/end of indefinite repeat

ipe|	jmp tsn
ip1,	jsp svr
	 ipcp
	 irpci
	 rcp
	 rce
	 rex
	 dpx
	 arc
	jmp ip6
ip6,	lac wfp
	dac rce
	sub mai
	extend
	dac i mai
	idx mai
	dac ipcp
	idx wfp
	and (177777
	dac mai
	lac tvl
	dac irpci
	lac dpx
	dac arc
	lac dpa
	dac dpx
	jsp rsw+1

ip4,	jsp svr
	 dpx
	 arc
	law ip5
	dap rex
	lac rce
	dac ipce
	jsp ma0
	lac arc
	dac ati

ip3,	dac ipt1
	extend
	lac i arc
	dac rcp
	idx arc
	extend
	lac i arc
	dac rce
	jsp rch
	lac irpci
	sma
	jmp irpc1
	jsp mas
	 jmp ip5
	 nco
          
                                                                 
ip5,	jsp maa
	lac rcp
	extend
	dac i dpa
	extend
	dac i ipt1
	idx dpa
	lac rce
	extend
	dac i dpa
	idx dpa
	sub sap
	sma
	jsp tmp
	extend
	dio i dpa
	idx arc
	sas dpx
	jmp ip3

	lac dpa
	dac dpx
	lac ipcp
	dac rcp
	lac ipce
	dac rce
	law ip2
	dap rex
	lac ati
	sza i
	jmp rr
stop3,	jsp unr
	 law ip5
	jsp unr
	 jmp ip6
	jmp rr

ip2,	jsp unr
	 law ip5
	jmp ip4

irpc1,	dzm ati
	jsp wcl
	 nco
	jmp ip5
          
                                                                 
/pseudo-instruction stop

pstop|	load stops, jmp stop1
	jsp rst

stop1,	lac rex
	lio (lac rcp
	sas (jmp rfb
	sad (jmp mat
	jmp stop2
	sas (jmp ip2
	jmp rex
	dio stops
	jmp stop3

stop2,	dio stops
	jmp rex

/read characters for macro call

rch,	dap rmx
	jsp rchb
	sad (60
	jmp rmg

rm2,	lat
	rar 2s
	spa
	jsp tyc+1
	lac lsc
rmx,	jmp .

rmk,	jsp unr		/end of arg, restore
	 law rmk
	jmp rchb+1

rmg,	jsp rchb		/set to read argument
	ral 1s
	add arc
	dac rmp
	jsp svr
	 rce
	 rcp
	 rex
	law rmk
	dap rex
	extend
	lac i rmp
	dac rcp
	idx rmp
	extend
	lio i rmp
	dio rce
	jmp rch+1

rmp,	0
          
                                                                 
/read and write characters

rchb,	dap rcx
stops,	xx		/lac rcp or jmp stop1
	sad rce
rex,	jmp .
	lch i rcp
	ral 6s
rc10,	dac lsc
	dac tyc
	sad (72
	clf 6
	sad (74
	stf 6
	lio lsc
rcx,	jmp .

wcl,	move lsc, wch
	jmp .+2

wch,	0
	dap wcx
	dap wcy
	idx wcy

wcx,	lac .
	dap wcx1
	lac wcp
	add (200000
	and (177777
wcx1,	sad .
	jmp wc2
	lac wch
	rar 6s
	dch i wcp
wcy,	jmp .

wc2,	dac rmp
	sad (mil+lmi
	jsp gc
	jsp sce
	lac t1
	jmp gka1

gka,	extend
	lio i t1
	extend
	dio i pt6
	idx pt6
	idx t1
gka1,	sas rmp
	jmp gka
	lac wcp
	sub t1
	add pt6
	dac wcp
	lac wfp
	sza i
	jmp wcx
	sub t1
	add pt6
	dac wfp
	jmp wcx
          
                                                                 
/garbage collector

gc,	ondrum
	dap gcx
	lac (mil
	dac fee		/transmitting pointer
	dac pt6		/receiving pointer

gc1,	dac t1
	sad mai
	jmp gcd		/done
	extend
	add i fee	/word count
	and (177777
	dac fee		/next value
	clf 3
	lac (st+2

gc2,	dac evp
	extend
	lac i evp	/search symtab
	sas t1
	jmp gc3
	law i 2
	add evp
	dac sp1
	add one
	dac sp2
	extend
	lac i sp1
	and (600000
	sas (200000
	jmp gc3
	extend
	lac i sp2
	sza i
	jmp gc3
	and (600000
	sza
	jmp gc3
	lac pt6
	extend
	dac i evp
	stf 3

gc3,	law 3		/index over symtab
	add evp
	sas (low+2
	jmp gc2

	lac sbp
	dac evp
	jmp gc5+1
          
                                                                 
gc4,	extend
	lac i evp	/search pushdown list
	and (177777
	sub fee
	szm
	jmp gc5
	add fee
	sub t1
	spa
	jmp gc5
	extend
	lac i evp
	sub t1
	add pt6
	extend
	dac i evp
	stf 3

gc5,	idx evp
	sas (pd2+1
	jmp gc4
	law rcp
	dap gcl1
	dap gcl2
gcl1,	lac .		/check read,repeat pointers
	and (177777
	sub fee
	szm
	jmp gc6
	add fee
	sub t1
	spa
	jmp gc6
	xct gcl1
	sub t1
	add pt6
gcl2,	dac .
	stf 3
gc6,	idx gcl1
	sas (lac ipcp+1
	jmp gcl1-1
	idx fee
	szf i 3
	jmp gc1
	lac t1
	sas pt6
	jmp gc7
	lac fee
	jmp gc1-1

gc7,	extend
	lio i t1		/save macro
	extend
	dio i pt6
	idx pt6
	idx t1
	sas fee
	jmp gc7
	jmp gc1
          
                                                                 
gcd,	lac pt6
	sas mai
	idx gcx
	lac pt6
	dac mai
gcx,	jmp .
	endrum

/pushdown processor

sav,	dap sa1
	law sap
	jmp sae

svr,	dap sa1
	law sbp
sae,	dap sah
	dap saq
	dap sat
	dap sau

saj,	law i 1
sah,	add .		/sap or sbp
sat,	dac .
sa1,	lac .	/get addr
	spa
	jmp sa3
	dap .+1
	lac .
	extend
saq,	dac i .		/pdl
	idx sa1
	jmp saj

sa3,	lac sa1
	dap sax
	extend
sau,	dac i .
	lac sap
	sub dpx
	spq
	jsp sce
	lac sbp
	sub (pbf+103
	spa
	jsp sce
sax,	jmp .
          
                                                                 
uns,	dap un1
	dap unx
	law sap
	jmp una

unr,	dap un1
	dap unx
	law sbp
una,	dap unl
	dap un0
	dap unj
	extend
un0,	lac i .		/get pd entry
	dap unk
	xct unk
un1,	sas .		/check with pp
	jsp se
	idx unx

und,	law i 1
	add unk
	dap unk
unl,	idx .		/sap or sbp
unk,	lac .		/get addr
	spa
unx,	jmp .
	dap unp
	extend
unj,	lac i .		/get pd entry
unp,	dac .		/restore
	jmp und
          
                                                                 
start
          
                                                                                                                            
