# vars - 0 - var cases - s - code
# mem (odd number cells)

#e is the amount to get to c
#f is the amount to get to p

# g is jump amount to get back to main loop
# s is start of code in memory

# in main loop, l is toggle, for even odd part of code
# d is previous result
# a is current instruction
# p will point to active location

# h is 1

mi

tc

cg #where g will point to main loop start or load start
#now here only at beginning

#A
pmpm
Ac
pp

ht

ni #i
ki #o
pnpn
Ac
pp

pkpk
uc
th
tu
At
pp

ai #set how to get to var[c]
eaea

bi #set how to get to var[p]
fbfb

aa
ai #bang
pa Ah #to enable exit in load
pa
AtAhAh

smsmsmgcsm  #code starts here
ds


#load the source to interpret
aa
ai

pp
pd
dh
dh
Aa

#break if bang
pp
pa
cA
#end if

cc #loop

gggc
AA #clear the bang exit
dd


#################################
#         main loop             #
#################################

Ad
ddaa
aA

#################################
pp
AA #clear 0 (so mutliple inputs dont add up)
pe
tt
tA
tA
Al #var[c]++ if l==-1
pp
pt
ts
pt #now p points to the current statement

#do toggle stuff
#l=-1-l
tt
th
tl
bb
bt
ll
lb

clda #update d if l==0

plpl #next byte if part 1

aa
aA #a is current instruction

pp
papa
ttbb
tAbt
pptt

cb #case statement
#note todo, could just make 0->jump out

#case register (0)
ta
ptpt
cc

aa
#case A (4)
pf
tA
pp pt pt ph
cc

#case i (11)
di
cc

#case o (13)
od
cc

#case bang (15) doing nothing will exit
ox

#this particular set of input is itself followed by a quine
!Aiocp!mitccgpmpmAcpphtnikipnpnAcpppkpkucthtuAtppaieaeabifbfbaaaipaAhpaAtAhAhsmsmsmgcsmdsaaaipppddhdhAapppacAccgggcAAddAdddaaaAppAApetttAtAAlpppttsptttthtlbbbtlllbcldaplplaaaApppapattbbtAbtppttcbtaptptccaapftAppptptphccdiccodcc!Aiocp!cctcutaipdAadusabspbAuttsstcstoaaaaipppdAadupppapapacAcsppoaaaaapppeaAeupppapapacAcsoa!cctcutaipdAadusabspbAuttsstcstoaaaaipppdAadupppapapacAcsppoaaaaapppeaAeupppapapacAcsoa!