           
midas assembler_. extended memory, part 4.

/constant designators

svs,	dap svx
	jsp sav		/save word info
	 gsj
	 gsi
	 wrd
	 fct
	 psn
	 fcn
	 def
	 rlc
	 fcr
	 fci
	 tt
	 ct
	 qt
	 bt
	 rt
	 syl
	 jmp svx
svx,	jmp .

lp,	jsp svs
lp1,	jsp sts
	 rp1
	 rp1
	init rt, rp
	jmp rsw

/evaluate constant syllable

rp1,	law 1		/tab or c. r.
rp,	add (rr		/r. p.
	dap cox
	jsp evl
	 flex usc
	jsp rss+1
	idx chc
	lac pss
	sza i
	jmp co8
	spi		/def in IO
	jsp udf

c12,	lac nco
	dac t2
	jmp co4

co2,	extend
	lac i t2
	sad wrd
	jmp co6
co4,	idx t2
	sas (con+1
	jmp co2
          
                                                                 
/define new constant

co1,	lac wrd
	extend
	dac i nco
	lac nco
	dac t2
	sub one
	dac nco
	extend
	lac i dpx
	and (177777
	sub nco
	sma
	jsp sce
	jsp crk
	lio (600000
co7,	rir 2s
	isp t1
	jmp co7
	dio t1		/mask
	jsp rcj
	xor rct
	extend
	xor i cr5
	and t1
	extend
	xor i cr5
	extend
	dac i cr5

c10,	idx nca
co5,	lac pss
	sza i
	jmp c22
	lac (con
	extend
	add i cn5
	sub t2
	cli
	rcl 1s
	rar 1s
	dio nmr
	and (7777
	dac num
	jsp rlck
	 flex irc
	spi i
	jsp ilr
          
                                                                 
c22,	jsp uns
	 jmp svx
	lac pss
	sza
cox,	jmp .
	law i 1
	dac def
	jmp cox

co8,	spi		/def on pass 1
	jmp c10
	jmp c12

co6,	jsp crv		/check rel. agreement
	sad rlc
	jmp co5
	jmp co4

crv,	dap cx
	jsp crk
	extend
	lio i cr5
cr4,	ril 2s		/calculate relocation
	isp t1
	jmp cr4
	jsp erk
cx,	jmp .

crk,	dap crx		/subr to reference crl
	lac (con
	sub t2
	scr 3s
	add (crl
	dac cr5
	cla
	scl 3s
	cma
	sub one
	dac t1
crx,	jmp .

cr5,	0
cn5,	0
cn6,	0
cn8,	0
va4,	0
va7,	0
          
                                                                 
/pseudo-instruction constants

cns|	ondrum
	lac indef
	spa
	jmp ilf
	lac cn5
	sad (cor+ncn+ncn+ncn
	jmp tmc
	dac cn6
	idx cn6
	dac cn8
	idx cn8
	lac (con+1
	dac t2
	lac rli
	add ofstr
	rar 1s
	add loc
	add ofst
	lio pss
	rir 1s
	spi i
	jmp cn1
	extend
	sad i cn5
	jmp cn7
cld,	error alm, alh, flex cld

cn1,	extend
	dac i cn5
	lac nca
	add loc
	add ofst
	extend
	dac i cn6
	jmp cnd

cn2,	extend
	lio i t2
	dio wrd
	jsp crv
	dac rlc
	jsp tb3

cn7,	law i 1
	add t2
	dac t2
	sas nco
	jmp cn2
	lac loc
	add ofst
	extend
	dac i cn8
          
                                                                 
cnd,	extend
	lac i cn5
	and (-600000
	cma
	extend
	add i cn6
	add aml
	dac aml
	dzm nca
	lac (con
	dac nco
	law 3
	add cn5
	dac cn5
	extend
	lac i cn6
	jmp cnb
	endrum

/pseudo-instruction variables

var|	ondrum
	lac indef
	spa
	jsp ilf
	idx va4
	dac va7
	idx va4
	sad (vor+nvo+nvo
	jmp tmv
	lac pss
	sza i
	jmp va2
	lac loc
	extend
	sad i va7
	jmp va6
vld,	error alm, rst, flexo vld

va2,	lac loc		/pass 1
	extend
	dac i va7
	load evp, st-1
	jmp vai
          
                                                                 
va3,	extend
	lac i sp2
	and (600000
	sas (200000
	jmp vai
	extend
	lac i sp1
	and (600000
	sza
	jmp va3a
	extend
	lac i evp
	add loc
	add ofst
	extend
	dap i evp
	lac rli
	add ofstr
	rar 1s
	extend
	add i sp2
va3b,	sub (200000
	extend
	dac i sp2

vai,	idx evp
	dac sp1
	dac sp2
	idx sp2
	dac evp
	idx evp
	sas (low+2
	jmp va3
	lac loc
	add vct
	extend
	dac i va4

va6,	dzm vct		/pass 2
	extend
	lac i va4
	extend
	sub i va7
	add aml
	dac aml
	extend
	lac i va4
	endrum jmp cnb

cnb,	lio rli
	dio rlc
	dac wrd
	jmp b5
          
                                                                 
va3a,	sas (600000
	jmp vai
	lac rli
	add ofstr
	rar 1s
	extend
	add i evp
	add loc
	add ofst
	and (407777
	extend
	dac i evp
	extend
	lac i sp2
	jmp va3b

dim|	lac pss		/pseudo-instruction dimension
	sza
	jmp itt
	jsp sts
	 rsw
	 rst
	init lt, di1
	init rt, di2
	jmp rsw

di1,	lac syl
	lio let
	spa+spi i 5-skp
	jsp ilf
	szf 2
	dac gsj
	jsp sav
	 sym l
	 sym r
	 gsj
	 jmp rsw

di2,	jsp evl
	 flex usd
	spi
	jsp udf
	lac gsi
	sza
	jsp ilf
	lac vct
	dac tvl
	add wrd
	dac vct
	jsp uns
	 jmp rsw
	jsp es
	 jmp di4
	spi>>05<<spa
	rcl 1s
	spi>>05<<spa
	jmp di4a
mdd,	move2 sym, lus
	error sov, rsw, flex mdd
          
                                                                 
di4,	lac gsj
	sza
	jmp di4a
	lac (200000
	jda vsm
	 0
	jmp rsw

di4a,	lac (200000
	jda vsm
	 600000
	jmp rsw

rfb,	dzm rcp
	dzm rce
	rpa
	swap
	jmp rc10

ilp,	lac (flex ilp
	jda typ
	law 77
	jda tyc
	init sov, 95r+2
	hlt>>05<<cli>>05<<clc>>05<<clf 4
	jmp 95r+2

/ignore to tab or carr ret

itt,	jsp rst+1
	lac lsc

it3,	sas (36
	sad (77
	jmp cfr
	jsp rch
	jmp it3

/error stop entries

uso,	move2 sym, lus
	error sov, rst, flex uso

udf,	dac sov
	jmp alj

irx,	law ts2

ilr,	dac sov
	jmp alj

ich,	error alm, rr, flex ich

ilf,	error alm, itt, flex ilf

mdv,	move2 sym, lus
	erroru flex mdv
          
                                                                 
iic,	error alm, rch+1, flex iic

ipa,	error alm, itt, flex ipa

sce,	error alm, alh, flex sce

tmc,	error alm, alh, flex tmc

tmp,	error alm, alh, flex tmp

tmv,	error alm, alh, flex tmv

se,	dac loc
	error alm, alh, flex iae

/error identification routine

alm,	0
	lio alm
	dio sov
	dzm lus r
	jmp sov+1

sov,	0		/return
	dap alp
alj,	init al6, al6+1
alp,	lac .		/get error code
ale,	ondrum
	jda typ
	lac mii
	sza i
	jmp al0
	cli
	jda tyy
	jda opt

al0,	jsp tb
	lac indef
	sma
	jmp al1
	lac (flex ind
	jda typ
	lac (flex ef 
	jda typ
al1,	lac loc
	and (177777
	jda opt
	lac rli
	sza i
	jmp al2a
	lac (flex +
	jda typ
	lac char rr
	jda tyc
          
                                                                 
al2a,	lac ofst
	ior ofstr
	sza i
	jmp al2
	cli
	jda tyy
	lac ofst
	jda opt
	lac ofstr
	sza i
	jmp al2
	lio (725474
	sma
	jda tyy
	rir 6s
	jda tyy
	rir 6s
	sma
	jda tyy
	law char rr
	jda tyc

al2,	jsp tb
	lac asm r
	sza i
	jmp al6
	lac (1a asm
	jda spt
	lac aml
	lio (725474
	szm
	jda tyy
	rir 6s
	sza
	jda tyy
	rir 6s
	szm
	jda tyy
	spa
	cma
	sza
	jda opt

al6,	jmp .
	lac api r
	sza i
	jmp al9

al7,	jsp tb
	lac (1a api
	jda spt
	lac lus r
	sza i
	jmp al8

als,	jsp tb
	lac (1a lus
	jda spt
          
                                                                 
al8,	law 77
	jda tyc
	lat
	rar 1s
	spa
	jmp alk
	endrum jmp alh
alh,	lio .+1
	dio 91r
	cla
	sad 91p
	jmp .-1
	law i 500.
	add one
	spa
	jmp .-2
	lio mze
	lac sov
	dap .+3
	clc>>05<<hlt
	dzm pch
	jmp .

al9,	lac lus r
	sza i
	jmp al8
	jsp tb
	jmp als

alk,	ral 4s
	sma
	dzm pch
	lac sov
	dap .+2
	clc
	jmp .
          
                                                                 
/symbol print subroutine

spt,	0
	dap spx
	clf 1

spf,	init spj, spd
	extend
	lac i spt
	and (-600000
	dac opt

spn,	init spp, spl

spr,	lac opt
spj,	sub
	spa
	jmp spp
	dac opt
	idx spp
	jmp spr

spp,	lio
	spi i
	jda tyy
	idx spj
	sas (sub spd+3
	jmp spn
	szf 1
spx,	jmp .
	stf 1
	idx spt
	jmp spf

spd,	3100
	50
one,	1

spl|
spln,	400000
	char r0	char r1
	char r2	char r3
	char r4	char r5
	char r6	char r7
	char r8	char r9
	char ra	char rb
	char rc	char rd
	char re	char rf
	char rg	char rh
	char ri	char rj
	char rk	char rl
	char rm	char rn
	char ro	char rp
	char rq	char rr
	char rs	char rt
	char ru	char rv
	char rw	char rx
	char ry	char rz
	char r.
          
                                                                 
/octal print subroutine

opt,	0
	dap opx
	law i 6
	dac spt
	clf 1
op1,	lio opt
	cla
	rcl 3s
	dio opt
	sza
	stf 1
	sza i
	law 20
	szf 1
	jda tyc
	isp spt
	jmp op1
	law 20
	szf i 1
	jda tyc
opx,	jmp .

tb,	lio (36
	jmp .+2

tyy,	0		/type a character from IO
	dio tyc
	jmp tyc+1
          
                                                                 
tyc,	0		/type from AC
	dap tyx
	lio tyc
ty5,	law i 770
	rcr 6s
	lio (252002	/magic number
	rcr 9s
	dap .+1
	rir
	spi
	and ty5
	rar 3s
	szs 60
	jmp ty1a
ty1,	cks
	ril 2s
	spi i
	jmp ty1
	swap
	tyo-i
ty1b,	lio tyc
	lac tyy
tyx,	jmp .

ty1a,	swap
	ppa
	jmp ty1b

typ,	0		/type three characters
	dap tyz
	setup t, 3

ty2,	lac typ
	ral 6s
	dac typ
	jda tyc
	isp t
	jmp ty2
tyz,	jmp .
          
                                                                 
/Indicators and variable storage

pss,	0	/ 0 . pass 1, 1 . pass 2
npa,	0	/ 0 . begin pass, 1 . continue pass
pch,	0	/ 0 . no punch, 1 . punch if pass 2
inp,	0	/ 0 . no input, -0 . start block only,
		/ +1 . punch input
tit,	0	/ 0 . no title, 1 . punch title
ini,	0	/ aux. input routine indicator
rlp,	0	/ relocatable program indicator
rlc,	0	/ word relocation count
rli,	0	/ reloctable mode indicator
rlm,	0	/ relocation mask
rlw,	0	/ relocation bit word
gsi,	0	/ global symbol in word . +0
gsj,	0	/ global symbol in last syl . +0
gls,	zero	/ last global symbol processed
rim,	0	/ +0 . block format, -0 . readin mode
lus,	zero	/ last undefined symbol
wrd,	0	/ sum of syllable products
num,	0	/ value of syllable
dnm,	0	/ decimal value
nmr,	0	/ number relocation
fct,	0	/ factor = product of syllables
fcr,	0	/ factor relocation
fci,	0	/ 0 . not product, +1 . multiplication,
		/ -0 . logical operation
def,	0	/ 0 . defined, -1 . undefined
chc,	0	/ number of characters in symbol
let,	0	/ 0 . no letters, -0 . letters present
sym,	zero	/ symbol
syl,	0	/ -0 . one symbol of less, 1 . two or more
api,	zero	/ last pseudo-instruction for error stop
asm,	zero	/ symbol part of symbolic location
aml,	0	/ numeric part of symbolic location
nsm,	0	/ symbolic location indicator
asa,	zero	/ symbol in location assignment
amn,	0	/ numeric part of location assignment
nco,	0	/ number of distinct constant values
nca,	0	/ number of constants
vct,	0	/ variables count
mai,	mil-1	/ macro instruction list pointer
mii,	0	/ macro call level counter
mdi,	0	/ macro define level counter
tvl,	0	/ temporary for defining symbols
lsc,	0	/ last character
rcp,	0	/ read charcter pointer
rce,	0	/ read character endcheck
rqq,	0	/ repeat origin pointer
ipcp,	0	/ irp origin pointer
ipce,	0	/ irp temporary for end check
ipt1,	0	/ irp temporary
wcp,	0	/ write character pointer
wfp,	0	/ temporary for wcp
igi,	0	/ bracket counter
dsk,	0	/ defined dummy symbol counter
dpx,	0	/ macro call argument end pointer
arc,	0	/ macro call argument origin pointer
inc,	0	/ 0 . concise, -0 . internal
          
                                                                 
rqc,	0	/ repeat count
sap,	0	/ (pushdown list
sbp,	0	/ (pointers
sp1,	0	/ symbol table pointers
sp2,	0
evp,	0
org,	0	/ block origin
loc,	0	/ location counter
indef,	0	/ location indefin ite indicator
ofst,	0	/ offset count
ofstr,	0	/ offset relocation factor

t,	0	/ temporary storage
t1,	0
t2,	0
t3,	0
t4,	0

l=0	r=1

constants
obl=1a .-60

1a 7750/	jmp ls

setup3			/ Sets s. b. reader buffer
dsm=92d+9lr		/ Dummy symbols

repeat 0if vp 1a+7750-dsm-ndsx2,dsm+ndsx2/print .overlap 1.

fr1=92d			/ Symbol package
          
                                                                 
start
          
                                                                                    

