lisp.mac 193 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528
  1. ;LISP.MAC, 9-Apr-81 21:51, Edit by FRICK
  2. ;
  3. ;NUMVAL redefined. It now gives error if given anything but INUM or FIXNUM.
  4. ;LISP.MAC, 26-Sep-80 10:44, Edit by FRICK
  5. ;
  6. ;%FSLID defined as support for PRELOAD facility.
  7. ;LISP.MAC, 25-Aug-80 12:06, Edit by FRICK
  8. ;
  9. ;Make ^Z comments work inside other comments.
  10. ;Corrected bug in initial dialogue. SYLO+1 is CAILE C,"z" instead
  11. ; of CAIG C,"z"
  12. ;<FRICK>LISP.MAC.28, 22-Nov-79 15:31:17, Edit by FRICK
  13. ;
  14. ;Define ERJMP for Tenex. Don't include RSCAN for Tenex.
  15. ;<FRICK>LISP.MAC.27, 21-Nov-79 11:21:50, Edit by FRICK
  16. ;
  17. ;Corrected bug in FUNARG. APFNG+6 is MOVN R,APFNG1 instead of HRRZ R,APFNG1.
  18. ;<FRICK>LISP.MAC.26, 13-Nov-79 19:48:53, Edit by FRICK
  19. ;
  20. ;Convert lower case to upper case on answer to start up questions
  21. ;<FRICK>LISP.MAC.24, 11-Nov-79 16:46:11, Edit by FRICK
  22. ;
  23. ;REMD now returns NIL or the removed type . function, as in Standard Lisp.
  24. ;Corrected bug in errormessage for index error in GETV, PUTV.
  25. ;PROG2 is again a defined function.
  26. ;<FRICK>LISP.MAC.20, 8-Nov-79 19:33:42, Edit by FRICK
  27. ;
  28. ;Added code for new FASLOD. Switches OFLD and NFLD controls assembling
  29. ; of new FASLOD and old FASLOAD. Both might be on at the same time.
  30. ;<FRICK>LISP.MAC.3, 1-Nov-79 16:26:25, Edit by FRICK
  31. ;
  32. ;For high core BPS in Tops-10 now computes start of high core.
  33. ;
  34. ;Fix bug in XEQ by guaranteeing 0 at end of RSCAN string.
  35. ;<FRICK>LISP.MAC.1, 28-Oct-79 16:06:56, Edit by FRICK
  36. ;
  37. ;An atom as first argument to FILEP means a filename for a file on DSK:
  38. ; with blank extension.
  39. ;
  40. ;XEQnow clears the terminal input buffer before simulating terminal
  41. ; input.
  42. ;<FRICK>LISP.MAC.4, 26-Oct-79 12:32:56, Edit by FRICK
  43. ;
  44. ;The charcters "+", "-" and "'" are now preceded by a "!" in PRIN1 and
  45. ; EXPLODE.
  46. ;<FRICK>LISP.MAC.2, 9-Oct-79 12:59:52, Edit by FRICK
  47. ;
  48. ;EOF is now signaled by returning the value of the interned id $EOF$.
  49. ;This value is originally the uninterned id $EOF$, but it can be
  50. ; changed.
  51. ;
  52. ;Cange of edit of 27-Mar-79. TYI (and READCH) now ignores null.
  53. ;<FRICK>LISP.MAC.16, 12-Sep-79 13:07:31, Edit by FRICK
  54. ;
  55. ;READ does now read negative bignums without dropping the minus sign
  56. ;
  57. ;When using high core in Tops-10, preserves high core data area.
  58. ;<FRICK>LISP.MAC.12, 16-Aug-79 16:13:29, Edit by FRICK
  59. ;
  60. ;BPS in high core now allowed also in Tops-10.
  61. ;Assembler switch SZBPS decides whether size of BPS is user settable.
  62. ;SZBPS is allways on if HCBPS is off. EXCORE only defined when SZBPS is
  63. ;on.
  64. ;
  65. ;Function EVLIS now defined.
  66. ;<FRICK>LISP.MAC.29, 2-Jul-79 15:11:01, Edit by FRICK
  67. ;
  68. ;Corrected bug in EQUAL so that EQUAL may return T for vectors.
  69. ;<FRICK>LISP.MAC.26, 15-Jun-79 19:08:49, Edit by FRICK
  70. ;
  71. ;The UUO handler changed to allow UUOs to be executed via a XCT.
  72. ;The MAPping functions have been changed to use this.
  73. ;<FRICK>LISP.MAC.19, 9-Jun-79 13:39:56, Edit by FRICK
  74. ;
  75. ;Included "T" and "?" in IDCHTAB.
  76. ;<FRICK>LISP.MAC.16, 29-May-79 18:40:20, Edit by FRICK
  77. ;
  78. ;Corrected error at XTYO so that character count now is reset at CR when
  79. ; echoing and TYO treats ascii 37 correctly.
  80. ;<FRICK>LISP.MAC.12, 23-May-79 23:07:49, Edit by FRICK
  81. ;
  82. ;The assembler switch APPL is defined. When on (off by default), EVAL
  83. ; return its arg when undefined function or unbound variable.
  84. ;<FRICK>LISP.MAC.11, 21-May-79 10:22:03, Edit by FRICK
  85. ;
  86. ;%SOSSWAP is now under assembler switch SOSSW that is off by default
  87. ;<FRICK>LISP.MAC.9, 17-May-79 15:29:09, Edit by FRICK
  88. ;
  89. ;%SOSSWAP and %SWAP only defined if OPSYS is > 0 (TENEX)
  90. ;
  91. ;If switch JSYXEQ is on then functions JSYS, %XEQ, ERRSTR and GETAB$ are defined
  92. ;<FRICK>LISP.MAC.7, 10-May-79 14:43:10, Edit by FRICK
  93. ;
  94. ;EOL conversion is now only done on input, not in READ0 routine used by
  95. ; COMPRESS or internal string reader READP1.
  96. ;The EOL conversion has further been changed so that CR, LF and FF are
  97. ; converted as follows:
  98. ; a CR is ignored if the next character is LF, FF or CRLF,
  99. ; a LF is converted to CRLF,
  100. ; a FF is converted to CRLF followed by FF.
  101. ;<FRICK>LISP.MAC.3, 4-May-79 18:12:32, Edit by FRICK
  102. ;
  103. ;Change unsafe BLT in ARGPDL
  104. ;<FRICK>LISP.MAC.16, 17-Apr-79 13:52:39, Edit by FRICK
  105. ;Call GET jsys as JSYS 200 to avoid name clash. Use SAV or EXE depending
  106. ; on OPSYS switch.
  107. ;<FRICK>LISP.MAC.15, 9-Apr-79 13:48:00, Edit by FRICK
  108. ;
  109. ;Removed <ht> in macro ML1 that gives problems in older MACRO versions
  110. ;<FRICK>LISP.MAC.14, 1-Apr-79 16:15:23, Edit by FRICK
  111. ;
  112. ;This file has been renumbered.
  113. ;<FRICK>LISP.MAC.13, 29-Mar-79 15:14:41, Edit by FRICK
  114. ;
  115. ;If the argument to FREEZE is true then the special stack is unbound
  116. ; to top level before halting. FREEZE checks if memory allocation is
  117. ; necessary when restarting if the argument is true.
  118. ;<FRICK>LISP.MAC.12, 27-Mar-79 18:00:20, Edit by FRICK
  119. ;
  120. ;The TYI routine now reads all characters exept ^Z but including % and
  121. ; null. This means that READCH reads % and null.
  122. ;<FRICK>LISP.MAC.5, 13-Mar-79 17:37:43, Edit by FRICK
  123. ;
  124. ;RDSLSH now knows about %. (RDSLSH T) sets % to be a normal letter,
  125. ; (RDSLSH NIL) sets % to be comment start.
  126. ;<FRICK>LISP.MAC.4, 12-Mar-79 16:31:30, Edit by FRICK
  127. ;
  128. ;Corrected bug in sixbit messages generated by prevoious edit, now
  129. ; generates EOL output again.
  130. ;
  131. ;*ECHO flag is now tested before *RAISE flag so that the status of
  132. ; *RAISE doesn't affect the echoed character.
  133. ;
  134. ;Corrected bug in MAPCAN, MAPCON: They now work also when NIL is
  135. ; returned as value by the applied function.
  136. ;<FRICK>LISP.MAC.26, 13-Feb-79 15:25:31, Edit by FRICK
  137. ;
  138. ;The character strings CR LF and CR FF are now replaced with the single
  139. ; character CRLF (ascii 37) in the routine TYID that does all input.
  140. ;CRLF is converted back to CR and LF in the internal routine TYO that
  141. ; does all output. The only exeption to this is the Lisp function TYO,
  142. ; (TYO 37) still will output a ascii 37.
  143. ;$EOL$ has as value the character id CRLF, so that READCH now returns
  144. ; the value of $EOL$ at end of line and PRINC $EOL$ is equivalent to
  145. ; TERPRI.
  146. ;SCAN now returns an interned character id in SCNVAL when seeing a
  147. ; delimiter. Because of this, UNTYI is replaced with UNREADCH that is
  148. ; similar but takes a character id as argument instead of ascii code.
  149. ;
  150. ;% now indicates start of a comment that ends with CRLF. Everything from
  151. ; % to (but not including) CRLF will be transparent to READ but not to
  152. ; READCH. SCAN has initially the same start and end of comment as READ
  153. ; and it will also not ignore the comment end character. As a consequence
  154. ; a comment can only be placed where a CRLF is legal. The special
  155. ; comment that starts with a ^Z and ends with CRLF does ignore the CRLF
  156. ; so that it can be placed anywhere.
  157. ;
  158. ;(AND) returns T.
  159. ;<FRICK>LISP.MAC.6, 31-Jan-79 14:03:36, Edit by FRICK
  160. ;
  161. ;READCH and EXPLODE are speeded up by maintaining an array of all
  162. ; interned character ids. This array is initially zero, but it is
  163. ; updated by INTERN and REMOB.
  164. ;<FRICK>LISP.MAC.4, 29-Jan-79 17:37:09, Edit by FRICK
  165. ;
  166. ;EXPLODE, READ (and COMPRESS) checks that they have the right scanner
  167. ; table and temporarily switches table if necessary. If an error occurs,
  168. ; this will leave the tables as if (SCANSET NIL) had been executed.
  169. ;<FRICK>LISP.MAC.1, 25-Jan-79 14:41:23, Edit by FRICK
  170. ;
  171. ;Corrected bug in EVAL when calling compiled EXPR with more than 5 args.
  172. ;<FRICK>LISP.MAC.13, 3-Jan-79 17:48:17, Edit by FRICK
  173. ;
  174. ;The use of L as indicator of octal numbers is now controlled by the
  175. ; switch ROCT. If ROCT is on then the change in edit of 26-Nov-78 is
  176. ; implemented, otherwise it is not.
  177. ;
  178. ;The symbol ILLAD is defined as the illegal address that generates a garbage
  179. ; collection. Setting it to 775777 (-2001) instead of 777777 (-1) seems to
  180. ; allewiate the problems mentioned in edit 25-Oct-78. For this reason
  181. ; CNSPRB is off by default in all versions of the system.
  182. ;
  183. ;The ^Z that indicates an ignored cr-lf is now not output if output is
  184. ; going to the terminal.
  185. ;
  186. ;The HALT that ended FREEZE in the Tops-10 version, is changed to EXIT 1, .
  187. ;<FRICK>LISP.MAC.7, 26-Nov-78 19:55:50, Edit by FRICK
  188. ;
  189. ;A number ended by the letter L, is read as an octal number also when
  190. ; the value of IBASE is not 8. When the value of BASE is 8, then end
  191. ; integers whith L when printed by PRIN1 but not when printed by PRIN2.
  192. ;<FRICK>LISP.MAC.1, 8-Nov-78 18:59:12, Edit by FRICK
  193. ;
  194. ;An atom as first argument to OPEN means a filename for a file on DSK:
  195. ; with blank extension.
  196. ;<FRICK>LISP.MAC.29, 3-Nov-78 17:15:24, Edit by FRICK
  197. ;
  198. ;Define SYM entry LMKSTR to make a Lisp string from top of SPDL
  199. ;<FRICK>LISP.MAC.28, 1-Nov-78 18:11:11, Edit by FRICK
  200. ;
  201. ;Make SETPCHAR return previous prompter as a non-interned identifier
  202. ;<FRICK>LISP.MAC.25, 25-Oct-78 19:10:13, Edit by FRICK
  203. ;
  204. ;Define an assembler switch CNSPRB, that when on will insert two instructions
  205. ; in the cons routine. These instructions will check explicitly for end
  206. ; of the free list instead of detecting the need for garbage collection
  207. ; by an illegal memory reference that occurs when the free list is empty.
  208. ; Explicit checking is slightly slower, but there seems to be some problems
  209. ; with the illegal memory reference mechanism on some virtual memory
  210. ; versions of the Tops-10 monitor.
  211. ;<FRICK>LISP.MAC.24, 26-Sep-78 16:38:51, Edit by FRICK
  212. ;
  213. ;Garbage collector now marks from reg REL also.
  214. ;<FRICK.SLSHEEP>LISP.MAC.2, 24-Sep-78 16:38:49, Edit by FRICK
  215. ;
  216. ;Declare some more symbols internal.
  217. ;<FRICK>LISP.MAC.17, 18-Sep-78 19:22:04, Edit by FRICK
  218. ;
  219. ;Fix bug in GCGAG output, so that it works also when number of cells
  220. ; collected are more than an INUM.
  221. ;<FRICK>LISP.MAC.11, 3-Sep-78 17:11:44, Edit by FRICK
  222. ;
  223. ;LINELENGTH now checks that its argument is NIL or greater than 0.
  224. ;PAGELENGTH now checks that its argument is NIL or greater than or equal to 0.
  225. ;
  226. ;DIGIT and LITER now returns NIL if their argument is not an
  227. ; interned id with a one character print name.
  228. ;<FRICK>LISP.MAC.7, 27-Aug-78 15:44:35, Edit by FRICK
  229. ;
  230. ;The ERROR print routine (also used by WARNING) doesn't relay any
  231. ;more on register T being saved. The stack is used instead.
  232. ;<FRICK>LISP.MAC.6, 24-Aug-78 16:53:44, Edit by FRICK
  233. ;(EQUAL 1 1.0) now returns NIL instead of T.
  234. ;
  235. ;The first argument to REMFLAG is a list whose elements now not
  236. ; have to be ids. REMFLAG does nothing for those that aren't ids.
  237. ;
  238. ;SUBR and FSUBR are now completely replaced by EXPR and FEXPR.
  239. ;For compatibility reason FASLOD will convert (F)SUBR to (F)EXPR and
  240. ;give a message about it the end of each load.
  241. ;
  242. ;Digits in DIGIT, EXPLODE and READCH are now character ids, not INUMs.
  243. ;
  244. ;The initialization file LISP.LSP is renamed to LISP.SL.
  245. ;<FRICK>LISP.MAC.2, 20-Aug-78 18:10:26, Edit by FRICK
  246. ;
  247. ;Make PATOM available as a SUBR.
  248. ;<FRICK>LISP.MAC.254, 1-Aug-78 17:49:50, Edit by FRICK
  249. ;
  250. ;Define Fasload type 11 to be similar to 13 but the codepointer
  251. ; is put on the property list with PUT instead of PUTD.
  252. ;<FRICK>LISP.MAC.252, 27-Jul-78 18:53:43, Edit by FRICK
  253. ;
  254. ;Make ERREx print the left half of register A if it isn't 0.
  255. ;This involves a change to PRINL also.
  256. ;Make a small change to PRINEL and remove PRIN1B that now is unnecessary.
  257. ;<FRICK>LISP.MAC.250, 25-Jul-78 23:52:04, Edit by FRICK
  258. ;
  259. ;Include this list of changes and renumber pages.
  260. ;<FRICK>LISP.MAC.245, 22-Jul-78 19:46:45, Edit by FRICK
  261. ;
  262. ;Set *ERRMSG to T on toplevel only if it is NIL.
  263. ;
  264. ;Make the OP routine (i.e. all binary numerical routines) check
  265. ;first that the arguments are numbers so that the error message
  266. ;"x IS NOT A NUMBER" gets the right "x".
  267. ;
  268. ;The garbage collector now also marks from the top element of
  269. ;the SPDL.
  270. ;<FRICK>LISP.MAC.238, 14-Jul-78 13:50:27, Edit by FRICK
  271. ;
  272. ;RETURN and GO now works in other than the last statement in
  273. ;a PROGN.
  274. ;
  275. ;SKIPTO now initialize register AR4 so that it doesn't think
  276. ;everything is EDIT or SOS line numbers.
  277. ;<FRICK>LISP.MAC.237, 10-Jul-78 01:21:58, Edit by FRICK
  278. SUBTTL HISTORY OF CHANGES --- PAGE 1
  279. ;
  280. ;COPYRIGHT (C) 1979 University of Utah.
  281. ;
  282. ;Permission to copy without fee all or part of this material is granted
  283. ;provided that copies are not made or distributed for direct commercial
  284. ;advantage, the Utah copyright notice and the title of the program and
  285. ;its date appear, and notice is given that copying is by permission of
  286. ;the University of Utah. To copy otherwise, or to republish, requires a
  287. ;fee and/or specific permission.
  288. ;
  289. SUBTTL AC DEFINITIONS AND EXTERNALS --- PAGE 2
  290. TITLE LISP INTERPRETER
  291. COMMENT  TABLE OF CONTENTS
  292. 1. History of changes
  293. 2. Assembling switches, AC Definitions, Symbols and Externals
  294. 3. Top Level and Initialization
  295. 4. APR Interrupt routines
  296. 5. UUO Handler and SUBR-call routines
  297. 6. ERROR Handler and Backtrace
  298. 7. TYI and TYO
  299. 8. INPUT and OUTPUT initialization and control
  300. 9. PRINT
  301. 10. READ and SCANner tables
  302. 11. Interpretive routines of LISP
  303. 12. Arithmetic routines
  304. 13. Bignum routines
  305. 14. Gfpak. Galois field package
  306. 15. EXPLODE, READLIST, FLATSIZE, etc.
  307. 16. EVAL and APPLY and bindings
  308. 17. ARRAY, EXARRAY, STORE
  309. 18. EXAMINE, DEPOSIT, BOOLE
  310. 19. Garbage Collector
  311. 20. GETSYM, PUTSYM and R50MAK
  312. 21. FASLOAD, FASLOD
  313. 22. ED - Alvine
  314. LOAD
  315. EXCISE, MORCOR, MOVSYM, etc.
  316. 23. FILEP
  317. SOSSWAP
  318. JSYS, GETAB#, XEQ
  319. 24. RBLK, WBLK
  320. 25. CORE, ALLOC
  321. 26. SETSYS, LSSAVE
  322. 27. Re-allocate code after a ST
  323. REHASH
  324. 28. Lisp atoms and initial OBLIST
  325. BPS, FS, FWS
  326. 29. Once-only Lisp Storage Allocator
  327. 
  328. PAGE
  329. COMMENT  General differences from Stanford's 1.6 are:
  330. 1) Octal ppns,
  331. 2) Explicit i/o for SOS-linkage,
  332. 3) The '*' prompt-char can be dynamically changed, to
  333. consist of up to 4 characters;
  334. 4) The subr CORE(n) is used to increase (or partially cut) core;
  335. 5) The subr ALLOC() just goes to LISPGO to alloc new core;
  336. 6) Altmode can be typed as 33 or 175.
  337. 7) Binary-I/O (36-bit) by INBIN,OUTBIN,BINI,BINO.
  338. 8) BPS & EXAMINE,DEPOSIT may address to 256K, vs old 64K limit.
  339. 9) RBLK,WBLK can manipulate overlay-blocks in BPS as files.
  340. Assembles for TOPS-20, TENEX or TOPS-10, operating systems
  341. depending on the setting of the variable OPSYS.
  342. N.B. Code for TENEX and TOPS-20 in CHKACS, CHKAC0, SETAPR
  343. makes assumptions about PA1050's acc and ^O handler locations.
  344. OPSYS is set here 
  345. ;OPSYS==0 ;Assembles for TOPS-10.
  346. ;OPSYS==1 ;Assembles for TENEX
  347. OPSYS==-1 ;Assembles for TOPS-20.
  348. IFNDEF OPSYS,<OPSYS==-1> ;TOPS-20 is default
  349. ;When OPSYS not is zero, this has the following effects:
  350. ; 1) The 10x psi is enabled for 10/50 ^O (simulated);
  351. ; 2) The swapout for the SOS-link is done as an inferior fork,
  352. ; which returns to LISPGO, unless using LISP.TNX patchs.
  353. ; 3) The initial start-up questions are slightly changed.
  354. ;SYDEV==1 ;When on has the following effects:
  355. ; 1) An initial question for system device or directory
  356. ; to use as SYS: device:
  357. ; For TENEX version asks for system directory number
  358. ; (default: number for <REDUCE>, or if that not
  359. ; exists, the users directory).
  360. ; For TOPS-10 or -20 version asks for system device
  361. ; name (default: SYS: ).
  362. ; 2) The subr SETSYS is used to dynamically change SYS: .
  363. ;CNSPRB==1 ;When on, will check explicitly for the end of the free list,
  364. ; instead of detecting it by an illegal memory reference.
  365. ;STL==0 ;When on, will assemble for Standard Lisp
  366. ;OCTPPN==0 ;When off, will assemble for SU-AI's PPNs.
  367. MOD==1 ;When on, will assemble GFPAK modular arithmetics
  368. ;ALOD==1 ;When on will assemble LOAD, *PUTSYM and *GETSYM.
  369. ;AED==1 ;When on will assemble ED and GRINDEF interface.
  370. ;NFLD==0 ;When off dont assemble new FASLOD
  371. OFLD==1 ;When on, assemble old FASLOAD
  372. ;RWB==1 ;When on will assemble WBLK and RBLK.
  373. ;ASARY==1 ;When on will assemble array routines
  374. EPDL==0 ;When on, will create a 3rd pdl pointed to by EP
  375. ;FNRG==0 ;When on, will assemble funarg features
  376. ;HCBPS==1 ;When on puts BPS in high core
  377. ;SZBPS==1 ;When on, size of BPS is user decidable, and EXCORE defined.
  378. ;ROCT==1 ;When on will read an integer followed by L as octal
  379. ;JSYXEQ==0 ;When off, will not define JSYS, %XEQ, ERRSTR and GETAB$
  380. ;SOSSW==1 ;When on assembles %SOSSWAP, used by SOSLINK
  381. ;APPL==1 ;When on, EVAL returns arg when undefined
  382. PAGE
  383. ;Default values for switches
  384. IFE OPSYS,<IFNDEF HCBPS,HCBPS==0 ;(Default low core for 10/50)
  385. IFNDEF SZBPS,SZBPS==1
  386. IF1,PRINTX Note: being assembled for TOPS-10, not TENEX or TOPS-20.
  387. SEARCH UUOSYM
  388. JSYXEQ==0 ; JSYSes not defined in TOPS-10
  389. IFNDEF OCTPPN,<
  390. OCTPPN==1
  391. IF1,PRINTX Note: if for SU-AI, reassemble with OCTPPN==0 >>
  392. IFN OPSYS,<IFNDEF HCBPS,HCBPS==1 ;(Default high core 400000:676776)
  393. IFNDEF SZBPS,SZBPS==0
  394. OCTPPN==1 > ;Permit (0,nnn) format if desired.
  395. IFL OPSYS,<SEARCH MONSYM
  396. IF1,PRINTX Note: being assembled for TOPS-20, not TENEX or TOPS-10. >
  397. IFG OPSYS,<SEARCH STENEX
  398. OPDEF ERJMP [JUMP 16,]
  399. IF1,PRINTX Note: being assembled for TENEX, not TOPS-10 or TOPS-20. >
  400. IFNDEF STL,<STL==1>
  401. IFN STL,<
  402. IFNDEF AED,AED==0
  403. IFNDEF ALOD,ALOD==0
  404. IFNDEF RWB,RWB==0
  405. IFNDEF ASARY,ASARY==0>
  406. IFNDEF SYDEV,<SYDEV==1> ;Default: SYDEV is on.
  407. IFNDEF CNSPRB,<CNSPRB==0>
  408. IFNDEF MOD,<MOD==0>
  409. IFNDEF ALOD,<ALOD==1>
  410. IFNDEF AED,<AED==1>
  411. IFNDEF RWB,<RWB==1>
  412. IFNDEF ASARY,<ASARY==1>
  413. IFNDEF NFLD,<NFLD==1>
  414. IFNDEF OFLD,<OFLD==0>
  415. IFNDEF EPDL,<EPDL==0>
  416. IFNDEF APPL,<APPL==0>
  417. IFNDEF FNRG,<FNRG==1>
  418. IFNDEF HCBPS,HCBPS==1
  419. IFNDEF SZBPS,SZBPS==1
  420. IFE HCBPS,SZBPS==1
  421. IFNDEF ROCT,<ROCT==0>
  422. IFNDEF JSYXEQ,<JSYXEQ==1>
  423. IFNDEF SOSSW,<SOSSW==0>
  424. PAGE
  425. TEN==^D10
  426. INUMIN=377777 ;Lower limit of INUMs.
  427. BCKETS==77
  428. INITBPS== 2000 ;Initial (default) size of BPS.
  429. INITCORE==^D12*2000-1 ;Initial (default) size of Lisp core .
  430. MAXCORE==^D124 ;Maximum size of Lisp core, to allow for I/O buffers.
  431. MINFBPS==1000 ;Necessary BPS for Fap bootstrap fisltable
  432. BOTBPS==1320 ;Necessary BPS for Fap loaded functions
  433. ILLAD==775777 ;Illegal address to generate interrupt when free list exhausted.
  434. ;Atom type tags
  435. ID=1000000-1 ;identifier
  436. CODE=ID-1 ;code pointer
  437. CODMIN==CODE
  438. VECT=CODE-1 ;vector
  439. STRNG=VECT-1 ;string
  440. FLONU=STRNG-1 ;floating point number
  441. FIXNU=FLONU-1 ;single word integer
  442. POSNU=FIXNU-1 ;positive bignum. Must be odd
  443. NEGNU=POSNU-1 ;negative bignum
  444. ATMIN=NEGNU-1 ;addresses bigger than this, are atom tags.
  445. INUM0=1+<INUMIN+ATMIN>/2
  446. IFN <ATMIN+INUMIN-2*INUM0>,<INUMIN=INUMIN+1>
  447. DEFINE PR%%IN (XX)<
  448. PRINTX Maximum INUM modulus is XX
  449. >
  450. IF1,<XX==ATMIN-INUM0
  451. PR%%IN \XX >
  452. PAGE
  453. ;Accumulator definitions
  454. ;'sacred' means sacred to the interpreter
  455. ;'marked' means marked from right and left half by the garbage collector
  456. ;'protected' means protected during garbage collection
  457. NIL=0 ;sacred, marked, protected ;atom head of NIL
  458. A=1 ;marked, protected ;results of functions and first arg of subrs
  459. B=A+1 ;marked, protected ;second arg of subrs
  460. C=B+1 ;marked, protected ;third arg of subrs
  461. AR4=4 ;marked, protected ;fourth arg of subrs (old AR1)
  462. AR5=5 ;marked, protected ;fifth arg of subrs (old AR2A)
  463. T=6 ;marked, protected ;minus number of args internaly
  464. TT=7 ;marked, protected
  465. REL=10 ;marked, protected ;rarely used
  466. IFE EPDL,<
  467. EP==14
  468. S=11 >
  469. IFN EPDL,<
  470. S==11
  471. EP=11 ;sacred, protected ;exp push down stack pointer >
  472. D=12
  473. R=13 ; protected
  474. P=14 ;sacred, protected ;regular push down stack pointer
  475. F=15 ;sacred ;free storage list pointer
  476. FF=16 ;sacred ;full word list pointer
  477. SP=17 ;sacred, protected ;special pushdown stack pointer
  478. NACS==5 ;number of argument acs
  479. NSUA==16 ;maximum number of subr arguments
  480. X==0 ;X indicates impure (modified) code locations
  481. ; Added Inst-definitions for legibility...
  482. OPDEF PCALL [PUSHJ P,]
  483. OPDEF PRET [POPJ P,]
  484. OPDEF PSAVE [PUSH P,]
  485. OPDEF PREST [POP P,]
  486. OPDEF PSKPRT [AOS (P)]
  487. OPDEF P1DROP [SUB P,[1,,1]]
  488. OPDEF P2DROP [SUB P,[2,,2]]
  489. OPDEF P3DROP [SUB P,[3,,3]]
  490. OPDEF PXDROP [SUB P,]
  491. OPDEF CARA [HLRZ ]
  492. OPDEF CDRA [HRRZ ]
  493. OPDEF RPLCA [HRLM ]
  494. OPDEF RPLCD [HRRM ]
  495. PAGE
  496. ;UUO definitions
  497. ;UUOs used to call functions from compiled code
  498. ;the number of arguments is given by the ac field
  499. ;the address is a pointer either to the function
  500. ;name or the code of the function
  501. OPDEF FCALL [34B8] ;ordinary function call-may be changed to PCALL
  502. OPDEF JCALL [35B8] ;terminal function call-may be changed to JRST
  503. OPDEF CALLF [36B8] ;like FCALL but may not be changed to PCALL
  504. OPDEF JCALLF [37B8] ;like JCALL but may not be changed to JRST
  505. ;error UUOs
  506. UOERRE==1
  507. UOERRL==10
  508. UOERRG==20
  509. UOERRI==21
  510. USTRTP==22
  511. ;ERRL and ERRE spans more than one UUO, to allow for larger ac-field
  512. ;Ac-field contains error number.
  513. OPDEF ERRE1 [1B8] ; 1 ;print expression, ordinary lisp error, bactrace
  514. OPDEF ERRE2 [2B8] ; 2
  515. OPDEF ERRE3 [3B8] ; 3
  516. OPDEF ERRE4 [4B8] ; 4
  517. OPDEF ERRE5 [5B8] ; 5
  518. OPDEF ERRE6 [6B8] ; 6
  519. OPDEF ERRE7 [7B8] ; 7
  520. OPDEF ERRL0 [10B8] ; 8 ;ordinary lisp error ;gives backtrace
  521. OPDEF ERRL1 [11B8] ; 9
  522. OPDEF ERRL2 [12B8] ; 10
  523. OPDEF ERRL3 [13B8] ; 11
  524. OPDEF ERRL4 [14B8] ; 12
  525. OPDEF ERRL5 [15B8] ; 13
  526. OPDEF ERRL6 [16B8] ; 14
  527. OPDEF ERRL7 [17B8] ; 15
  528. OPDEF ERRG [20B8] ; 16 ;space overflow error ;no backtrace
  529. OPDEF ERRI [21B8] ; 17 ;ill. mem. ref.
  530. OPDEF STRTIP [22B8] ; 18 ;print error message and continue
  531. PAGE
  532. ;system UUOs
  533. OPDEF TTYUUO [51B8]
  534. OPDEF INCHRW [TTYUUO 0,]
  535. OPDEF OUTCHR [TTYUUO 1,]
  536. OPDEF OUTSTR [TTYUUO 3,]
  537. OPDEF INCHWL [TTYUUO 4,]
  538. OPDEF INCHSL [TTYUUO 5,]
  539. OPDEF CLRBFI [TTYUUO 11,]
  540. OPDEF SKPINC [TTYUUO 13,]
  541. OPDEF TALK [PCALL TTYCLR] ;this is to turn off control O.
  542. ;when ttyser lets you do this
  543. ;easily, change me
  544. ;system uuos
  545. DEVCHR==4
  546. CORE==11
  547. RESET==0
  548. APRINI==16
  549. MSTIME==23
  550. STIME==27
  551. SETUWP==36
  552. PAGE
  553. ;I/O bits and constants
  554. LNPRVT==6 ;lines per vertical tab
  555. TTYPL==0 ;teletype pagelength. No paging
  556. LPTPL==0 ;line printer pagelength. No paging
  557. TTYLL==105 ;teletype linelength
  558. LPTLL==160 ;line printer linelength
  559. MLIOB==203 ;max length of I/O buffer
  560. NIOB==2 ;no of I/O buffers per device
  561. NIOCH==17 ;number of I/O channels
  562. FSTCH==1 ;first I/O channel
  563. TTCH==0 ;teletype I/O channel
  564. BLKSIZE==NIOB*MLIOB+COUNT+1
  565. INB==2
  566. OUTB==1
  567. AVLB==40
  568. DIRB==4
  569. ;special ASCII characters
  570. ALTMOD==175 ;LISP'S ALTMODE (TENEX-PA1050 & SU-AI) 33'S CONVERTED.
  571. IGCRLF==32 ;ignored cr-lf
  572. RUBOUT==177
  573. CRLF==37 ;TYID converts the sequence CR LF or CR FORMF to CRLF. TYO converts back.
  574. LF==12
  575. CR==15
  576. TAB==11
  577. BELL==7
  578. DBLQT==42 ;double quote "
  579. VT==13 ;vertical tab
  580. FORMF==14 ;form feed
  581. ;byte pointer field definitions
  582. ACFLD==^D12 ;ac field
  583. XFLD== ^D17 ;index field
  584. OPFLD==^D8 ;opcode field
  585. SIGN==400000 ;sign marker for bignums
  586. PAGE
  587. ;external and internal symbols
  588. EXTERNAL .JB41 ;instruction to be executed on UUO
  589. EXTERNAL .JBAPR ;address of APR interupt routines
  590. EXTERNAL .JBCNI ;interupt condition flags
  591. EXTERNAL .JBFF ;first location beyond program
  592. EXTERNAL .JBREL ;address of last legal instruction in core image
  593. EXTERNAL .JBREN ;reentry address
  594. EXTERNAL .JBSA ;starting address
  595. EXTERNAL .JBSYM ;address of symbol table
  596. EXTERNAL .JBTPC ;program counter at time of interupt
  597. EXTERNAL .JBUUO ;uuo is put here with effective address computed
  598. EXTERNAL .JBHRL ;RH= High-segment .JBREL, LH set 0.
  599. ;apr flags
  600. PDOV==200000 ;push down list overflow
  601. MPV==20000 ;memory protection violation
  602. NXM==10000 ;non-existant memory referenced
  603. APRFLG==PDOV+MPV+NXM ;any of the above
  604. ;foolst macros: these get relocated (RH addr) relative to FS.
  605. DEFINE FOO <
  606. XLIST
  607. BAZ (\FOOCNT)
  608. LIST
  609. >
  610. DEFINE BAZ (X)
  611. <FOOCNT=FOOCNT+1
  612. FOO'X:!
  613. SUPPRESS FOO'X
  614. >
  615. FOOCNT=0
  616. SUBTTL TOP LEVEL AND INITIALIZATION --- PAGE 3
  617. LISPGO: SETOM RETFLG# ;enter via INITFN
  618. JRST STRT ;go to re-allocator
  619. DEBUGO: SETZM RETFLG ;clear return flag to allow INITFN to be changed
  620. JSR CHKACS ;entry point to get into read-eval-print loop
  621. JUMPN A,LSPRT2 ; without unbinding spec pdl...
  622. ;If NIL looks like an atomheader, we skip
  623. ; reseting the ACCs, etc, else refresh...
  624. START: CALLI RESET ;Initializations for lisp interrupts...
  625. JSR APRSET ;Set up APRs and Tenex ^chars.
  626. JSR CHKAC0 ;Reset NIL if necessary, else retain any user additions.
  627. IFN AED,SETZM PSAV1
  628. FOO SETZB 1,VERMSG
  629. MOVE 17,[1,,2]
  630. BLT 17,17 ;clear acs, other than NIL.
  631. MOVEI F,ILLAD ;empty fs list
  632. LSPRT1: MOVE P,C2# ;Initialize regular PDL.
  633. IFN EPDL,MOVE EP,EC2# ;initialize EPDL
  634. SKIPE SP,SPSAV#
  635. PCALL TUNBIND ;Unbind spec pdl to top
  636. MOVE SP,SC2# ;Initialize special PDL.
  637. PUSH SP,[0] ;mark for unbind
  638. FOO MOVEI B,TRUTH
  639. FOO SKIPN ERRSW ;only change if NIL
  640. FOO MOVEM B,ERRSW ;print error messages
  641. SETZM ERRTN ;return to top level on errors
  642. SETOM PRVCNT# ;initialize counter for errio
  643. IFN OPSYS,SETZM KBINTF
  644. SETZM EXARG ;Delete content of
  645. MOVE A,[EXARG,,EXARG+1] ; extended ascs to
  646. BLT A,EXARG+NSUA-NACS-1 ; allow gc
  647. LSPRT2: PCALL TTYRET ;Return output for gc msg.
  648. JSR CHKNIL ;initialize nil
  649. SKIPE HASHFG#
  650. JRST REHASH ;rehash if necessary
  651. SKIPN FF
  652. PCALL AGC2 ;garbage collect only if necessary
  653. SETZM GCFFLG#
  654. SKIPN BSFLG# ;initial bootstrap for macros
  655. JRST BOOTS
  656. SKIPE BPSFLG#
  657. JRST BINER2 ;BPS OVERFLOW DURING A (LOAD T).
  658. SKIPN RETFLG ;test for error return
  659. JRST LISP2
  660. FOO SKIPE A,INITF
  661. CALLF 0,(A) ;evaluate initialization function
  662. SETZM RETFLG
  663. LISP2: PCALL TTYRET ;return all i/o to tty
  664. PCALL TERPRI
  665. SKIPE GOBF# ;garbaged oblist flag
  666. STRTIP [SIXBIT /_***** GARBAGED OBLIST_!/]
  667. SETZM GOBF
  668. LISP1: PCALL READ ;this is the top level of lisp
  669. PCALL EVAL
  670. PCALL TERPRI
  671. PCALL PRINT
  672. PCALL TERPRI
  673. JRST LISP1
  674. PAGE
  675. ;return from lisp error
  676. LSPRE: CLRBFI ;clear input buffer
  677. FOO SKIPE RSTSW
  678. JRST LISP2 ;(*rset t) goes to read-eval-print loop without unbind
  679. LSPRET: MOVE P,C2 ;return from bell
  680. PCALL TERPRI
  681. IFN AED,<SKIPE P,PSAV1# ;bell from alvine?
  682. JRST [HRRZ REL,ED ;yes, return to alvine
  683. JRST 1(REL)]> ;improved magic
  684. MOVEM SP,SPSAV ;force unbinding of spec pdl
  685. SETOM RETFLG ;set return flag
  686. JRST LSPRT1
  687. ;bootstrapper for macro definitions & Lisp extensions...
  688. BOOTS: SETOM BSFLG
  689. MOVEI A,BSTYI
  690. PCALL READP1
  691. PCALL EVAL
  692. PCALL READ ;last prog calls ERR, back to LISP1.
  693. JRST .-2
  694. BSTYI: ILDB A,[POINT 7,[ASCII /(RDS(OPEN '(SYS:(LISP.SL)) 'INPUT))/]]
  695. PRET
  696. PAGE
  697. ;Verify that NIL is a good atom, perhaps with user properties,
  698. ; else reset it (AC0) to be the Urlisp atomheader...
  699. IFN OPSYS,<
  700. CHKACS: X ;Tenex-Pa1050 needs to be clever about ^C's.
  701. CALLI A,MSTIME ;Do a simple op to ensure PA1050 exists.
  702. JSR CHKNIL
  703. JUMPN A,@CHKACS ;Didn't have to fix it,
  704. MOVE NIL,@700032 ; else check last ac0 saved in PA1050.
  705. JSR CHKNIL
  706. JUMPE A,@CHKACS ; Not ok either, have to refresh all accs.
  707. HRLZ 17,700032 ;Was ok, so grab the save-acc blk
  708. BLT 17,17 ; from PA1050's area.
  709. JRST CHKACS+2 ;Set ac1 non0 and return successfully.
  710. CHKAC0: X ;Setup 0 without worrying about 1:17.
  711. JSR CHKNIL
  712. JUMPN A,@CHKAC0 ;Tenex's was ok,
  713. MOVE NIL,@700032
  714. JSR CHKNIL
  715. JRST @CHKAC0 > ; or PA1050's, else CNIL2 reset.
  716. CHKNIL: X ;Yet another impure loc, for JSRing.
  717. JSP TT,CHKNI1
  718. JUMPN A,@CHKNIL ; o.k.
  719. MOVE NIL,CNIL3 ; refresh NIL
  720. MOVEI A,NIL ;Return 0 if have to reset...
  721. JRST @CHKNIL
  722. CHKNI1: HLRO A,NIL
  723. AOJN A,SETNIL ;LH not -1.
  724. CDRA A,NIL
  725. CAILE A,@GCPP1 ;(base of FS)
  726. CAIL A,@GCP1 ;(base of FWS)
  727. JRST SETNIL ; proplist addr not in FS.
  728. FOO MOVEI B,VALUE
  729. GETNIL: MOVS C,(A) ;Make sure it has a VALUE cell,
  730. MOVS A,(C)
  731. CAIN B,(A) ; else EVAL would say "#0 Unbound Variable".
  732. JRST GOTNIL
  733. CARA A,C
  734. JUMPN A,GETNIL
  735. JRST (TT)
  736. GOTNIL: HLRZS A ;We don't require this to be UrLisp's VNIL cell.
  737. SKIPE (A) ;Check that it points back to NIL tho,
  738. SETNIL: MOVEI A,NIL ; else reset it.
  739. JRST (TT) ;Return non0: didn't have to reset.
  740. IFE OPSYS,<CHKACS==CHKNIL ;Don't have to worry about separate
  741. CHKAC0==CHKNIL> ; PA1050 accs being present after a ^C.
  742. SUBTTL APR INTERRUPT ROUTINES --- PAGE 4
  743. ;arithmetic processor interupts
  744. ;mem. protect. violation, nonex. mem. or pdl overflow
  745. APRINT: MOVEM R,ACSAV+R
  746. MOVE R,.JBCNI ;get interrupt bits
  747. SETZM .JBCNI ;Clear for compiled-code Pdl check: <JUMPGE P,@.JBAPR>
  748. TRNE R,MPV+NXM ;what kind
  749. JRST ILLMEM
  750. JUMPN NIL,MES21 ;a pdl overflow
  751. STRTIP [SIXBIT /_***** PDL OVERFLOW FROM GC - CAN'T CONTINUE!/]
  752. JRST START
  753. MES21: SETZM .JBUUO
  754. SKIPL P
  755. ERRG ^D256,[SIXBIT /REG PUSHDOWN CAPACITY EXCEEDED!/]
  756. SKIPL SP
  757. SPDLOV: ERRG ^D257,[SIXBIT /SPEC PUSHDOWN CAPACITY EXCEEDED!/]
  758. IFN EPDL,<SKIPL EP
  759. ERRG ^D258,[SIXBIT /EXP PUSHDOWN CAPACITY EXCEEDED!/] >
  760. TRNN R,PDOV
  761. HALT ;lisp should not be here
  762. BINER2: SETZM BPSFLG
  763. ERRG ^D259,[SIXBIT /BINARY PROGRAM SPACE EXCEEDED!/]
  764. ILLMEM: LDB R,[POINT 4,@.JBTPC,XFLD] ;get index field of bad word
  765. CAIN R,F ;is it F ?
  766. CAIE F,ILLAD
  767. ERRI 2,@.JBTPC ;no! error
  768. PSAVE .JBTPC ;yes! save return address
  769. MOVEI R,APRFLG
  770. CALLI R,APRINI ; reset interupt,
  771. MOVEI R,AGC1
  772. JRSTF @R ; garbage collect and continue
  773. PAGE
  774. APRSET: 0 ;SET UP NECESSARY INTERRUPTS.
  775. MOVE A,[JSR UUOH]
  776. MOVEM A,.JB41
  777. MOVEI A,APRINT
  778. MOVEM A,.JBAPR
  779. MOVEI A,APRFLG
  780. CALLI A,APRINI ;THIS DOES THE 10/50 SETUP.
  781. IFE OPSYS,<
  782. IFN HCBPS,<
  783. SETZ A,
  784. CALLI A,SETUWP ;Necessary as RESET resets high core write bit.
  785. HALT >
  786. JRST @APRSET>
  787. IFN OPSYS,< ; and for TENEX (Accs 1&2 are free):
  788. MOVEI 1,400000 ;FORK HANDLE FOR THIS FORK.
  789. RIR ;GET THE PA1050 FILE'S LEVTAB,,CHNTAB.
  790. IFG OPSYS,<
  791. MOVE 1,[XWD 1,CHANL0]
  792. EXCH 1,^D30(2) ;Set channel addresses...
  793. HRRZS 1 ; Normally would just use chn 0 for ^O
  794. CAIL 1,700000 ; but PA1050 also diddles on chn 30,
  795. HRRM 1,CHANL0 > ; so do local CHANL0 then PA1050's CFOBF.
  796. MOVE 1,[XWD 1,CHANL1]
  797. MOVEM 1,1(2)
  798. MOVE 1,[XWD 1,CHANL2]
  799. MOVEM 1,2(2)
  800. MOVE 1,[XWD 1,CHANL3]
  801. MOVEM 1,3(2)
  802. IFG OPSYS,<
  803. MOVE 1,["O"-100,,^D30];Set terminal-characters...
  804. ATI >
  805. MOVE 1,["P"-100,,1]
  806. ATI
  807. MOVE 1,["E"-100,,2]
  808. ATI
  809. MOVE 1,["K"-100,,3]
  810. ATI
  811. MOVEI 1,400000
  812. IFG OPSYS,<MOVSI 2,(1B0+1B1+1B2+1B3)>
  813. IFL OPSYS,<MOVSI 2,(1B1+1B2+1B3)>
  814. AIC
  815. IFG OPSYS,SETZM CTRLOF# ;Init.
  816. SETZM KBINTF# ;Init.
  817. JRST @APRSET
  818. IFG OPSYS,<
  819. CHANL0: SETCMM CTRLOF ;Flip-flop the ^O flag.
  820. DEBRK >
  821. PAGE
  822. CHANL1: PSAVE 1 ; ^P HANDLER...
  823. PSAVE 2 ; Prints current file's <Line>/<Page>.
  824. PSAVE 3
  825. MOVEI 1," "
  826. PBOUT
  827. SKIPG LINUM
  828. JRST [MOVM 2,LINUM
  829. PCALL IPNUM
  830. JRST .+3]
  831. HRROI 1,LINUM
  832. PSOUT
  833. MOVEI 1,"/"
  834. PBOUT
  835. MOVE 2,PGNUM
  836. PCALL IPNUM
  837. IFG OPSYS,MOVEI 1,37
  838. IFL OPSYS,<MOVEI 1,CR
  839. PBOUT
  840. MOVEI 1,LF >
  841. PBOUT
  842. PREST 3
  843. PREST 2
  844. PREST 1
  845. DEBRK
  846. IPNUM: MOVEI 1,101
  847. ADDI 2,1
  848. MOVEI 3,^D10
  849. NOUT
  850. PRET
  851. PRET
  852. CHANL2: PSAVE 1
  853. HRROI 1,[ASCIZ /^E
  854. /]
  855. PSOUT
  856. PREST 1
  857. HLLOS KBINTF ;Flag RH -- next UUO becomes (ERR).
  858. DEBRK
  859. CHANL3: PSAVE 1
  860. HRROI 1,[ASCIZ /^K
  861. /]
  862. PSOUT
  863. PREST 1
  864. HRROS KBINTF ;Flag LH -- next UUO breaks out to top.
  865. DEBRK
  866. KBINTH: MOVE A,KBINTF ;Handle KB ^char now -- from UUOH, AGC, etc.
  867. SETZM KBINTF
  868. IFG OPSYS,SETZM CTRLOF
  869. TLNE A,-1 ;Which was it?
  870. JRST LSPRET ; ^K - escape to top-level.
  871. MOVEI A,NIL
  872. JRST ERR ; ^E - (ERR NIL) to ERRSET or top.
  873. > ;end of IFN OPSYS
  874. SUBTTL UUO HANDLER AND SUBR CALL ROUTINES --- PAGE 5
  875. UUOH: X ;jsr location
  876. MOVEM T,TSV#
  877. MOVEM TT,TTSV#
  878. LDB T,[POINT 9,.JBUUO,OPFLD] ;get opcode
  879. CAIGE T,34 ;is it a function call?
  880. JRST ERROR ;or a LISP error?
  881. IFN OPSYS,<
  882. SKIPE KBINTF ;Has user hit ^Chars on KB?
  883. JRST KBINTH ; Yes, handle it. >
  884. HRRZ TT,UUOH
  885. SOSA TT
  886. MOVEI TT,@(TT)
  887. LDB T,[POINT 9,(TT),OPFLD]
  888. CAIN T,256 ;Is it XCT
  889. JRST .-3
  890. HRRM TT,UUOCL-1
  891. LDB T,[POINT 5,.JBUUO,ACFLD]
  892. TRZN T,20
  893. PSAVE UUOH ;call|callf -- return addr.
  894. CARA R,@.JBUUO
  895. CAIE R,ID
  896. JRST UUOS ;if wasn't an id head, else...
  897. CAIE T,17
  898. TDZA R,R
  899. MOVEI R,1 ;R=0 if T=0-16, else 1(17).
  900. CDRA T,@.JBUUO
  901. FOO MOVEI D,FUNCELL
  902. UUOH1: JUMPE T,UUOH3
  903. MOVS TT,(T)
  904. MOVS T,(TT)
  905. CAIN D,(T)
  906. JRA T,UUOH2
  907. CARA T,TT
  908. JRST UUOH1
  909. PAGE
  910. UUOH2: CARA TT,T
  911. HRL T,.JBUUO ;name of function, for backtrace
  912. ;FOO CAIN TT,SUBR
  913. ; JRST @UUST(R)
  914. ;FOO CAIN TT,FSUBR
  915. ; JRST @UUFST(R)
  916. CARA D,(T)
  917. CAIE D,ID
  918. CAIGE D,CODMIN
  919. JRST .+2
  920. SUBI R,4 ;its a subr or fsubr
  921. FOO CAIN TT,EXPR
  922. JRST @UUET(R)
  923. FOO CAIN TT,FEXPR
  924. JRST @UUFET(R)
  925. UUOH4: HRRZ A,.JBUUO
  926. ERRE1 ^D16,[SIXBIT /UNDEFINED UUO!/] ;e.g., a MACRO or no def.
  927. UUOH3: PSAVE A
  928. PSAVE B
  929. HRRZ A,.JBUUO
  930. FOO MOVEI B,VALUE
  931. PCALL GET
  932. JUMPE A,UUOH4
  933. CDRA T,(A)
  934. HRL T,.JBUUO ;name of function, for backtrace
  935. PREST B
  936. PREST A
  937. JRST UUOEXP
  938. PAGE
  939. UUOSC: CDRA T,(T)
  940. UUOSBR:
  941. FOO SKIPE NOUUOF
  942. JRST UUOCL
  943. MOVE TT,.JBUUO
  944. HRLI T,(PCALL)
  945. TLNE TT,1000 ;1000 means no push
  946. HRLI T,(JRST)
  947. TLNN TT,2000 ;2000 means no clobber
  948. MOVEM T,X
  949. UUOCL: MOVE TT,TTSV
  950. MOVE R,T
  951. MOVE T,TSV
  952. JRST (R)
  953. UUOS: HRRZ T,.JBUUO ;If not an atomheader, what?
  954. CAIL R,CODMIN
  955. JRST UUOSC ; code pointer
  956. CAILE T,@GCPP1 ; Base of FS,
  957. CAIL T,@GCP1 ; FWS...
  958. JRST UUOSBR
  959. UUOEXP: PSAVE T ;<fn name or NIL,,func def>
  960. LDB T,ARGFLD
  961. JUMPE T,IAPPLY
  962. CAIN T,17
  963. MOVEI T,1
  964. MOVEI TT,IAPPLY
  965. SKIPA R,T
  966. ARGPDL: LDB R,ARGFLD
  967. ARGP1: HRLZ T,R
  968. ADD P,T
  969. JUMPGE P,MES21 ;check for stack overflow
  970. MOVEI T,1(P)
  971. HRLI T,A
  972. CAIG R,NACS
  973. JRST .+4
  974. BLT T,NACS(P)
  975. MOVEI T,NACS+1(P)
  976. HRLI T,EXARG
  977. ADDI P,(R)
  978. BLT T,(P)
  979. MOVNI T,(R)
  980. JRST (TT)
  981. EXARG: BLOCK NSUA-NACS+1
  982. ARGFLD: POINT 4,.JBUUO,ACFLD
  983. PAGE
  984. ;R=0 => compiler calling a -
  985. ;R=1 => compiler calling f type
  986. ;for an expr or fexpr that has a code pointer, 4 is subtracted
  987. ; from R, to map expr into subr and fexpr into fsubr
  988. UUST: UUOSC
  989. UUOS2 ;calling f (page 15 - EVAL).
  990. UUFST: UUOS9 ;calling - its a f
  991. UUOSC
  992. UUET: UUOEXP
  993. UUOS6 ;calling f its an expr (page 15 - EVAL).
  994. UUFET: UUOS3 ;calling - its a fexpr
  995. UUOEXP
  996. UUOSFE: HRRZ A,.JBUUO
  997. ERRE1 ^D17,[SIXBIT /CALLED AS EXPR!/]
  998. UUOS9: PSAVE T
  999. JSP TT,ARGPDL
  1000. MOVEI TT,UUOCL
  1001. QTLFY: MOVEI A,0 ;If AGC and GCGAG(T), can clobber
  1002. QTLFY1: JUMPE T,(TT) ; .JBUUO and UUOH, so saved in GC.
  1003. EXCH A,(P)
  1004. PCALL QTIFY
  1005. PREST B
  1006. PCALL CONS
  1007. AOJA T,QTLFY1
  1008. UUOS3: PSAVE T
  1009. JSP TT,ARGPDL
  1010. JSP TT,QTLFY
  1011. JRST UUOS3I
  1012. SUBTTL ERROR HANDLER AND BACKTRACE --- PAGE 6
  1013. ERRSUB: HRRZ A,.JBUUO ;Print SIXBITed messages (errors)...
  1014. JUMPE A,CPOPJ
  1015. HRLI A,(POINT 6,0)
  1016. MOVEM A,ERRPTR#
  1017. ERRORB: ILDB A,ERRPTR
  1018. CAIN A,01 ;conversion from sixbit
  1019. PRET
  1020. CAIN A,77
  1021. HRREI A,CRLF-40
  1022. ADDI A,40
  1023. PCALL TYO
  1024. JRST ERRORB
  1025. WHEAD: PCALL ERRIO
  1026. MOVEI B,3
  1027. JRST ERHED+2
  1028. ERHED: PCALL ERRIO
  1029. MOVEI B,5
  1030. PCALL TERPRI
  1031. MOVEI R,TYO
  1032. XCT "*",CTY
  1033. SOJG B,.-1
  1034. XCT " ",CTY
  1035. PRET
  1036. TOURET: PCALL TERPRI
  1037. ;subroutine to return output to previously selected device
  1038. OUTRET: SKIPL PRVCNT ;if prvcnt<0 then there was no device deselect
  1039. SOSL PRVCNT ;when prvcnt goes negative, then reselect
  1040. PRET
  1041. PSAVE PRVSEL# ;previously selected output
  1042. PREST TYOD
  1043. PRET
  1044. ;subroutine to force error messages out on tty
  1045. ERRIO:
  1046. FOO CDRA B,ERRSW
  1047. CAIE B,INUM0 ;inum0 => print message on selected device
  1048. AOSLE PRVCNT ;Deselected iff PRVCNT already <0.
  1049. PRET
  1050. TALK ;undo control o
  1051. MOVE B,[JRST TTYO]
  1052. EXCH B,TYOD
  1053. MOVEM B,PRVSEL
  1054. PRET
  1055. ERRTN: 0 ;0 => top level *
  1056. ;- => pdl to reset to - stored by errorset
  1057. ;+ => string tyo pout rtn flag
  1058. PAGE
  1059. ;subroutine to search oblist for closest function to address in R
  1060. ERSUB3:
  1061. JSR CHKNIL ;Reset AC0 if need be.
  1062. FOO MOVEI A,QST
  1063. HRLZ B,INT1
  1064. MOVNS B
  1065. SETZB AR5,GOBF
  1066. CAIL R,STRT
  1067. MOVEI AR5,STRT
  1068. FOO CAIL R,FS
  1069. MOVEI A,NIL
  1070. PSAVE .JBAPR
  1071. MOVEI C,[SETOM GOBF ;Intercept ill-mem-refs, flag
  1072. JRST ERRO2G] ; "garbaged OBLIST" for LISP2.
  1073. HRRM C,.JBAPR
  1074. HLRZ C,@RHX5
  1075. ERRO2B: JUMPE C,[AOBJN B,.-1
  1076. PREST .JBAPR ;oblist done, restore
  1077. JRST PRIN2D] ;print closest match
  1078. CARA TT,(C)
  1079. CDRA TT,(TT)
  1080. JRST ERRO2C+1
  1081. ERRO2C: CARA TT,TT
  1082. JUMPE TT,ERRO2G
  1083. MOVS TT,(TT)
  1084. CARA AR4,(TT)
  1085. FOO CAIE AR4,FUNCELL
  1086. JRST ERRO2C
  1087. CDRA TT,(TT)
  1088. CDRA TT,(TT)
  1089. CARA AR4,(TT)
  1090. CAIE AR4,ID
  1091. CAIGE AR4,CODMIN
  1092. JRST ERRO2G
  1093. CDRA TT,(TT)
  1094. CAMLE TT,AR5 ;LE to prefer car to quote
  1095. CAMLE TT,R
  1096. JRST ERRO2G
  1097. MOVE AR5,TT
  1098. CARA A,(C)
  1099. ERRO2G: CDRA C,(C)
  1100. JRST ERRO2B
  1101. PAGE
  1102. ;dispatcher for error message uuos
  1103. ERROR: MOVEI B,APRFLG ;Enable 10/50 interrupts.
  1104. CALLI B,APRINI
  1105. LDB B,[POINT 9,.JBUUO,OPFLD] ;get opcode
  1106. CAIL B,UOERRE ;what
  1107. CAILE B,USTRTP ;is it?
  1108. JRST ILLUUO ; an illegal opcode
  1109. LDB R,[POINT 9,.JBUUO,ACFLD] ;error number
  1110. ADDI R,INUM0
  1111. CAIL B,USTRTP
  1112. JRST STRTYP ;print message and continue
  1113. FOO SETZM VERMSG
  1114. CAIL B,UOERRI
  1115. JRST ERROR2 ;illegal memory reference
  1116. HRRM R,ERRX ;error number
  1117. CAIL B,UOERRG
  1118. JRST ERRORG ;space overflow error
  1119. CAIL B,UOERRL
  1120. JRST ERROR1 ;ordinary LISP error
  1121. FOO HRRZM A,VERMSG ;set EMSG* to expression
  1122. PSAVE A ;save it
  1123. FOO SKIPN ERRSW
  1124. JRST ERREND ;dont print message, call (err nil)
  1125. PCALL ERHED ;print message on tty
  1126. PREST A
  1127. PCALL PRIN1 ;print expression
  1128. XCT " ",CTY
  1129. JRST ERRORA ;then ordinary Lisp error
  1130. ERRORG: SKIPN P,ERRTN ;if in errset, restore p to that level
  1131. MOVE P,C2 ;else to top level
  1132. ERROR1: ;and attempt to print message
  1133. FOO SKIPN ERRSW
  1134. JRST ERREND ;dont print message, call (err nil)
  1135. PCALL ERHED ;print message on tty
  1136. ERRORA: PCALL ERRSUB ;print the message
  1137. JRST ERRBK ;go the backtrace
  1138. ;STRTYP uses acs A, B and R
  1139. STRTYP: PCALL ERRIO
  1140. PCALL ERRSUB ;print message and continue
  1141. PCALL OUTRET
  1142. JRST @UUOH
  1143. ERROR2: HRRZ A,.JBUUO
  1144. MOVEI B,[SIXBIT / ILL MEM REF FROM !/]
  1145. SUBI R,420
  1146. JRST ERSUB2
  1147. PAGE
  1148. ILLUUO: HRRZ A,UUOH
  1149. MOVEI B,[SIXBIT / ILL UUO FROM !/]
  1150. MOVEI R,INUM0+1
  1151. FOO SETZM VERMSG
  1152. ERSUB2: HRRM R,ERRX
  1153. FOO SKIPN ERRSW
  1154. JRST ERREND ;dont print message
  1155. PSAVE A
  1156. PSAVE B
  1157. PCALL ERHED
  1158. PCALL PRINL2 ;print number
  1159. PREST A
  1160. PCALL ERRSUB+1 ;print message
  1161. PREST R
  1162. PCALL ERSUB3 ;print nearest oblist match
  1163. ERRBK:
  1164. FOO SKIPE BACTRF
  1165. PCALL BKTRC ;print backtrace
  1166. PCALL TOURET ;return to previous device
  1167. ERREND: JSR CHKNIL ;Insure NIL is set properly.
  1168. ERRX: MOVEI A,X ;(ERR x) error number
  1169. ERR2: SKIPN ERRTN
  1170. JRST LSPRE
  1171. ERR: SKIPN P,ERRTN
  1172. JRST LSPRET ;not in an errset, or bad error -- go to top level
  1173. ERR1: PREST B
  1174. PCALL UBD ;unbind to previous errset
  1175. IFN EPDL,PREST EP
  1176. FOO PREST ERRSW
  1177. PREST ERRTN
  1178. JRST ERRP4 ;and proceed
  1179. ERRORSET:PSAVE PA3
  1180. PSAVE PA4
  1181. PSAVE ERRTN
  1182. FOO EXCH B,ERRSW ;INUM0 -> print on selected device (not nec TYO).
  1183. PSAVE B
  1184. IFN EPDL,PSAVE EP
  1185. PSAVE SP
  1186. MOVEM P,ERRTN
  1187. PUSH SP,[0] ;mark for unbind
  1188. FOO EXCH C,BACTRF ;bind BACTRF on spdl to save from error
  1189. FOO HRLI C,BACTRF
  1190. PUSH SP,C
  1191. PCALL EVAL
  1192. PCALL NCONS
  1193. JRST ERR1
  1194. PAGE
  1195. .ERROR:
  1196. FOO HRRZM B,VERMSG
  1197. PSAVE A
  1198. FOO SKIPN ERRSW
  1199. JRST .ERR1
  1200. MOVE A,B
  1201. PCALL ERRIO
  1202. JUMPE A,.ERRO
  1203. PCALL ERHED+1
  1204. PCALL PRINEL
  1205. .ERRO:
  1206. FOO SKIPE BACTRF
  1207. PCALL BKTRC
  1208. PCALL TOURET
  1209. .ERR1: JSR CHKNIL
  1210. PREST A
  1211. JRST ERR2
  1212. PRINEL: JSP D,PATMTP
  1213. JRST PRIN2
  1214. PSAVE A
  1215. CARA A,(A)
  1216. PCALL PRIN1
  1217. PRINE1: CDRA T,@(P)
  1218. MOVEM T,(P)
  1219. JUMPE T,POPAJ
  1220. XCT " ",CTY
  1221. CARA A,(T)
  1222. PCALL PRIN2
  1223. JRST PRINE1
  1224. ;WARNING prints a warning message on the tty
  1225. WARNING:
  1226. FOO SKIPN %MSG
  1227. JRST FALSE
  1228. PCALL WHEAD
  1229. PCALL PRINEL
  1230. JRST TOURET
  1231. PAGE
  1232. BKTRC: ;backtrace subroutine
  1233. FOO CDRA A,BACTRF ;Nil or non-Nil or 0 or +-n...
  1234. BKTRA: SETZM RVAL ;No stack-args printed, unless 0 or neg.
  1235. CAIG A,INUMIN
  1236. JRST BKTR0A
  1237. HRREI B,-INUM0(A)
  1238. SKIPG B
  1239. SETOM RVAL ;0 or neg also prints stack args.
  1240. MOVM B,B
  1241. HRRZ A,P
  1242. SUB A,B ;Just the top n items or
  1243. JUMPN B,BKTR0B ;0 == T otherwise.
  1244. BKTR0A: SKIPN A,ERRTN ;backtrace to previous errset
  1245. MOVE A,C2 ;or top level
  1246. BKTR0B: HRRZM A,BAKLEV#
  1247. STRTIP [SIXBIT /_BACKTRACE_!/]
  1248. FOO MOVE A,VBPORG
  1249. PCALL NUMVAL
  1250. MOVEM A,HVAL
  1251. MOVEI D,-1(P)
  1252. BKTR2: CAMG D,BAKLEV
  1253. JRST FALSE ;done
  1254. HRRZ A,(D) ;get pdl element
  1255. FOO CAIGE A,FS
  1256. JUMPN A,BKTR2B ;this is (hopefully) a true program address
  1257. IFN HCBPS,<
  1258. CAML A,HVAL ;Check for High BPS subrs,
  1259. JRST BKTR2A ; else an INUM.
  1260. CAILE A,400000 ;PCALL from location 377777 is illegal
  1261. JRST BKTR1B ;Test it.
  1262. >
  1263. IFE HCBPS,<
  1264. CAILE A,INUMIN ;Check for Excore BPS subrs,
  1265. JRST BKTR2A ; else an INUM.
  1266. CAML A,HVAL
  1267. SOJA D,BKTR2
  1268. CAMLE A,JRELO
  1269. JRST BKTR1B ;Test it.
  1270. >
  1271. CAIGE A,@GCP1 ;Within FS or NIL?
  1272. BKTR2A: SKIPN RVAL ;Want to print args on stack?
  1273. SOJA D,BKTR2 ; Unknown, neither prog nor sexpr, so skip.
  1274. MOVEI A,"="
  1275. PCALL TYO
  1276. HRRZ A,(D)
  1277. BKTR2C: PCALL PRIN2D
  1278. JRST BKTR1C
  1279. PAGE
  1280. BKTR2B: CAIE A,ILIST3 ;evaluating arguments ?
  1281. JRST BKTR1B ;no
  1282. HRRZ B,-1(D) ;maybe
  1283. CAIE B,EXP2
  1284. CAIN B,ESB1
  1285. JRST BKTR1A ;yes
  1286. BKTR1B: CAIN A,CPOPJ
  1287. JRST [HLRZ A,(D) ;calling a function
  1288. PCALL PRIN2D
  1289. STRTIP [SIXBIT /-ENTER !/]
  1290. SOJA D,BKTR2]
  1291. HLRZ B,-1(A)
  1292. CAILE B,(JCALLF 17,@(17))
  1293. CAIN B,(PCALL) ;tests for various types of calls
  1294. CAIGE B,(FCALL)
  1295. JRST [CAIG A,INUMIN
  1296. SOJA D,BKTR2 ;Not a proper function call.
  1297. JRST BKTR2A ];This could print as a INUM.
  1298. PSAVE -1(A) ;save object of function call
  1299. MOVEI R,-1(A) ;location of function call
  1300. PCALL ERSUB3 ;print closest oblist match
  1301. XCT "-",CTY
  1302. PREST R
  1303. TLNE R,17
  1304. HRRZ R,ERSUB3 ;qst -- cant handle indexed calls
  1305. HRRZS R
  1306. CARA B,(R)
  1307. CAIN B,ID
  1308. JRST [CDRA A,R ;was calling an atomic function
  1309. JRST BKTR2C] ;print its name
  1310. CAIL B,CODMIN ;code pointer ?
  1311. CDRA R,(R) ;yes
  1312. PCALL ERSUB3 ;was calling a code location; print closest match
  1313. BKTR1C: XCT " ",CTY
  1314. BKTR1: SOJA D,BKTR2 ;continue
  1315. BKTR1A: HLRE B,-1(D)
  1316. ADD B,D
  1317. HLRZ A,-3(B)
  1318. JUMPE A,BKTR1
  1319. PCALL PRIN2D
  1320. STRTIP [SIXBIT /-EVALARGS !/]
  1321. SOJA D,BKTR2
  1322. PRIN2D: PSAVE D
  1323. PCALL PRIN2
  1324. PREST D
  1325. PRET
  1326. SUBTTL TYI & TYO --- PAGE 7
  1327. ;Input routines...
  1328. BINI: PCALL TYID
  1329. JRST FIX1A
  1330. ITYI: PCALL TYI
  1331. FIXI: ADDI A,INUM0
  1332. PRET
  1333. TYICC: PCALL COMIGN
  1334. TYI: MOVEI AR4,1
  1335. TYIC: PCALL TYID1
  1336. JUMPE A,.-1 ;Ignore null
  1337. CAIN A,IGCRLF ;start of ignored cr-lf
  1338. JRST TYICC ;read comment
  1339. PRET
  1340. TYIA: CAIN A,LF ;If it is LF
  1341. JRST RETCRLF ; then return CRLF
  1342. CAIN A,FORMF ; else if it is FORMF
  1343. JRST RCRLFFF ; then return CRLF FF
  1344. CAIE A,CR
  1345. PRET
  1346. PCALL TYID ;Read next character
  1347. CAIN A,CRLF ;If it is CRLF
  1348. PRET ; then return it
  1349. MOVEM A,OLDCH ; else backup character
  1350. MOVEI A,CR ; and return CR
  1351. PRET
  1352. RCRLFFF:MOVEM A,OLDCH ;Backup FF
  1353. RETCRLF:MOVEI A,CRLF
  1354. PRET
  1355. TYID1: SKIPE A,OLDCH
  1356. JRST TYI1
  1357. TYID: JRST TTYI+X ;<SOSG X> for other device input...
  1358. JRST TYI2X
  1359. TYI3: ILDB A,X ;pointer
  1360. SKIPGE INCH ;IF BINARY-MODE INPUT,
  1361. PRET ; SKIP LINUM &FECHO & RAISE CODE.
  1362. TYI3A: TDNN AR4,@X ;pointer
  1363. JRST TYI4
  1364. MOVE A,@TYI3A
  1365. CAMN A,[<ASCII / />+1] ;page mark for stopgap
  1366. AOSA PGNUM ;increment page number
  1367. MOVEM A,LINUM
  1368. MOVNI A,5
  1369. ADDM A,@TYID ;adjust character count for line number
  1370. AOS @TYI3 ;increment byte pointer over line number and tab
  1371. JRST TYID
  1372. PAGE
  1373. TYI4: SKIPLE LINUM
  1374. JRST TYI4A
  1375. CAIN A,LF
  1376. JRST TYI4L
  1377. CAIE A,FORMF
  1378. JRST TYI4A
  1379. SETZM LINUM
  1380. AOSA PGNUM
  1381. TYI4L: SOS LINUM
  1382. TYI4A:
  1383. FOO SKIPN VFECHO
  1384. JRST TYI4E
  1385. CAIN A,"D"-100 ;On! File-input echoed to TTY.
  1386. JRST TYI4W
  1387. PCALL XTYO
  1388. JRST TYI4E
  1389. TYI4W:
  1390. IFN OPSYS,<
  1391. PSAVE 2 ;Unless ^D encountered in file...
  1392. MOVEI 1,100 ; want to pause during echo,
  1393. RFMOD ; e.g., demo on a CRT.
  1394. PSAVE 2
  1395. TRZ 2,776000 ;Clear wakeup,echo.
  1396. TRO 2,020000 ;Set just punctuation,
  1397. SFMOD
  1398. WAITSP: PBIN ;Wait til user types a space on KB.
  1399. CAIE 1," "
  1400. JRST WAITSP
  1401. MOVEI 1,100
  1402. PREST 2
  1403. SFMOD ;Restore old TTYmodes.
  1404. PREST 2
  1405. JRST TYID ;Get next file-character.
  1406. >
  1407. IFE OPSYS,<
  1408. SETSTS TTCH,1+1B28 ;OFF ECHO TO TTY, TO GET <sp>...
  1409. WAITSP: INCHRW A
  1410. CAIE A," "
  1411. JRST WAITSP
  1412. SETSTS TTCH,1
  1413. JRST TYID
  1414. >
  1415. PAGE
  1416. TYI2X: INPUT X,0
  1417. TYI2Y: STATZ X,740000
  1418. ERRL0 ^D128,AIN.8 ;input error
  1419. TYI2Z: STATO X,20000
  1420. JRST TYI3 ;continue with file
  1421. PSAVE T ;end of file
  1422. PSAVE C
  1423. PSAVE R
  1424. PSAVE AR4
  1425. MOVE A,INCH
  1426. HLRZ T,CHTAB(A) ;inlst -- remaining files to input
  1427. JUMPE T,TYI2E ;none left -- stop
  1428. HRRZ C,CHTAB(A) ;get location of data for this channel
  1429. MOVE R,CHDEV(C)
  1430. MOVEM R,DEV
  1431. MOVE R,CHPPN(C)
  1432. MOVEM R,PPN
  1433. PCALL SETIN ;start next input
  1434. PREST AR4
  1435. PREST R
  1436. PREST C
  1437. PREST T
  1438. JRST TYI
  1439. TYI2E: PCALL INCNT ;(CLOSE (RDS NIL))
  1440. TALK ;turn off control o
  1441. FOO MOVE A,V$EOF$ ;we are done
  1442. JRST ERR
  1443. PGLINE: MOVM A,LINUM
  1444. SKIPG LINUM
  1445. AOJA A,.+3
  1446. MOVE C,[POINT 7,LINUM]
  1447. PCALL NUM10 ;convert ascii line number to an integer
  1448. PCALL FIX1A ;(may be larger than INUM size - 99999).
  1449. SKIPG LINUM ;If not line numbered file
  1450. PCALL NCONS ; then (pg line)
  1451. MOVE B,PGNUM
  1452. HRLI A,INUM0+1(B)
  1453. JRST DCONSA ; else (pg . line)
  1454. OLDCH: 0 ; *
  1455. PGNUM: 0 ; *
  1456. LINUM: 0 ; *
  1457. 0 ;zero to terminate num10
  1458. PAGE
  1459. ;teletype input
  1460. TTYI:
  1461. FOO SKIPE DDTIFG
  1462. JRST TTYID
  1463. INCHSL A ;single char if line has been typed
  1464. JRST [TALK ;turn off control o.
  1465. OUTSTR PCHAR ;output THE PROMPT-CHAR(S).
  1466. INCHWL A ;wait for a line
  1467. JRST .+1]
  1468. TTYXIT: CAIN A,BELL
  1469. JRST LSPRET ;bell returns to top level
  1470. CAIN A,33
  1471. MOVEI A,ALTMOD ;<esc> becomes <alt> (DECUS tty input).
  1472. TYI4E:
  1473. FOO SKIPE VRAISE
  1474. CAIGE A,"A"+40
  1475. JRST TYIA
  1476. CAIG A,"Z"+40
  1477. TRZ A,40 ;If flag on, make lowercase into upper.
  1478. PRET
  1479. TTYID: TALK ;turn off control o, remove this when ttyser works
  1480. INCHRW A ;single character input ddt submode style
  1481. CAIE A,RUBOUT
  1482. JRST TTYXIT
  1483. OUTCHR ["\"] ;echo backslash
  1484. SKIPE PSAV
  1485. JRST RDRUB ;rubout in read resets to top level of read
  1486. PRET
  1487. PCHAR: ASCIZ /*/ ;INITIAL (DEFAULT) PROMPT-CHAR.
  1488. SETPCH: PCALL GT1PNM
  1489. TRZ A,377 ;(INSURE NULL AT END OF STRING).
  1490. EXCH A,PCHAR ;1-4 CHARS.
  1491. JRST PNGNK2 ;return previous promter as non-interned id
  1492. PAGE
  1493. ;output ROUTINES.
  1494. BINO: PSAVE A
  1495. PCALL NUMVAL
  1496. PCALL TYOD
  1497. JRST POPAJ
  1498. ITYO: SUBI A,INUM0
  1499. PSAVE CFIXI ;go to FIXI after TYO
  1500. XTYO: CAIN A,CRLF ;is it CRLF
  1501. JRST TYO+2 ;yes! output as is, do not convert to CR LF
  1502. TYO: CAIG A,CRLF
  1503. JRST TYO3
  1504. SOSGE CHCT
  1505. JRST TYO1
  1506. TYOD: JRST TTYO+X ;sosg x for other device
  1507. JRST TYO2X
  1508. TYO5: IDPB A,X
  1509. PRET
  1510. TYO2X: OUT X,0
  1511. JRST TYO5
  1512. ERRL0 ^D129,[SIXBIT /OUTPUT ERROR!/]
  1513. TYO3: CAIE A,CRLF
  1514. JRST TYO3X
  1515. MOVEI A,CR
  1516. PCALL TYO3XX
  1517. MOVEI A,LF
  1518. TYO3X: CAIG A,CR
  1519. CAIGE A,TAB
  1520. JUMPN A,TYO+2 ;everything between 0(null) and 11(tab) decrement chct
  1521. TYO3XX: PSAVE B
  1522. MOVE B,LINL
  1523. CAIN A,TAB
  1524. JRST [SUB B,CHCT
  1525. IORI B,7 ;simulate tab effect on chct
  1526. SUB B,LINL
  1527. SETCAM B,CHCT
  1528. JRST TYO4]
  1529. CAIN A,CR
  1530. MOVEM B,CHCT ;reset chct after a cr
  1531. CAIN A,VT
  1532. JRST [PSAVE C
  1533. MOVE B,LNCT
  1534. IDIVI B,LNPRVT
  1535. ADDI B,1
  1536. IMULI B,LNPRVT
  1537. MOVEM B,LNCT
  1538. PREST C
  1539. JRST TYO6]
  1540. CAIN A,FORMF
  1541. TYO7: SETZM LNCT
  1542. CAIE A,LF
  1543. JRST TYO4
  1544. AOS LNCT
  1545. TYO6: SKIPE B,PAGL
  1546. CAMLE B,LNCT
  1547. JRST TYO4
  1548. MOVEI A,FORMF
  1549. JRST TYO7
  1550. PAGE
  1551. TYO1: SKIPN OUTCH
  1552. JRST TYO11 ;don't print a IGCRLF to terminal
  1553. PSAVE A ;linelength exceeded
  1554. MOVEI A,IGCRLF ;ignored cr-lf
  1555. PCALL TYOD
  1556. PREST A
  1557. TYO11: PCALL TERPRI
  1558. SOSA CHCT
  1559. TYO4: PREST B
  1560. JRST TYOD
  1561. LINELENGTH:
  1562. JUMPE A,LINEL1
  1563. CAIG A,INUM0
  1564. ERRE2 ^D36,[SIXBIT /ILLEGAL ARG TO LINELENGTH!/]
  1565. SUBI A,INUM0
  1566. HRRM A,LINL
  1567. HRRM A,CHCT
  1568. LINEL1: HRRZ A,LINL
  1569. CFIXI: JRST FIXI
  1570. PAGELENGTH:
  1571. JUMPE A,PAGEL1
  1572. CAIGE A,INUM0
  1573. ERRE2 ^D37,[SIXBIT /ILLEGAL ARG TO PAGELENGTH!/]
  1574. SUBI A,INUM0
  1575. HRRM A,PAGL
  1576. JUMPE A,PAGEL1
  1577. SKIPE LNCT
  1578. PCALL EJECT
  1579. PAGEL1: HRRZ A,PAGL
  1580. JRST FIXI
  1581. POSN: SKIPA A,LINL
  1582. LPOSN: SKIPA A,LNCT
  1583. SUB A,CHCT
  1584. JRST FIX1A
  1585. LINL: TTYLL ;*
  1586. CHCT: TTYLL ;*
  1587. PAGL: TTYPL
  1588. LNCT: 0
  1589. ;teletype output
  1590. TTYO: ;Output 1 char from A...
  1591. IFG OPSYS,SKIPN CTRLOF ; unless ^O on.
  1592. OUTCHR A
  1593. PRET
  1594. PAGE
  1595. TTYRET: PCALL OUTCNT
  1596. JRST INCNT
  1597. TTYCLR: ;Turn off ^O, in a way such that msg
  1598. IFLE OPSYS, < ; or promptchar will print.
  1599. SKPINC
  1600. PRET
  1601. PRET >
  1602. IFG OPSYS, <
  1603. PSAVE A
  1604. MOVEI 1,101
  1605. DOBE
  1606. SETZM CTRLOF
  1607. JRST POPAJ >
  1608. TTOCH: 0 ;*
  1609. 0 ;tty page number -- always zero
  1610. 0 ;tty line number -- always zero
  1611. TTOLL: TTYLL ;*
  1612. TTOHP: TTYLL ;*
  1613. TTOPL: TTYPL
  1614. TTOVP: 0
  1615. SUBTTL INPUT AND OUTPUT INITIALIZATION AND CONTROL --- PAGE 8
  1616. ;convert ascii to sixbit for device initialization routines
  1617. SIXMAK: SETZM SIXMK2#
  1618. MOVE AR4,[POINT 6,SIXMK2]
  1619. HRROI R,SIXMK1
  1620. PCALL PRINTA ;use print to unpack ascii characters
  1621. MOVE A,SIXMK2
  1622. PRET
  1623. SIXMK1: ADDI A,40
  1624. TLNN AR4,770000
  1625. PRET ;last character position -- ignore remaining chars
  1626. CAIN A,"."+40
  1627. MOVEI A,0 ;ignore dots at end of numbers for decimal base
  1628. CAIN A,":"+40
  1629. HRLI AR4,(POINT 6,0,29) ;deposit : in last char position
  1630. IDPB A,AR4
  1631. PRET
  1632. ;subroutine to process next item in file name list
  1633. INXTIO: JUMPE T,FALSE
  1634. CDRA T,(T)
  1635. NXTIO: CARA A,(T)
  1636. PCALL ATOM
  1637. JUMPE A,CPOPJ ;non-atomic
  1638. CARA A,(T)
  1639. JRST SIXMAK ;make sixbit if atomic
  1640. IFN OCTPPN,<IOPPNX==NUMVAL>
  1641. PAGE
  1642. IOSUB: PCALL NXTIO
  1643. MOVEM T,DEVDAT#
  1644. LDB B,[POINT 6,A,35]
  1645. JUMPE A,IOPPN ;non-atomic item, must be ppn or (file.ext)
  1646. CAIE B,":"-40
  1647. JRST IOFIL ;not a device name -- must be file name
  1648. TRZ A,77 ;clear out the :
  1649. IFN OPSYS,PCALL CHKDIR
  1650. IODEV2: MOVEM A,DEV
  1651. PCALL INXTIO
  1652. JUMPN A,IOFIL2 ;not ppn or (fil.ext)
  1653. IOPPN: JUMPE T,FIL
  1654. PCALL PPNEXT
  1655. JUMPN A,IOEXT ;(fil.ext)
  1656. CARA A,(T)
  1657. CARA A,(A) ;caar is project number
  1658. PCALL IOPPNX
  1659. HRLM A,PPN ;project number
  1660. CARA A,(T)
  1661. PCALL CADR ;cadar is programmer number
  1662. PCALL IOPPNX
  1663. HRRM A,PPN ;programmer number
  1664. MOVSI A,(SIXBIT /DSK/) ;disk is assumed
  1665. JRST IODEV2
  1666. IOFIL: JUMPN A,IOFIL3 ;was it an atom
  1667. JUMPE T,FIL ;no, was it nil (end)
  1668. PCALL PPNEXT
  1669. JUMPE A,CPOPJ ;see a ppn, no file named
  1670. IOEXT: CARA A,(T) ;(file.ext)
  1671. CDRA A,(A) ;get cdr == extension
  1672. PCALL SIXMAK
  1673. HLLZM A,EXT
  1674. CARA A,(T)
  1675. CARA A,(A) ;get car = file name
  1676. PCALL SIXMAK
  1677. FIL: JUMPE T,.+2
  1678. CDRA T,(T)
  1679. SKIPE DEV
  1680. PRET
  1681. PSAVE A ;no device named
  1682. MOVSI A,(SIXBIT /DSK/)
  1683. MOVEM A,DEV
  1684. JRST POPAJ
  1685. IOFIL2: LDB B,[POINT 6,A,35]
  1686. CAIN B,":"-40
  1687. JRST FALSE ;saw a :,not file name
  1688. IOFIL3: SETZM EXT ;file name -- clear extension
  1689. JRST FIL
  1690. PAGE
  1691. PPNEXT: CARA A,(T)
  1692. CDRA A,(A) ;cdar
  1693. JRST ATOM ;ppn iff (not(atom(cdar l)))
  1694. IFE OCTPPN,<
  1695. IOPPNX: PCALL SIXMAK
  1696. TRNE A,77
  1697. PRET
  1698. LSH A,-6
  1699. JRST .-3 >
  1700. IFN OPSYS,<
  1701. CHKDIR: CAME A,[SIXBIT /DIR/] ;i.e., (... DIR: directory filename ...)
  1702. PRET
  1703. PSAVE T
  1704. PCALL INXTIO
  1705. JUMPE A,NIXDIR ;NON-ATOMIC.
  1706. CARA A,(T)
  1707. PCALL PNAMUK
  1708. SETZM 1(C)
  1709. IFG OPSYS ,<
  1710. MOVSI A,400000
  1711. HRROI B,1(SP)
  1712. STDIR
  1713. JRST NIXDIR
  1714. JRST NIXDIR
  1715. HRRZM A,PPN >
  1716. IFL OPSYS, <
  1717. HRLI A,440700 ; MAKE UP A
  1718. HRRI A,1(SP) ; BYTE POINTER
  1719. MOVE B,A
  1720. MOVEI C,"<"
  1721. LP1: ILDB 4,A
  1722. IDPB C,B
  1723. MOVE C,4
  1724. JUMPN C,LP1
  1725. MOVEI C,">" ; PUT IN LEFT BRACKET
  1726. IDPB C,B
  1727. IDPB 4,B
  1728. MOVEI A,0
  1729. HRROI B,1(SP)
  1730. RCDIR
  1731. ERJMP NIXDIR
  1732. SYSNU: HRLI C,X
  1733. MOVEM C,PPN >
  1734. P1DROP ;SLUFF.
  1735. USEDSK: MOVSI A,(SIXBIT /DSK/)
  1736. PRET
  1737. NIXDIR: PREST T ;TRY AS FILENAME INSTEAD.
  1738. JRST USEDSK
  1739. > ;end of IFN OPSYS
  1740. PAGE
  1741. ;subroutine to reset all i/o channels -- used by excise and realloc
  1742. IOBRST: X ;jsr location
  1743. HRRZ A,.JBREL
  1744. HRLM A,.JBSA
  1745. MOVEM A,CORUSE
  1746. MOVEM A,.JBSYM
  1747. SETZM CHTAB+FSTCH
  1748. MOVE A,[XWD CHTAB+FSTCH,CHTAB+FSTCH+1]
  1749. BLT A,CHTAB+NIOCH+FSTCH-1 ;clear channel table
  1750. JRST @IOBRST
  1751. CHTAB=.-FSTCH ;GC'D BY GCMKL AS AN ARRAY, SINCE LH=LIST,
  1752. BLOCK NIOCH ;[1-17] RH=ADDR OF .JBFF DATA BLK. ;*
  1753. ;channel data
  1754. CHNAM==0 ;name of channel
  1755. CHDEV==1 ;name of device
  1756. CHPPN==2 ;ppn for input channel
  1757. CHOCH==3 ;oldch for input channels
  1758. CHPAGE==4 ;page number for input
  1759. CHLINE==5 ;line number for input
  1760. CHDAT==6 ;device data
  1761. POINTR==7 ;byte pointer for device buffer
  1762. COUNT==10 ;character count for device buffer
  1763. CHLL==2 ;linelength for output channel
  1764. CHHP==3 ;hposit for output channels
  1765. CHPL==4 ;pagelength for output channel
  1766. CHVP==5 ;vposit for output channels
  1767. ;flags in left half of CHNAM
  1768. BINM==400000 ;binary I/O
  1769. OUTM==1 ;output
  1770. PAGE
  1771. OPEN: JUMPE A,.+3
  1772. JSP D,ATMTYP
  1773. PCALL NCONS
  1774. MOVE T,A
  1775. SETZB A,DEV
  1776. FOO CAIE B,INBIN
  1777. FOO CAIN B,OUTBIN
  1778. TLO A,BINM ;binary I/O
  1779. FOO CAIE B,OUTPUT
  1780. FOO CAIN B,OUTBIN
  1781. TLO A,OUTM ;output
  1782. FOO CAIE B,INPUT
  1783. JUMPE A,[MOVE A,B
  1784. ERRE1 ^D18,[SIXBIT /NOT A KEYWORD FOR OPEN!/]]
  1785. MOVE B,[-NIOCH,,FSTCH]
  1786. OPEN1: SKIPN C,CHTAB(B)
  1787. JRST OPEN2 ;found free channel without buffer
  1788. SKIPN CHNAM(C)
  1789. JRST DEVCLR ;found free channel with buffer
  1790. AOBJN B,OPEN1 ;try next channel
  1791. ERRL0 ^D130,[SIXBIT "NO I/O CHANNELS LEFT!"]
  1792. OPEN2: PSAVE A
  1793. MOVEI A,BLKSIZ
  1794. PCALL MORCOR ;expand core for buffer if necessary
  1795. MOVE C,A
  1796. PREST A
  1797. HRRM C,CHTAB(B)
  1798. DEVCLR: HRRZ C,CHTAB(B)
  1799. HRR A,B
  1800. HLLOM A,CHNAM(C)
  1801. MOVEI B,INUM0(B)
  1802. PSAVE B
  1803. SETZM PPN
  1804. TLNE A,OUTM
  1805. JRST SETOUT
  1806. PCALL SETIN
  1807. JRST POPAJ
  1808. PAGE
  1809. SETIN: PSAVE A ;CHANNEL #.
  1810. PCALL IOSUB ;get device and file name
  1811. MOVEM A,LOOKIN ;file name
  1812. MOVE A,DEV
  1813. CALLI A,DEVCHR
  1814. TLNN A,INB
  1815. JRST AIN.2 ;not input device
  1816. TLNN A,AVLB
  1817. JRST AIN.4 ;not available
  1818. PREST A
  1819. HLLZS ININIT
  1820. MOVEI B,13
  1821. SKIPGE A
  1822. HRRM B,ININIT ;BINARY-INBIN.
  1823. DPB A,[POINT 4,ININIT,ACFLD] ;set up channel numbers
  1824. DPB A,[POINT 4,INLOOK,ACFLD]
  1825. DPB A,[POINT 4,ININBF,ACFLD]
  1826. HRRZ B,CHTAB(A)
  1827. HRLM T,CHTAB(A) ;save remaining file name list
  1828. MOVEI A,CHDAT(B)
  1829. MOVEM A,DEV+1 ;pointer to bufdat
  1830. IFN SYDEV,<PCALL SYSDEV> ;Check for SYS:
  1831. ININIT: INIT X,X ;INIT CHN#,STATUS
  1832. DEV: X ;SIXBIT /DEV/
  1833. X ;XWD 0,IBUF
  1834. JRST AIN.7 ;cant init
  1835. PUSH B,DEV
  1836. PUSH B,PPN
  1837. INLOOK: LOOKUP X,LOOKIN
  1838. JRST AIN.7 ;cant find file
  1839. PUSH B,[0] ;oldch
  1840. PUSH B,[0] ;line number
  1841. PUSH B,[0] ;page number
  1842. ADDI B,4
  1843. HRRM B,.JBFF
  1844. ININBF: INBUF X,NIOB
  1845. JRST TRUE
  1846. PAGE
  1847. IFN SYDEV, < ;shunt SYS: to <LISP>'s dir (or wherever).
  1848. SYSDEV: MOVSI A,(SIXBIT /SYS/)
  1849. CAME A,DEV
  1850. PRET
  1851. IFG OPSYS,<MOVSI A,(SIXBIT /DSK/)>
  1852. IFLE OPSYS,<MOVE A,SYSNUM>
  1853. MOVEM A,DEV
  1854. IFG OPSYS,<PSAVE SYSNUM
  1855. PREST PPN >
  1856. PRET
  1857. >
  1858. ENTR:
  1859. LOOKIN: BLOCK 4
  1860. EXT=LOOKIN+1
  1861. PPN=LOOKIN+3
  1862. PAGE
  1863. SETOUT: PSAVE A
  1864. PCALL IOSUB ;get device and file name
  1865. MOVEM A,ENTR ;file name
  1866. SETZM ENTR+2 ;zero creation date
  1867. PREST A
  1868. DPB A,[POINT 4,OUINIT,ACFLD] ;setup channel numbers
  1869. DPB A,[POINT 4,OUTENT,ACFLD]
  1870. DPB A,[POINT 4,OUTOBF,ACFLD]
  1871. HRRZ B,CHTAB(A)
  1872. MOVEI A,CHDAT(B)
  1873. HRLM A,DEVO+1
  1874. MOVE A,DEV
  1875. MOVEM A,DEVO
  1876. CALLI A,DEVCHR
  1877. TLNN A,OUTB
  1878. JRST AOUT.2 ;not output device
  1879. TLNN A,AVLB
  1880. JRST AOUT.4 ;not available
  1881. HLLZS OUINIT
  1882. MOVEI A,13
  1883. SKIPGE CHNAM(B)
  1884. HRRM A,OUINIT ;BINARY-OUTBIN.
  1885. OUINIT: INIT X,X ;INIT CHN#,STATUS
  1886. DEVO: X ;SIXBIT /DEV/
  1887. X ;XWD OBUF,0
  1888. JRST AOUT.4 ;cant init
  1889. PUSH B,DEV
  1890. OUTENT: ENTER X,ENTR
  1891. JRST OUTERR ;cant enter
  1892. PUSH B,[LPTLL] ;linelength
  1893. PUSH B,[LPTLL] ;chrct
  1894. PUSH B,[LPTPL] ;pagelength
  1895. PUSH B,[0] ;linct
  1896. ADDI B,4
  1897. HRRM B,.JBFF
  1898. OUTOBF: OUTBUF X,NIOB
  1899. JRST POPAJ
  1900. OUTERR: MOVE A,DEVDAT
  1901. LDB B,[POINT 3,ENTR+1,35]
  1902. CAIE B,2
  1903. ERRE1 ^D19,[SIXBIT /DIRECTORY FULL!/]
  1904. ERRE1 ^D20,[SIXBIT /FILE IS WRITE PROTECTED!/]
  1905. PAGE
  1906. INCNT: MOVEI A,NIL ;(CLOSE (RDS NIL))
  1907. PSAVE [JRST CLOSE]
  1908. RDS: PSAVE INCH#
  1909. PCALL IOSEL
  1910. TLNE A,OUTM ;test to see if it is an input channel
  1911. ERRL0 ^D131,[SIXBIT/NO INPUT - RDS!/]
  1912. SKIPN TT
  1913. MOVEI TT,TTOCH-CHOCH ;tty deselect
  1914. MOVEI D,CHOCH(TT)
  1915. HRLI D,OLDCH
  1916. BLT D,CHLINE(TT) ;save channel data
  1917. JUMPE A,ITTYRE ;select tty
  1918. DPB A,[POINT 4,TYI2X,ACFLD] ;set up channel numbers
  1919. DPB A,[POINT 4,TYI2Y,ACFLD]
  1920. DPB A,[POINT 4,TYI2Z,ACFLD]
  1921. HRRM B,TYI3 ;set up tyi parameters
  1922. HRRM B,TYI3A
  1923. MOVSI B,CHOCH(C)
  1924. INC3: HRRI B,OLDCH
  1925. BLT B,LINUM ;restore channel data
  1926. MOVEM T,TYID
  1927. FOO PREST VINC
  1928. EXCH A,INCH ;flags,,channel#.
  1929. IOEND: HRRZS A
  1930. JUMPN A,FIXI
  1931. PRET
  1932. ITTYRE: MOVE T,[JRST TTYI] ;reselect tty
  1933. MOVSI B,TTOCH
  1934. JRST INC3
  1935. PAGE
  1936. OUTCNT: MOVEI A,NIL ;(CLOSE (WRS NIL))
  1937. PSAVE [JRST CLOSE]
  1938. WRS: PSAVE OUTCH#
  1939. PCALL IOSEL
  1940. TLNN A,OUTM ;is it output channel
  1941. JUMPN A,[ERRL0 ^D132,[SIXBIT /NO OUTPUT - WRS!/]]
  1942. SKIPN TT
  1943. MOVEI TT,TTOLL-CHLL ;tty deselect
  1944. MOVEI D,CHLL(TT)
  1945. HRLI D,LINL
  1946. BLT D,CHVP(TT) ;save channel data
  1947. JUMPE A,OTTYRE ;return to tty
  1948. DPB A,[POINT 4,TYO2X,ACFLD] ;set up tyo2 channel numbers
  1949. HRRM B,TYO5 ;set up tyo2 parameters
  1950. MOVSI B,CHLL(C)
  1951. OUTC3: HRRI B,LINL
  1952. BLT B,LNCT ;get channel data
  1953. MOVEM T,TYOD
  1954. FOO PREST VOUTC
  1955. EXCH A,OUTCH ;flags,,channel#.
  1956. JRST IOEND
  1957. OTTYRE: MOVE T,[JRST TTYO]
  1958. MOVSI B,TTOLL ;tty reselect
  1959. JRST OUTC3
  1960. PAGE
  1961. IOSEL: PCALL GCHNO ;convert into channel number
  1962. SKIPE TT,A
  1963. ADDI TT,INUM0
  1964. EXCH TT,-1(P)
  1965. SKIPE TT
  1966. HRRZ TT,CHTAB(TT)
  1967. JUMPE A,CPOPJ
  1968. SKIPE C,CHTAB(A)
  1969. SKIPN T,CHNAM(C)
  1970. JRST CPOPJ1
  1971. HLL A,T
  1972. MOVEI B,POINTR(C)
  1973. MOVEI T,COUNT(C)
  1974. HRLI T,(SOSG)
  1975. PRET
  1976. CLOSE: PCALL GCHNO ;convert into channel number
  1977. ICLOSE: JUMPE A,CPOPJ ;don't close terminal cannel
  1978. SKIPE D,CHTAB(A)
  1979. SETZM CHNAM(D) ;blast channel name
  1980. DPB A,[POINT 4,.+1,ACFLD]
  1981. RELEASE X, ;release channel
  1982. HRRZS CHTAB(A) ;release channel table entry
  1983. JRST FIXI
  1984. ;convert A into channel number
  1985. GCHNO: SKIPE A
  1986. SUBI A,INUM0
  1987. CAIG A,NIOCH
  1988. JUMPGE A,CPOPJ
  1989. ADDI A,INUM0
  1990. ERRE1 ^D21,[SIXBIT /IS NOT A CHANNEL NAME!/]
  1991. AOUT.2:
  1992. AIN.2: MOVE A,DEVDAT
  1993. ERRE1 ^D22,[SIXBIT /ILLEGAL DEVICE!/]
  1994. AOUT.4:
  1995. AIN.4: MOVE A,DEVDAT
  1996. ERRE1 ^D23,[SIXBIT /DEVICE NOT AVAILABLE!/]
  1997. AIN.7: MOVE A,DEVDAT
  1998. ERRE1 ^D24,[SIXBIT /CAN'T FIND FILE!/]
  1999. SUBTTL PRINT --- PAGE 9
  2000. PRINT: MOVEI R,TYO
  2001. PCALL PRIN1
  2002. TERPRI: PSAVE A
  2003. MOVEI A,CRLF
  2004. TERPR1: PCALL TYO
  2005. CPOPAJ: JRST POPAJ
  2006. EJECT: MOVEI A,CR
  2007. PCALL TYO
  2008. MOVEI A,FORMF
  2009. PCALL TYO
  2010. JRST FALSE
  2011. PRINC: PSAVE A
  2012. PCALL GTFCH
  2013. JRST TERPR1
  2014. PRIN2: SKIPA R,.+1
  2015. PRIN1: HRRZI R,TYO ;<HRRZI> = <551>, NEGATIVE FOR PRIN2.
  2016. PSAVE A
  2017. PCALL PRINTA
  2018. JRST POPAJ
  2019. PRINTA: HLRZ B,SLSH ;PRIN3 OR PRIN3C SET BY SCANSET
  2020. SKIPGE R
  2021. MOVEI B,PRIN4
  2022. HRRM B,PRIN5
  2023. PRINT4: PSAVE A
  2024. JSP D,PATMTP
  2025. JRST PRINT1
  2026. XCT "(",CTY
  2027. PRINT3: MOVE A,TT ;[if 0 --> NIL's 777777 --> ill mem ref].
  2028. PCALL PRINT4
  2029. CDRA A,@(P)
  2030. JUMPE A,PRINT2
  2031. MOVEM A,(P)
  2032. XCT " ",CTY
  2033. JSP D,PATMTP
  2034. JRST .+2
  2035. JRST PRINT3
  2036. XCT ".",CTY
  2037. XCT " ",CTY
  2038. PCALL PRIN1A
  2039. PRINT2: XCT ")",CTY
  2040. JRST POPAJ
  2041. PAGE
  2042. PRINT1: PSAVE CPOPAJ
  2043. PRIN1A: JUMPE TT,PRINIC ;inum
  2044. JUMPL TT,PRINL ;not a Lisp expression
  2045. CDRA A,(A)
  2046. CAIN TT,ID
  2047. JUMPN A,PRINN
  2048. CAIL TT,CODMIN
  2049. JRST PCODE
  2050. JUMPN A,@PRITAB-ATMIN-1(TT) ;go to print routine for the given type
  2051. PRINL: XCT "#",CTY
  2052. HLRZ A,-1(P)
  2053. JUMPE A,.+3 ;usually there is no left half
  2054. PCALL PRINL1
  2055. XCT ",",CTY
  2056. HRRZ A,-1(P)
  2057. PRINL1: MOVEI C,8
  2058. PRINI3: JUMPL A,[MOVE B,0 ;case of -2^35
  2059. MOVEI A,1
  2060. DIVI A,(C)
  2061. JRST .+2]
  2062. IDIVI A,0(C)
  2063. HRLM B,(P)
  2064. SKIPE A
  2065. PCALL .-3
  2066. JRST FP7A1
  2067. PRITAB: BPRI ;negative bignum
  2068. BPRI+1 ;positive bignum
  2069. PRINI1 ;integer
  2070. PRINO ;floating point number
  2071. PSTR ;string
  2072. PVEC ;vector
  2073. PAGE
  2074. PRINL2: MOVEI R,TYO
  2075. JRST PRINL1
  2076. PRINI1: SKIPA A,(A)
  2077. PRINIC: SUBI A,INUM0
  2078. FOO CDRA C,VBASE
  2079. SUBI C,INUM0
  2080. JUMPGE A,PRINI2
  2081. XCT "-",CTY
  2082. MOVNS A
  2083. PRINI2: PCALL PRINI3
  2084. PRINI4:
  2085. IFN ROCT,<CAIN C,10
  2086. JRST POCTNM>
  2087. CAIN C,TEN
  2088. FOO SKIPE %NOPOINT
  2089. PRET
  2090. MOVEI A,"."
  2091. JRST (R)
  2092. IFN ROCT,<
  2093. POCTNM: JUMPL R,CPOPJ
  2094. MOVEI A,"L"
  2095. JRST (R) >
  2096. PVEC: PSAVE -1(A)
  2097. HRLI A,(POINT 18)
  2098. PSAVE A
  2099. MOVEI A,"["
  2100. PCALL (R)
  2101. JRST PVECL+1
  2102. PVECL: XCT ",",CTY
  2103. ILDB A,(P)
  2104. PCALL PRINT4
  2105. SOSL -1(P)
  2106. JRST PVECL
  2107. MOVEI A,"]"
  2108. P2DROP
  2109. JRST (R)
  2110. PCODE: XCT "#",CTY
  2111. XCT "#",CTY
  2112. JRST PRINL1
  2113. CTY: JSA A,TYOI
  2114. TYOI: X
  2115. PSAVE A
  2116. LDB A,[POINT 6,-1(A),ACFLD]
  2117. PCALL (R)
  2118. PREST A
  2119. JRA A,(A)
  2120. PAGE
  2121. PRINN:
  2122. FOO MOVEI B,PNAME
  2123. PCALL GET4
  2124. JUMPE A,PRINL
  2125. CARA A,D
  2126. PCALL PRIDST
  2127. ILDB A,C
  2128. JUMPE A,CPOPJ ;special case of null character
  2129. PRIN2X: JUMPL R,PRIN4 ;never slash
  2130. LDB B,SL1FLD
  2131. JRST PRIN2N(B) ;1 for no slash
  2132. PRIN3: SKIPL CHRTAB(A) ;<0 for no slash
  2133. PRIN2N: PCALL SLSHPR ;slashify
  2134. PRIN4: PCALL (R)
  2135. ILDB A,C
  2136. PRIN5: JUMPN A,PRIN3+X ;prin4 for never slash
  2137. PRET
  2138. PSTR: PCALL PRIDST
  2139. MOVE A,STRBEG
  2140. JRST PSTR3
  2141. PSTREC: PCALL (R)
  2142. MOVE A,STREND
  2143. PSTR3: SKIPL R ;dont print " if no slashify
  2144. PSTR2: PCALL (R)
  2145. ILDB A,C
  2146. CAMN A,STREND
  2147. JRST PSTREC
  2148. JUMPN A,PSTR2
  2149. MOVE A,STREND
  2150. JUMPGE R,(R)
  2151. PRET
  2152. PRIDST: MOVEI C,2(SP)
  2153. PCALL PNAMU3
  2154. PUSH C,[0]
  2155. HRLI C,(POINT 7,0,35)
  2156. HRRI C,2(SP)
  2157. PRET
  2158. SLSHPR: PSAVE A
  2159. HRRZ A,SLSH
  2160. PCALL (R)
  2161. JRST POPAJ
  2162. PAGE
  2163. PRINO: MOVE A,(A)
  2164. SETZB B,C
  2165. JUMPG A,FP1
  2166. JUMPE A,FP3
  2167. MOVNS A
  2168. XCT "-",CTY
  2169. FP1: CAMGE A,FT01
  2170. JRST FP4
  2171. CAML A,FT8
  2172. AOJA B,FP4
  2173. FP3: MULI A,400
  2174. ASHC B,-243(A)
  2175. MOVE A,B
  2176. SETZM FPTEM#
  2177. PCALL FP7
  2178. XCT ".",CTY
  2179. MOVNI T,8
  2180. ADD T,FPTEM
  2181. MOVE B,C
  2182. FP3A: MOVE A,B
  2183. MULI A,TEN
  2184. PCALL FP7B
  2185. SKIPE B
  2186. AOJL T,FP3A
  2187. PRET
  2188. FP4: MOVNI C,6
  2189. MOVEI TT,0
  2190. FP4A: ADDI TT,1(TT)
  2191. XCT FCP(B)
  2192. TRZA TT,1
  2193. FMPR A,@FCP+1(B)
  2194. AOJN C,FP4A
  2195. PSAVE TT
  2196. MOVNI B,-2(B)
  2197. DPB B,[POINT 2,FP4C,11]
  2198. PCALL FP3
  2199. MOVEI A,"E"
  2200. PCALL (R)
  2201. FP4C: XCT "+"+X,CTY
  2202. PREST A
  2203. FP7: JUMPE A,FP7B
  2204. IDIVI A,TEN
  2205. AOS FPTEM
  2206. HRLM B,(P)
  2207. JUMPE A,FP7A1
  2208. PCALL FP7
  2209. FP7A1: HLRE A,(P)
  2210. FP7B: ADDI A,"0"
  2211. JRST (R)
  2212. PAGE
  2213. 353473426555 ;1e32
  2214. 266434157116 ;1e16
  2215. FT8: 1.0E8
  2216. 1.0E4
  2217. 1.0E2
  2218. 1.0E1
  2219. FT: 1.0E0
  2220. 026637304365 ;1e-32
  2221. 113715126246 ;1e-16
  2222. 146527461671 ;1e-8
  2223. 163643334273 ;1e-4
  2224. 172507534122 ;1e-2
  2225. FT01: 175631463146 ;1e-1
  2226. FT0:
  2227. FCP: CAMLE A,FT0(C)
  2228. CAMGE A,FT(C)
  2229. XWD C,FT0
  2230. SUBTTL SUPER FAST TABLE DRIVEN READ --- PAGE 10
  2231. ;magic scanner table bit definitions
  2232. ;bit 0=0 iff slashified as nth id character
  2233. ;bit 1=0 iff slashified as 1st id character
  2234. ;bits 2-5 ratab index
  2235. ;bits 6-8 dotab index
  2236. ;bits 9-10 strtab index
  2237. ;bits 11-13 idtab index
  2238. ;bits 14-16 exptab index
  2239. ;bits 17-19 rdtab index
  2240. ;bits 20-25 ascii to radix 50 conversion
  2241. ;bits used by the alternative SCANner
  2242. ;bits 26-29 ratab index
  2243. ;bits 30-31 strtab index
  2244. ;bits 32-34 idtab index
  2245. ;bit 35=0 iff slashified as 1st id character
  2246. ;bit 32=0 iff slashified as nth id character
  2247. ;The following 8 words are modified by SCANSET and SCANRESET
  2248. IGEND: CRLF
  2249. STRBEG: DBLQT ;string start
  2250. STREND: DBLQT ;string end
  2251. SLSH: XWD PRIN3,"!" ;slashtest,slashifier
  2252. SL1FLD: POINT 1,CHRTAB(A),1
  2253. RATFLD: POINT 4,CHRTAB(A),5
  2254. STRFLD: POINT 2,CHRTAB(A),10
  2255. IDFLD: POINT 3,CHRTAB(A),13
  2256. DOTFLD:
  2257. NUMFLD: POINT 3,CHRTAB(A),8
  2258. EXPFLD: POINT 3,CHRTAB(A),16
  2259. RDFLD: POINT 3,CHRTAB(A),19
  2260. R50FLD: POINT 6,CHRTAB(A),25
  2261. ;magic state flags in t
  2262. EXP==1 ;exponent
  2263. NEXP==2 ;negative exponent
  2264. SAWDOT==4 ;saw a dot (.)
  2265. MINSGN==10 ;negative number
  2266. IFN ROCT,<OCTNM==20 ;octal number (saw a L)
  2267. RDIG==6 >
  2268. IFE ROCT,RDIG==5
  2269. ;atom type in R for SCAN
  2270. IDCLS==0 ;identifier
  2271. STRCLS==1 ;string
  2272. NUMCLS==2 ;number
  2273. DELCLS==3 ;delimiter
  2274. PAGE
  2275. ;macros for scanner table
  2276. DEFINE RAD50 (X)<
  2277. IFB <X>,<R50VAL=0>
  2278. IFLE <"X"-"9">,<IFGE <"X"-"0">,<R50VAL="X"-"0"+1>>
  2279. IFIDN <"X"><".">,<R50VAL=45>
  2280. IFIDN <"X"><"$">,<R50VAL=46>
  2281. IFIDN <"X"><"%">,<R50VAL=47>
  2282. IFGE <"X"-"A">,<R50VAL="X"-"A"+13>>
  2283. DEFINE TABIN (SN,S1,R,D,S,I,E,RD,R50,RE<2>,SE<3>,IE<2>,S1E<0>)<
  2284. XLIST
  2285. IRPC R50< RAD50 (R50)
  2286. BYTE (1)SN,S1(4)R(3)D(2)S(3)I,E,RD(6)R50VAL(4)RE(2)SE(3)IE(1)S1E>
  2287. LIST>
  2288. DEFINE LET (X)<
  2289. TABIN (0,0,5,2,3,4,2,0,X)>
  2290. DEFINE SCNLET (X)<
  2291. TABIN (1,1,5,2,3,4,2,0,X,5,3,4,1)>
  2292. DEFINE DELIMIT (X,Y)<
  2293. TABIN (0,0,2,2,3,2,2,Y,X)>
  2294. DEFINE IGNORE (X)<
  2295. TABIN (0,0,3,2,3,2,2,0,X,3)>
  2296. PAGE
  2297. CHRTAB:
  2298. TABIN (0,0,1,1,1,1,1,0,< >,1,1,1)
  2299. ;null
  2300. LET (< >)
  2301. IGNORE (< >)
  2302. ;tab,lf,vtab,ff,cr
  2303. LET (< >)
  2304. ;16 to 31
  2305. TABIN (0,0,0,0,0,0,0,0,< >,0,0,0)
  2306. ;igmrk
  2307. LET (< >)
  2308. ;33 -- <ESC> JUST A LETTER WHEN IN A FILE.
  2309. LET (< >)
  2310. ;34 to 36
  2311. IGNORE (< >)
  2312. ;37 (EOL) and space
  2313. TABIN (0,0,4,2,3,3,2,0,< >,4,3,3)
  2314. ;! the new slashifier
  2315. TABIN (0,0,9,2,2,2,2,0,< >,9,2)
  2316. ;"
  2317. LET (< $>)
  2318. ;#$
  2319. TABIN (0,0,0,0,3,0,0,0,<%>,0,3,0)
  2320. ;% is comment start
  2321. LET (< >)
  2322. ;&
  2323. TABIN (0,0,2,2,3,4,2,5,< >)
  2324. ;' the new quote character
  2325. DELIMIT (< >,0)
  2326. DELIMIT (< >,1)
  2327. ;()
  2328. LET (< >)
  2329. ;*
  2330. TABIN (0,0,3,2,3,4,2,0,< >)
  2331. ;+
  2332. TABIN (0,0,3,2,3,2,2,0,< >)
  2333. ;, ignored for READ, delimit for SCAN
  2334. TABIN (0,0,6,2,3,4,2,0,< >)
  2335. ;-
  2336. TABIN (0,0,7,3,3,2,2,4,<.>,7)
  2337. LET (< >)
  2338. ;/ old slashifyer is just a letter now
  2339. TABIN (1,0,8,RDIG,3,4,3,0,<0123456789>,8,3,4)
  2340. LET (< >)
  2341. ;:;
  2342. DELIMIT (< >,2)
  2343. ;< super paranthesis
  2344. LET (< >)
  2345. ;=
  2346. DELIMIT (< >,3)
  2347. ;> super paranthesis
  2348. LET (< >)
  2349. ;?
  2350. LET (< >)
  2351. ;@ old quote character is just a letter now
  2352. SCNLET (<ABCD>)
  2353. TABIN (1,1,5,4,3,4,2,0,<E>,5,3,4,1)
  2354. ;E exponent for floating point number
  2355. SCNLET (<FGHIJK>)
  2356. IFE ROCT,SCNLET(<L>)
  2357. IFN ROCT,<
  2358. TABIN (1,1,5,5,3,4,2,0,<L>,5,3,4,1)
  2359. ;L ends an octal number >
  2360. SCNLET (<MNOPQRSTUVWXYZ>)
  2361. DELIMIT (< >,6)
  2362. ;[ vector start
  2363. LET (< >)
  2364. ;\
  2365. DELIMIT (< >,3)
  2366. ;] vector end
  2367. LET (< >)
  2368. ;^_`
  2369. SCNLET (<ABCDEFGHIJKLMNOPQRSTUVWXYZ>)
  2370. ;lower case
  2371. LET (< >)
  2372. ;{
  2373. DELIMIT (< >,3)
  2374. ;175 -- ALTMODE (ALSO DECUS' 33 CONVERTED DURING TTI INPUT).
  2375. LET (< >)
  2376. ;~
  2377. DELIMIT (< >,6)
  2378. ;rubout
  2379. PAGE
  2380. IDCHTAB:BLOCK "?" ;table of character ids. updated by INTERN and
  2381. FOO XWD 0,QST
  2382. BLOCK 100-"?"-1 ; REMOB. refered to by READCH and EXPLODE.
  2383. READCH: PCALL TYI
  2384. RECH1: TRNN A,100
  2385. SKIPA C,IDCHTAB(A)
  2386. HLRZ C,IDCHTAB-100(A)
  2387. TRNE C,-1 ;is it in character id table ?
  2388. JRST RETC ;yes! return it
  2389. PSAVE TT ;save TT and
  2390. PSAVE T ; T for EXPLODE
  2391. LSH A,35
  2392. MOVE C,SP
  2393. PUSH C,A
  2394. PCALL INTER0
  2395. PREST T
  2396. PREST TT
  2397. PRET
  2398. READP1: SETZM NOINFG
  2399. READ0: PSAVE TYID
  2400. PSAVE OLDCH
  2401. SETZM OLDCH#
  2402. HRLI A,(JRST)
  2403. MOVEM A,TYID
  2404. PCALL READ+1
  2405. PREST OLDCH
  2406. PREST TYID
  2407. PRET
  2408. RDRUB: MOVEI A,CR
  2409. PCALL TTYO
  2410. MOVEI A,LF
  2411. PCALL TTYO
  2412. SKIPA P,PSAV#
  2413. READ: SETZM NOINFG# ;0 means intern
  2414. SKIPN OLSCNV
  2415. JRST READD
  2416. SETZ A,
  2417. PCALL SCANSET
  2418. PSAVE A
  2419. PCALL READD
  2420. EXCH A,(P)
  2421. PCALL SCANSET
  2422. JRST POPAJ
  2423. READD: MOVEM P,PSAV
  2424. PCALL READ1
  2425. SETZM PSAV
  2426. PRET
  2427. READ1: PCALL RATOM
  2428. PRET ;atom
  2429. XCT RDTAB2(B)
  2430. JRST READ1 ;try again
  2431. RDTAB2: JRST READ2 ;0 (
  2432. JFCL ;1 )
  2433. JRST READ4 ;2 <
  2434. JFCL ;3 ],>,$
  2435. JFCL ;4 .
  2436. JRST RDQT ;5 '
  2437. JRST READVC ;6 [
  2438. READ2: PCALL RATOM
  2439. JRST READ2A ;atom
  2440. XCT RDTAB(B)
  2441. READ2A: PSAVE A
  2442. PCALL READ2
  2443. PREST B
  2444. JRST XCONS
  2445. RDTAB: PCALL READ2 ;0 (
  2446. JRST FALSE ;1 )
  2447. PCALL READ4 ;2 <
  2448. JRST READ5 ;3 ],>,$
  2449. JRST RDT ;4 .
  2450. PCALL RDQT ;5 '
  2451. PCALL READVC ;6 [
  2452. RDTX: PCALL RATOM
  2453. PRET ;atom
  2454. XCT RDTAB2(B)
  2455. DOTERR: SETZM OLDCH
  2456. ERRL0 ^D133,[SIXBIT /DOT CONTEXT ERROR!/]
  2457. RDT: PCALL RDTX
  2458. PSAVE A
  2459. PCALL RATOM
  2460. JRST DOTERR
  2461. CAIN B,1
  2462. JRST POPAJ
  2463. CAIE B,3
  2464. JRST DOTERR
  2465. MOVEM A,OLDCH
  2466. JRST POPAJ
  2467. READ4: PCALL READ2
  2468. MOVE B,OLDCH
  2469. CAIE B,ALTMOD
  2470. TYI1: SETZM OLDCH ;kill the > or ]
  2471. PRET
  2472. READ5: MOVEM A,OLDCH ;save > or ] or $
  2473. JRST FALSE ;and return nil
  2474. RDQT: PCALL READ1
  2475. QTIFY: PCALL NCONS
  2476. FOO HRLI A,CQUOTE
  2477. JRST DCONSA
  2478. ;skip a comment
  2479. COMENT: CAIN A,IGCRLF ;^Z ?
  2480. JRST COMIGN ;yes. end on CRLF
  2481. MOVE A,IGEND ;no. end on IGEND
  2482. HRRM A,COMM+1 ;set end char
  2483. COMM: PCALL TYIC ;AR4 must contain 1 here
  2484. CAIE A,CRLF+X
  2485. JRST COMM
  2486. PRET
  2487. ;skip a super (^Z) comment
  2488. COMIGN: PCALL TYID1 ;AR4 must contain 1 here
  2489. CAIE A,CRLF
  2490. JRST COMIGN
  2491. PRET
  2492. PAGE
  2493. READVC: PCALL READ2
  2494. MOVE B,OLDCH
  2495. ENDVC: CAIN B,"]"
  2496. SETZM OLDCH
  2497. LTOVEC: JUMPE A,CPOPJ
  2498. PSAVE A ;save list
  2499. CDRA A,(A)
  2500. PCALL LENGTH
  2501. PCALL MKVECT ;make a vector
  2502. CDRA B,(A)
  2503. EXCH A,(P)
  2504. MOVSI C,(POINT 18,(B))
  2505. MOVS A,(A)
  2506. IDPB A,C
  2507. CARA A,A
  2508. JUMPN A,.-3
  2509. JRST POPAJ
  2510. PAGE
  2511. ;atom parser
  2512. RATOM: SETZB T,R ;IDCLS in R
  2513. HRLI C,(POINT 7,0,35)
  2514. HRRI C,(SP)
  2515. SETZM 1(C) ;clear first word
  2516. MOVEI AR4,1
  2517. RATOM2: PCALL TYID1
  2518. LDB B,RATFLD
  2519. JRST RATAB(B)
  2520. RATAB: PCALL COMENT ;0 comment
  2521. JRST RATOM2 ;1 null
  2522. JRST RATOM3 ;2 delimit
  2523. JRST RATOM2 ;3 ignore
  2524. PCALL TYIC ;4 !
  2525. JRST RDID ;5 letter
  2526. JRST RDNMIN ;6 -
  2527. JRST RDOT ;7 .
  2528. JRST RDNUM ;8 digit
  2529. JRST RDSTR ;9 string
  2530. ;a real dotted pair
  2531. RDOT2: MOVEM A,OLDCH
  2532. MOVEI A,"."
  2533. RATOM3: LDB B,RDFLD
  2534. HRRI R,DELCLS ;delimiter
  2535. CPOPJ1: PSKPRT ;non-atom (ie a delimiter)
  2536. PRET
  2537. ;dot handler
  2538. RDOT: PCALL TYID1
  2539. LDB B,DOTFLD
  2540. JRST DOTAB(B)
  2541. DOTAB: PCALL COMENT ;0 comment
  2542. JRST RDOT ;1 null
  2543. JRST RDOT2 ;2 delimit
  2544. JRST RDOT2 ;3 dot
  2545. JRST RDOT2 ;4 E
  2546. IFN ROCT,JRST RDOT2 ;5 L
  2547. MOVEI B,0 ;6 (5) digit
  2548. IDPB B,C
  2549. TLO T,SAWDOT
  2550. JRST RDNUM
  2551. PAGE
  2552. ;string scanner
  2553. STRTAB: PCALL COMENT ;0 comment
  2554. JRST RDSTR ;1 null
  2555. JRST STR2 ;2 delimit
  2556. IDPB A,C ;3 string element
  2557. RDSTR: PCALL TYID1
  2558. LDB B,STRFLD ;A huge string (e.g. missing close-quote)
  2559. JRST STRTAB(B) ; will overflow SPDL and clobber I/O bufs.
  2560. STR2: PCALL TYID1
  2561. LDB B,STRFLD
  2562. CAIN B,2
  2563. JRST RDSTR-1
  2564. MOVEM A,OLDCH
  2565. HRRI R,STRCLS ;string
  2566. LMKSTR: PCALL IDEND
  2567. MSTR1: PCALL IDSUB
  2568. PCALL PNAMAK
  2569. HRLI A,STRNG
  2570. JRST DCONSA
  2571. ;identifier scanner
  2572. IDTAB: PCALL COMENT ;0
  2573. JRST RDID+1 ;1 null
  2574. JRST MAKID ;2 delimit
  2575. PCALL TYIC ;3 !
  2576. RDID: IDPB A,C ;4 letter or digit
  2577. PCALL TYID1
  2578. LDB B,IDFLD
  2579. JRST IDTAB(B)
  2580. PAGE
  2581. ;number scanner
  2582. NUMTAB: PCALL COMENT ;0 comment
  2583. JRST RDNUM+1 ;1 null
  2584. JRST NUMAK ;2 delimit
  2585. JRST RDNDOT ;3 dot
  2586. JRST RDE ;4 e
  2587. IFN ROCT,JRST OCTNUM ;5 L
  2588. RDNUM: IDPB A,C ;6 (5) digit
  2589. PCALL TYID1
  2590. LDB B,NUMFLD
  2591. JRST NUMTAB(B)
  2592. RDNDOT: TLOE T,SAWDOT
  2593. JRST NUMAK ;two dots - delimit
  2594. MOVEI A,0
  2595. JRST RDNUM
  2596. RDNMIN: TLO T,MINSGN
  2597. JRST RDNUM+1
  2598. ;exponent scanner
  2599. RDE: TLO T,EXP
  2600. MOVEI A,0
  2601. IDPB A,C
  2602. PCALL TYID1
  2603. CAIN A,"-"
  2604. TLOA T,NEXP
  2605. CAIN A,"+"
  2606. JRST RDE2+1
  2607. JRST RDE2+2
  2608. EXPTAB: PCALL COMENT ;0
  2609. JRST RDE2+1 ;1 null
  2610. JRST NUMAK ;2 delimit
  2611. RDE2: IDPB A,C ;3 digit
  2612. PCALL TYID1
  2613. LDB B,EXPFLD
  2614. JRST EXPTAB(B)
  2615. IFN ROCT,<
  2616. OCTNUM: TLO T,OCTNM
  2617. PCALL TYID1
  2618. LDB B,NUMFLD
  2619. SOJG B,NUMAK
  2620. JUMPL B,OCTNUM+1
  2621. PCALL COMENT
  2622. JRST B,OCTNUM+1 >
  2623. PAGE
  2624. ;semantic routines
  2625. ;identifier interner and builder
  2626. IDEND: TDZA A,A
  2627. IDEND1: IDPB A,C
  2628. TLNE C,760000
  2629. JRST IDEND1
  2630. PRET
  2631. MAKID: MOVEM A,OLDCH
  2632. PCALL IDEND
  2633. SKIPE NOINFG
  2634. JRST NOINTR ;dont intern it
  2635. INTER0: PCALL INTER2 ;is it in oblist
  2636. PRET ;found
  2637. PCALL PNAIMK ;not there
  2638. MAKID2: SKIPGE C,IDCHPO# ;character id ?
  2639. JRST MKID2 ;no!
  2640. TRNN C,100
  2641. JRST .+3
  2642. HRLM A,IDCHTAB-100(C)
  2643. JRST MKID2
  2644. HRRM A,IDCHTAB(C)
  2645. MKID2: MOVE C,CURBUC
  2646. HLRZ B,@RHX2
  2647. PCALL CONS ;cons it into the oblist
  2648. HRLM A,@RHX2
  2649. JRST CAR
  2650. CURBUC: 0
  2651. ;pname unmaker
  2652. PNAMUK: MOVE C,SP
  2653. PNAMUD: PCALL GETPNM
  2654. PNAMU3: CARA B,(A)
  2655. PUSH C,(B)
  2656. CDRA A,(A)
  2657. JUMPN A,PNAMU3
  2658. PRET
  2659. ;idsub constructs a iowd pointer for a print name
  2660. IDSUB: HRRZS C
  2661. CAML C,JRELO ;top of spec pdl
  2662. JRST SPDLOV
  2663. MOVNS C
  2664. ADDI C,(SP)
  2665. HRLZS C
  2666. HRRI C,1(SP)
  2667. MOVEM C,IDPTR#
  2668. MOVEI B,1
  2669. ANDCAM B,(C) ;clear low bit
  2670. AOBJN C,.-1
  2671. PRET
  2672. NOINTR: PCALL IDSUB
  2673. PNAIMK: PCALL PNAMAK
  2674. JRST PNGNK1
  2675. PAGE
  2676. ;identifier interner
  2677. INTERT: PCALL PNAMUK
  2678. INTER2: PCALL IDSUB
  2679. INTER1: MOVE B,1(SP) ;get first word of pname
  2680. LSH B,-1 ;right justify it
  2681. SETOM IDCHPO ;indicate no character id
  2682. TDNE B,[1777,,777777] ;character id ?
  2683. JRST INT1 ;no!
  2684. MOVE T,B
  2685. LSH T,-12
  2686. HLRZM T,IDCHPO ;is a character id
  2687. INT1: IDIVI B,BCKETS+X ;compute hash code
  2688. RHX2:
  2689. FOO HLRZ T,OBTBL(B+1) ;get bucket
  2690. MOVEM B+1,CURBUC ;save bucket number
  2691. MOVE C,T
  2692. JRST MAKID1
  2693. MAKID3: MOVE C,T ;save previous atom
  2694. CDRA T,(T) ;get next atom
  2695. MAKID1: JUMPE T,CPOPJ1 ;not in oblist
  2696. CARA A,(T) ;next id in oblist
  2697. FOO MOVEI B,PNAME
  2698. PCALL IGET
  2699. JUMPE A,[ERRL2 ^D167,[SIXBIT \MISSING PRINT NAME IN OBLIST!\]]
  2700. MOVE D,IDPTR ;found pname
  2701. MAKID5: JUMPE A,MAKID3 ;not the one
  2702. MOVS A,(A)
  2703. MOVE B,(A)
  2704. CAME B,(D)
  2705. JRST MAKID3 ;not the one
  2706. CARA A,A ;ok so far
  2707. AOBJN D,MAKID5
  2708. JUMPN A,MAKID3 ;not the one
  2709. CARA A,(T) ;this is it
  2710. CARA B,(C)
  2711. RPLCA A,(C)
  2712. RPLCA B,(T)
  2713. PRET
  2714. ;pname builder
  2715. PNAMAK: MOVE T,IDPTR
  2716. MOVEI TT,C
  2717. PNAMB: MOVE A,(T)
  2718. PCALL FWCONS
  2719. PCALL NCONS
  2720. RPLCD A,(TT)
  2721. MOVE TT,A
  2722. AOBJN T,PNAMB
  2723. RETC: HRRZ A,C
  2724. PRET
  2725. PAGE
  2726. ;number builder
  2727. NUMAK: MOVEM A,OLDCH
  2728. HRRI R,NUMCLS ;number
  2729. MOVEI A,0
  2730. IDPB A,C
  2731. IDPB A,C
  2732. HRRZS C
  2733. CAML C,JRELO ;top of spec pdl
  2734. JRST SPDLOV
  2735. MOVSI C,(POINT 7,0,35)
  2736. HRRI C,(SP)
  2737. TLNE T,SAWDOT+EXP
  2738. JRST NUMAK2 ;decimal number or flt pt
  2739. FOO MOVE A,VIBASE ;ibase integrer
  2740. SUBI A,INUM0
  2741. IFN ROCT,<TLNE T,OCTNM
  2742. MOVEI A,10 ;octal number >
  2743. PCALL NUM
  2744. NUMAK4:
  2745. MOVEI B,FIXNU
  2746. NUMAK6: TLNE T,MINSGN
  2747. MOVNS A
  2748. JRST MAKNUM
  2749. NUMAK2: PCALL NUM10
  2750. MOVEM A,TT
  2751. TLNN T,SAWDOT
  2752. JRST [PCALL FLOAT1 ;flt pt without fraction
  2753. MOVE TT,A
  2754. JRST NUMAK3]
  2755. PCALL NUM10 ;fraction part
  2756. EXCH A,TT
  2757. TLNN T,EXP
  2758. JUMPE AR5,NUMAK4 ;no exponent and no fraction
  2759. PCALL FLOAT1
  2760. EXCH A,TT
  2761. PCALL FLOAT1
  2762. MOVEI AR4,FT01
  2763. PCALL FLOSUB
  2764. FMPR A,B
  2765. FADRM A,TT
  2766. NUMAK3: PCALL NUM10 ;exponent part
  2767. MOVE AR5,A
  2768. MOVEI AR4,FT-1
  2769. TLNE T,NEXP
  2770. MOVEI AR4,FT01 ;-exponent
  2771. PCALL FLOSUB
  2772. FMPR TT,B ;positive exponent
  2773. MOVEI B,FLONU
  2774. MOVE A,TT
  2775. JFCL 10,FLOOV
  2776. JRST NUMAK6
  2777. PAGE
  2778. FLOSUB: MOVSI B,(1.0)
  2779. TRZE AR5,1
  2780. FMPR B,(AR4)
  2781. JUMPE AR5,CPOPJ
  2782. LSH AR5,-1
  2783. SOJA AR4,FLOSUB+1
  2784. ;variable radix integer builder
  2785. NUM10: MOVEI A,TEN
  2786. NUM: HRRM A,NUM1
  2787. JFCL 10,.+1 ;clear carry0 flag
  2788. SETZB A,AR5
  2789. NUM2: ILDB B,C
  2790. JUMPE B,CPOPJ ;done
  2791. NUM1: IMULI A,X
  2792. ADDI A,-"0"(B)
  2793. NUM3: JFCL 10,RDBNM
  2794. AOJA AR5,NUM2
  2795. PAGE
  2796. INTERN: MOVEM A,AR5
  2797. PCALL INTERT ;is it in oblist
  2798. PRET ;found it
  2799. MOVE A,AR5 ;not there
  2800. CARA B,(A)
  2801. CAIE B,STRNG
  2802. JRST MAKID2 ;put it there
  2803. CDRA A,(A)
  2804. PCALL PNGNK1 ;make an id of it
  2805. JRST MAKID2
  2806. REMOB: JUMPE A,CPOPJ ;never remove NIL
  2807. JSP D,NILID ;return NIL if not an id
  2808. PSAVE A
  2809. PCALL INTERT
  2810. SKIPA B,CURBUC
  2811. JRST POPAJ ;not on oblist
  2812. RHX5:
  2813. FOO HLRZ C,OBTBL+X(B)
  2814. CARA T,(C)
  2815. CAMN T,A
  2816. JRST [CDRA TT,(C)
  2817. HRLM TT,@RHX5
  2818. JRST POPAJ]
  2819. REMOB3: MOVE TT,C
  2820. CDRA C,(C)
  2821. CARA T,(C)
  2822. CAME T,A
  2823. JRST REMOB3
  2824. CDRA T,(C)
  2825. RPLCD T,(TT)
  2826. SKIPGE C,IDCHPO ;character id ?
  2827. JRST POPAJ ;no!
  2828. TRNN C,100
  2829. JRST .+3
  2830. HRRZM IDCHTAB-100(C)
  2831. JRST POPAJ
  2832. HLLZM IDCHTAB(C)
  2833. POPAJ: PREST A
  2834. PRET
  2835. ;Get print name for identifier or string. Return with skip if sucessful.
  2836. GETPNM: JSP D,ATMTYP
  2837. JRST .+2
  2838. NOPNAM: ERRL0 ^D134,[SIXBIT /NO PRINT NAME!/]
  2839. CDRA A,(A)
  2840. CAIN TT,STRNG ;is it a string?
  2841. JUMPN A,CPOPJ ;yes
  2842. CAIE TT,ID
  2843. JRST NOPNAM
  2844. FOO MOVEI B,PNAME
  2845. PCALL GET4
  2846. JUMPE A,NOPNAM ;didn't find it
  2847. CARA A,D
  2848. PRET
  2849. PAGE
  2850. ;return NIL if argument is not on the oblist
  2851. .INTERNP:JSP D,NILID ;return NIL if not an id
  2852. MOVE AR5,A
  2853. PCALL GT1PNM ;get first word of pname
  2854. MOVE B,A
  2855. LSH B,-1
  2856. XCT INT1 ;compute hash code
  2857. XCT INT1+1 ;get bucket
  2858. EXCH A,T
  2859. MOVE B,AR5
  2860. JRST FLAGP1
  2861. ;SKIPTO subr 1 arg. Skips reading until found character that matches
  2862. ; first character in the argument
  2863. SKIPTO: MOVEI AR4,1
  2864. PSAVE A
  2865. PCALL GTFCH
  2866. PCALL COMM-1 ;read as comment
  2867. JRST POPAJ
  2868. RDSLSH: MOVE D,[POINT 18,NQUOT]
  2869. MOVE R,[POINT 7,[ASCIZ "%'!@/<>["]]
  2870. MOVEI B,(5B3+2B6+3B8+4B11+2B14) ;Letter
  2871. JUMPN A,RDSL2
  2872. MOVEI B,(3B8) ;Comment
  2873. AOJA D,RDSL2
  2874. RDSL1: DPB B,[POINT 18,CHRTAB(A),19]
  2875. ILDB B,D
  2876. RDSL2: ILDB A,R
  2877. JUMPN A,RDSL1
  2878. JRST SCANSET
  2879. NQUOT: <5B3+2B6+3B8+4B11+2B14+0B17>+<5B21+2B24+3B26+4B29+2B32+0B35>
  2880. <2B3+2B6+3B8+4B11+2B14+5B17>+<4B21+2B24+3B26+3B29+2B32+0B35>
  2881. <5B3+2B6+3B8+4B11+2B14+0B17>+<5B21+2B24+3B26+4B29+2B32+0B35>
  2882. <2B3+2B6+3B8+2B11+2B14+2B17>+<2B21+2B24+3B26+2B29+2B32+3B35>
  2883. <2B3+2B6+3B8+2B11+2B14+6B17>
  2884. PAGE
  2885. ; SCAN -- GENERAL PURPOSE ADAPTER FOR LISP SCANNER
  2886. OLDSCN: CRLF ;IGEND
  2887. DBLQT ;STRBEG
  2888. DBLQT ;STREND
  2889. XWD PRIN3,"!" ;SLSH
  2890. POINT 1,CHRTAB(A),1 ;SL1FLD
  2891. POINT 4,CHRTAB(A),5 ;RATFLD
  2892. POINT 2,CHRTAB(A),10 ;STRFLD
  2893. POINT 3,CHRTAB(A),13 ;IDFLD
  2894. IGEND2: CRLF+X ;IGEND
  2895. STRBE2: DBLQT ;STRBEG
  2896. STREN2: DBLQT ;STREND
  2897. SLSH2: XWD PRIN3C,"!"+X ;SLSH
  2898. SL1F2: POINT 1,CHRTAB(A),35 ;SL1FLD
  2899. RATF2: POINT 4,CHRTAB(A),29 ;RATFLD
  2900. STRF2: POINT 2,CHRTAB(A),31 ;STRFLD
  2901. IDF2: POINT 3,CHRTAB(A),34 ;IDFLD
  2902. LETFLD: POINT 1,CHRTAB(A),32 ;ON IF LETTER OR DIGIT
  2903. ALLFLD: POINT 10,CHRTAB(A),35 ;ALL NEW FIELDS
  2904. SCANSET:JUMPN A,.+2
  2905. SKIPA B,[XWD OLDSCN,IGEND]
  2906. MOVE B,[XWD IGEND2,IGEND]
  2907. BLT B,IDFLD
  2908. EXCH A,OLSCNV# ;Get previous setting
  2909. PRET
  2910. PRIN3C: LDB B,LETFLD
  2911. JRST PRIN2N(B)
  2912. PAGE
  2913. SCAN: SETOM NOINFG
  2914. PCALL RATOM
  2915. SKIPA
  2916. PCALL READCH+1
  2917. FOO MOVEM A,SCNV
  2918. MOVEI A,INUM0(R)
  2919. PRET
  2920. UNREADCH:
  2921. PSAVE A
  2922. PCALL GTFCH
  2923. MOVEM A,OLDCH
  2924. JRST POPAJ
  2925. LETTER: MOVEI B,5B29+3B31+4B34+1B35
  2926. LET2: SUBI A,INUM0
  2927. DPB B,ALLFLD
  2928. JRST FALSE
  2929. DELIMITER:
  2930. SKIPA B,[2B29+3B31+2B34+0B35] ;A DELIMITER, NOT A LETTER.
  2931. IGNORE: MOVEI B,3B29+3B31+2B34+0B35
  2932. JRST LET2
  2933. PAGE
  2934. SCANINIT: SUBI A,INUM0
  2935. SUBI B,INUM0
  2936. HRRM A,IGST2 ;IGSTRT
  2937. MOVEM B,IGEND2 ;IGEND
  2938. MOVEI B,2B29+3B31+2B34+0B35 ;DELIMITER
  2939. MOVEI A,177
  2940. DPB B,ALLFLD
  2941. SOJG A,.-1
  2942. MOVE A,[XWD "A"-"Z"-1,"A"]
  2943. MOVEI B,5B29+3B31+4B34+1B35 ;LETTER
  2944. DPB B,ALLFLD
  2945. AOBJN A,.-1
  2946. MOVE A,[XWD "a"-"z"-1,"a"]
  2947. DPB B,ALLFLD
  2948. AOBJN A,.-1
  2949. MOVE A,[XWD "0"-"9"-1,"0"]
  2950. MOVEI B,8B29+3B31+4B34+0B35 ;DIGIT
  2951. DPB B,ALLFLD
  2952. AOBJN A,.-1
  2953. IGST2: MOVEI A,X
  2954. MOVEI B,0 ;IGSTRT
  2955. DPB B,ALLFLD
  2956. MOVEI A,-INUM0(AR4) ;STREND
  2957. MOVEM A,STREN2
  2958. MOVEI B,2
  2959. DPB B,STRF2
  2960. MOVEI A,-INUM0(C) ;STRBEG
  2961. MOVEM A,STRBE2
  2962. MOVEI B,9
  2963. DPB B,RATF2
  2964. MOVEI A,-INUM0(AR5)
  2965. HRRM AR5,SLSH2 ;SLASHIFIER
  2966. MOVEI B,4B29+3B31+3B34+0B35 ;SLASHIFIER
  2967. DPB B,ALLFLD
  2968. MOVEI A,0 ;NULL
  2969. MOVEI B,1B29+1B31+1B34+0B35 ;NULL
  2970. DPB B,ALLFLD
  2971. MOVEI A,"."
  2972. MOVEI B,7
  2973. DPB B,RATF2
  2974. SETZM CHRTAB+IGCRLF ;^Z IS ALWAYS A COMMENT-CHAR.
  2975. JRST FALSE
  2976. SUBTTL LISP INTERPRETER SUBROUTINES --- PAGE 11
  2977. IF1,PURGE CDR
  2978. CADDDR: SKIPA A,(A)
  2979. CADDAR: CARA A,(A)
  2980. CADDR: SKIPA A,(A)
  2981. CADAR: CARA A,(A)
  2982. CADR: SKIPA A,(A)
  2983. CAAR: CARA A,(A)
  2984. CAR: CARA A,(A)
  2985. PRET
  2986. CDDDDR: SKIPA A,(A)
  2987. CDDDAR: CARA A,(A)
  2988. CDDDR: SKIPA A,(A)
  2989. CDDAR: CARA A,(A)
  2990. CDDR: SKIPA A,(A)
  2991. CDAR: CARA A,(A)
  2992. CDR: CDRA A,(A)
  2993. PRET
  2994. CAADDR: SKIPA A,(A)
  2995. CAADAR: CARA A,(A)
  2996. CAADR: SKIPA A,(A)
  2997. CAAAR: CARA A,(A)
  2998. JRST CAAR
  2999. CDADDR: SKIPA A,(A)
  3000. CDADAR: CARA A,(A)
  3001. CDADR: SKIPA A,(A)
  3002. CDAAR: CARA A,(A)
  3003. JRST CDAR
  3004. CAAADR: SKIPA A,(A)
  3005. CAAAAR: CARA A,(A)
  3006. JRST CAAAR
  3007. CDDADR: SKIPA A,(A)
  3008. CDDAAR: CARA A,(A)
  3009. JRST CDDAR
  3010. CDAADR: SKIPA A,(A)
  3011. CDAAAR: CARA A,(A)
  3012. JRST CDAAR
  3013. CADADR: SKIPA A,(A)
  3014. CADAAR: CARA A,(A)
  3015. JRST CADAR
  3016. RPLACA: RPLCA B,(A)
  3017. PRET
  3018. RPLACD: RPLCD B,(A)
  3019. PRET
  3020. PAGE
  3021. QUOTE: CARA A,(A) ;car and quote duplicated for backtrace
  3022. PRET
  3023. AASCII: PCALL NUMVAL
  3024. LSH A,^D29
  3025. PNGNK2: PCALL BNCONS
  3026. PNGNK1:
  3027. FOO HRLI A,PNAME
  3028. PCALL DCONSA
  3029. PCALL NCONS
  3030. IDCONS: HRLI A,ID
  3031. JRST DCONSA
  3032. NCONS: HRLZS A
  3033. JRST DCONSA
  3034. CONS: EXCH B,A
  3035. XCONS: HRL A,B
  3036. DCONSA:
  3037. IFN CNSPRB,<
  3038. CAIN F,ILLAD
  3039. PCALL AGC>
  3040. EXCH A,(F)
  3041. EXCH A,F
  3042. AOS CONSVAL
  3043. PRET
  3044. FW0CNS: MOVEI A,0
  3045. FWCONS: JUMPN FF,FWC1
  3046. EXCH A,FWC0#
  3047. PCALL AGC
  3048. EXCH A,FWC0
  3049. FWC1: EXCH A,(FF)
  3050. EXCH A,FF
  3051. PRET
  3052. PAGE
  3053. IFE STL,<
  3054. SASSOC: PCALL SAS1
  3055. JCALLF 0,(C)
  3056. PRET
  3057. SAS0: CARA B,T
  3058. SAS1: JUMPE B,CPOPJ
  3059. MOVS T,(B)
  3060. MOVS TT,(T)
  3061. CAIE A,(TT)
  3062. JRST SAS0
  3063. CDRA A,T
  3064. JRST CPOPJ1
  3065. ATSOC: PCALL SAS1
  3066. JRST FALSE > ;end of IFE STL
  3067. IFN STL,<
  3068. ATSOC: EXCH A,B
  3069. PCALL GET4
  3070. SKIPE A
  3071. CDRA A,TT >
  3072. PRET
  3073. REVERSE:SKIPN T,A
  3074. PRET
  3075. MOVEI A,NIL
  3076. HLL A,(T)
  3077. CDRA T,(T)
  3078. PCALL DCONSA
  3079. JUMPN T,.-3
  3080. CPOPJ: PRET
  3081. LENGTH: MOVEI B,0
  3082. LNGTH1: JSP D,ATMTYP
  3083. JRST FIX1
  3084. CDRA A,(A)
  3085. AOJA B,LNGTH1
  3086. LAST: MOVE C,A
  3087. CDRA A,(A)
  3088. JSP D,NATMTYP
  3089. JRST LAST
  3090. JRST RETC
  3091. NATMTYP:SETZ TT,
  3092. CAILE A,INUMIN
  3093. JRST 1(D)
  3094. CARA TT,(A)
  3095. CAILE TT,ATMIN
  3096. JRST 1(D)
  3097. JRST (D)
  3098. PAGE
  3099. PATOM: MOVEI D,TRFA
  3100. PATMTP: JUMPE A,NILIN
  3101. SETZ TT,
  3102. CAILE A,INUMIN
  3103. JRST (D) ;inum
  3104. CAIGE A,@GCP1 ;Base of FWS
  3105. CAIGE A,@GCPP1 ;Base of FS
  3106. SOJA TT,(D) ;not a Lisp cell
  3107. NILIN: CARA TT,(A)
  3108. CAILE TT,ATMIN
  3109. JRST (D) ;atom
  3110. JRST 1(D)
  3111. ATOM: MOVEI D,TRFA
  3112. ATMTYP: SETZ TT,
  3113. CAILE A,INUMIN
  3114. JRST (D) ;inum
  3115. CARA TT,(A)
  3116. CAILE TT,ATMIN
  3117. JRST (D) ;atom
  3118. JRST 1(D)
  3119. PAIRP: JSP D,ATMTYP
  3120. MOVEI A,NIL
  3121. PRET
  3122. CONSTANTP:JSP D,ATMTYP
  3123. CAIN TT,ID
  3124. MOVEI A,NIL
  3125. PRET
  3126. STRINGP:JSP D,ATMTYP
  3127. CAIE TT,STRNG
  3128. MOVEI A,NIL
  3129. PRET
  3130. NUMBERP:JSP D,ATMTYP
  3131. CAILE TT,FLONU
  3132. FALSE: MOVEI A,NIL
  3133. PRET
  3134. FIXP: JSP D,ATMTYP
  3135. CAILE TT,FIXNU
  3136. MOVEI A,NIL
  3137. PRET
  3138. FLOATP: JSP D,ATMTYP
  3139. CAIE TT,FLONU
  3140. MOVEI A,NIL
  3141. PRET
  3142. INUMP: CAIG A,INUMIN
  3143. MOVEI A,NIL
  3144. PRET
  3145. PAGE
  3146. BIGP: JSP D,ATMTYP
  3147. CPOSNU: CAILE TT,POSNU
  3148. JRST FALSE
  3149. JUMPE TT,FALSE
  3150. PRET
  3151. IDP: MOVEI D,TRUE
  3152. NILID: CAILE A,INUMIN
  3153. JRST FALSE
  3154. HLLE TT,(A)
  3155. AOJE TT,(D)
  3156. JRST FALSE ;return NIL if not an id
  3157. ;give error if not id
  3158. CHKID: CAILE A,INUMIN
  3159. JRST NOID
  3160. HLLE TT,(A)
  3161. AOJE TT,(D)
  3162. NOID: ERRE1 ^D25,[SIXBIT /IS NOT AN IDENTIFIER!/]
  3163. EQ: CAMN A,B
  3164. TRFA: JRST TRUE
  3165. JRST FALSE
  3166. ZEROP: JSP D,ONUMV
  3167. JRST FALSE ;BIGNUM CAN'T BE ZERO
  3168. NOT:
  3169. NULL: JUMPN A,FALSE
  3170. TRUE:
  3171. FOO MOVEI A,TRUTH
  3172. PRET
  3173. LITER: PCALL .INTERNP
  3174. JUMPE A,CPOPJ
  3175. ROT T,7
  3176. CAIL T,"A"
  3177. CAILE T,"z"
  3178. JRST FALSE
  3179. CAILE T,"Z"
  3180. CAIL T,"a"
  3181. JRST RETB
  3182. JRST FALSE
  3183. DIGIT: PCALL .INTERNP
  3184. JUMPE A,CPOPJ
  3185. ROT T,7
  3186. CAIL T,"0"
  3187. CAILE T,"9"
  3188. JRST FALSE
  3189. JRST RETB
  3190. PAGE
  3191. IF1,<PURGE GET> ;MONSYM has defined GET, so purge it.
  3192. GETD:
  3193. FOO MOVEI B,FUNCELL
  3194. GET: JSP D,NILID ;return NIL if not id
  3195. IGET: PCALL GET1
  3196. SKIPE A
  3197. GET2: CARA A,D
  3198. PRET
  3199. GET1: CDRA A,(A)
  3200. GET4: JUMPE A,CPOPJ
  3201. GET0: MOVS TT,(A)
  3202. MOVS D,(TT)
  3203. CAIN B,(D)
  3204. PRET
  3205. CARA A,TT
  3206. JUMPN A,GET0
  3207. PRET
  3208. IFE STL,<
  3209. GETL: CDRA A,(A)
  3210. GETL0: CARA T,(A)
  3211. CARA T,(T)
  3212. MOVE C,B
  3213. GETL1: MOVS TT,(C)
  3214. CAIN T,(TT)
  3215. JRST CAR
  3216. CARA C,TT
  3217. JUMPN C,GETL1
  3218. CDRA A,(A)
  3219. JUMPN A,GETL0
  3220. PRET >
  3221. REMD:
  3222. FOO MOVEI B,FUNCELL
  3223. REMPROP:JSP D,NILID ;return NIL if not id
  3224. REMP1: MOVE T,A
  3225. CDRA A,(T)
  3226. JUMPE A,CPOPJ ;we are done if it is not there
  3227. MOVS TT,(A)
  3228. MOVS D,(TT)
  3229. CAIE B,(D)
  3230. JRST REMP1
  3231. HLRM TT,(T)
  3232. JUMPN T,GET2
  3233. HLROM TT,CNIL3 ;reset NIL
  3234. JRST GET2
  3235. PAGE
  3236. PUTD: EXCH A,C
  3237. IPUTD: PCALL XCONS
  3238. EXCH A,C
  3239. FOO MOVEI B,FUNCELL
  3240. PUT: JSP D,CHKID
  3241. MOVE T,A
  3242. MOVE A,B
  3243. JSP D,CHKID
  3244. MOVE A,T
  3245. PCALL GET1
  3246. JUMPN A,CSET1
  3247. MOVE A,C
  3248. PCALL XCONS
  3249. CDRA B,(T)
  3250. PCALL CONS
  3251. RPLCD A,(T)
  3252. JUMPN T,CDAR
  3253. RPLCD A,CNIL3 ;set NIL
  3254. JRST CDAR
  3255. CSET1:
  3256. FOO CAIN B,VALUE
  3257. CARA TT,D
  3258. RPLCD C,(TT)
  3259. JRST RETC
  3260. IFE STL,<
  3261. DEFPROP:
  3262. CDRA C,(A)
  3263. CDRA B,(C)
  3264. CARA A,(A)
  3265. CARA B,(B)
  3266. CARA C,(C)
  3267. PSAVE A
  3268. PCALL PUT
  3269. JRST POPAJ >
  3270. MKCODE: PCALL NUMVAL
  3271. IMKCODE:HRLI A,CODE
  3272. JRST DCONSA
  3273. CODEP: JSP D,ATMTYP
  3274. CAIGE TT,CODMIN
  3275. JRST FALSE
  3276. CAIL TT,ID
  3277. MOVEI A,NIL
  3278. PRET
  3279. PAGE
  3280. FLAGP: JSP D,NILID
  3281. CDRA A,(A)
  3282. FLAGP1: PCALL MEMQ+1
  3283. JUMPN A,TRUE
  3284. PRET
  3285. FLAG: MOVEI D,FLAG1
  3286. FLAGO: HRRM D,FLAGX
  3287. MOVE T,A
  3288. MOVE A,B
  3289. JSP D,CHKID ;flag indicator must be id
  3290. FLAGL: JUMPE T,FALSE
  3291. CARA A,(T)
  3292. FLAGX: PCALL X
  3293. CDRA T,(T)
  3294. JRST FLAGL
  3295. FLAG1: JSP D,CHKID ;may only flag id
  3296. CDRA A,(A)
  3297. PCALL MEMQ+1
  3298. JUMPN A,CPOPJ
  3299. CARA C,(T)
  3300. CDRA A,(C)
  3301. PCALL XCONS
  3302. FLAG2: RPLCD A,(C)
  3303. JUMPN C,CPOPJ
  3304. RPLCD A,CNIL3
  3305. PRET
  3306. REMFLAG:JSP D,FLAGO
  3307. JSP D,NILID
  3308. FLAG3: MOVE C,A
  3309. CDRA A,(C)
  3310. JUMPE A,CPOPJ
  3311. CARA D,(A)
  3312. CAIE B,(D) ;B is preserved by XCONS
  3313. JRST FLAG3
  3314. CDRA A,(A)
  3315. JRST FLAG2
  3316. PAGE
  3317. EQUAL: MOVE C,P ;Unfortunately, if BIGNUMs are involved here,
  3318. EQUAL1: CAMN A,B ; potential AGC so save your variables.
  3319. JRST TRUE
  3320. JSP D,PATMTP
  3321. SKIPA T,TT ;ATOM
  3322. HRROI T,(TT)
  3323. EXCH A,B
  3324. JSP D,PATMTP
  3325. JRST EQLATM ;ATOM
  3326. AOJGE T,NOEQL ;not atom but first arg was
  3327. PSAVE A
  3328. PSAVE B
  3329. CDRA A,TT
  3330. CARA B,(B)
  3331. PCALL EQUAL1
  3332. PREST B
  3333. PREST A
  3334. CDRA A,(A)
  3335. CDRA B,(B)
  3336. JRST EQUAL1
  3337. EQLATM: CAME T,TT ;same atom type ?
  3338. JRST NOEQL ;no, try for floating point
  3339. JUMPLE TT,NOEQL ;Inum and non lisp cell adresses must be EQ
  3340. CAILE TT,POSNU ;Bignum
  3341. CAIN TT,STRNG
  3342. JRST EQS
  3343. CAIN TT,VECT
  3344. JRST EQV
  3345. CDRA A,(A)
  3346. CDRA B,(B)
  3347. MOVE A,(A)
  3348. CAMN A,(B)
  3349. JRST TRUE
  3350. NOEQL: MOVE P,C
  3351. JRST FALSE
  3352. PAGE
  3353. EQS: CDRA D,(A)
  3354. CDRA TT,(B)
  3355. EQS2: JUMPE D,NOEQL
  3356. MOVS D,(D)
  3357. MOVS TT,(TT)
  3358. MOVE B,(TT)
  3359. CAME B,(D)
  3360. JRST NOEQL
  3361. HLRZS D
  3362. HLRZS TT
  3363. JUMPN TT,EQS2
  3364. JUMPN D,NOEQL
  3365. JRST TRUE
  3366. EQV: CDRA TT,(A)
  3367. CDRA D,(B)
  3368. MOVE B,-1(TT)
  3369. CAME B,-1(D)
  3370. JRST NOEQL ;different size
  3371. PSAVE B
  3372. HRLI TT,(POINT 18)
  3373. PSAVE TT
  3374. HRLI D,(POINT 18)
  3375. PSAVE D
  3376. EQV2: ILDB A,(P)
  3377. ILDB B,-1(P)
  3378. PCALL EQUAL1
  3379. SOSL -2(P)
  3380. JRST EQV2
  3381. P3DROP
  3382. JRST TRUE
  3383. PAGE
  3384. SUBAS==EXARG
  3385. SUBBS==EXARG+1
  3386. SUBST: MOVEM A,SUBAS# ;Recurse..find subportion in C =B, and
  3387. MOVEM B,SUBBS# ; re-CONS with A instead.
  3388. SUBS0: MOVE A,SUBAS
  3389. MOVE B,SUBBS
  3390. PSAVE C
  3391. MOVE A,C
  3392. PCALL EQUAL
  3393. PREST C
  3394. JUMPN A,SUBS3
  3395. CAILE C,INUMIN
  3396. JRST SUBS1
  3397. CARA T,(C)
  3398. CAILE T,ATMIN
  3399. JRST SUBS1
  3400. PSAVE C
  3401. CARA C,(C)
  3402. PCALL SUBS0
  3403. EXCH A,(P)
  3404. CDRA C,(A)
  3405. PCALL SUBS0
  3406. PREST B
  3407. JRST XCONS
  3408. SUBS1: SKIPA A,C
  3409. SUBS3: HRRZ A,SUBAS
  3410. PRET
  3411. PAGE
  3412. NCONC: JUMPE A,PROG2
  3413. MOVE TT,A
  3414. MOVE C,TT
  3415. CDRA TT,(C)
  3416. JUMPN TT,.-2
  3417. RPLCD B,(C)
  3418. PRET
  3419. APPEND: JUMPE A,PROG2
  3420. MOVEI C,AR4
  3421. MOVE TT,A
  3422. APP1: CARA A,(TT)
  3423. PSAVE B
  3424. PCALL CONS ;saves b
  3425. PREST B
  3426. RPLCD A,(C)
  3427. MOVE C,A
  3428. CDRA TT,(TT)
  3429. JUMPN TT,APP1
  3430. JRST RETAR4
  3431. PROGN: SKIPN B,A
  3432. PRET
  3433. PROGN1: PSAVE B
  3434. CARA A,(B)
  3435. PCALL EVAL
  3436. PREST B
  3437. COND2: SKIPL C,PA4
  3438. JRST RETC ;exit if a RETURN was found
  3439. CDRA B,(B)
  3440. SKIPL PA3 ;exit if a GO was found
  3441. JUMPN B,PROGN1
  3442. PRET
  3443. PAGE
  3444. MEMBER: MOVEM A,SUBAS
  3445. MEMB1: JUMPE B,FALSE
  3446. MOVE A,SUBAS
  3447. PSAVE B
  3448. CARA B,(B)
  3449. PCALL EQUAL
  3450. AJMN: JUMPN A,POPAJ
  3451. PREST B
  3452. CDRA B,(B)
  3453. JRST MEMB1
  3454. MEMQ: EXCH A,B
  3455. JUMPE A,CPOPJ
  3456. MOVS C,(A)
  3457. CAIN B,(C)
  3458. PRET
  3459. CARA A,C
  3460. JUMPN A,MEMQ+2
  3461. PRET
  3462. AND: JUMPE A,TRUE
  3463. SKIPA C,AJMN
  3464. OR: MOVSI C,(JUMPE A,)
  3465. JUMPE A,CPOPJ
  3466. HRRI C,ANDOR
  3467. PSAVE A
  3468. PSAVE C
  3469. JRST ANDORI
  3470. ANDOR: EXCH A,-1(P)
  3471. CDRA A,(A)
  3472. JUMPE A,POP1AJ
  3473. MOVEM A,-1(P)
  3474. ANDORI: CARA A,(A)
  3475. PCALL EVAL
  3476. XCT (P)
  3477. POP2J: P2DROP
  3478. PRET
  3479. POP1AJ: P1DROP
  3480. JRST POPAJ
  3481. PAGE
  3482. GENSYM: MOVE B,[POINT 7,GNUM,34]
  3483. MOVNI C,4
  3484. MOVEI TT,"0"
  3485. GENSY2: LDB T,B
  3486. AOS T
  3487. DPB T,B
  3488. CAIG T,"9"
  3489. JRST GENSY1
  3490. DPB TT,B
  3491. ADD B,[XWD 70000,0]
  3492. AOJN C,GENSY2
  3493. GENSY1: MOVE A,GNUM
  3494. PCALL FWCONS
  3495. PCALL NCONS
  3496. JRST PNGNK1
  3497. GNUM: ASCII /G0000/ ;*
  3498. IFE STL,<
  3499. CSYM: CARA A,(A)
  3500. PSAVE A
  3501. PCALL GT1PNM
  3502. MOVEM A,GNUM
  3503. JRST POPAJ >
  3504. GT1PNM: PCALL GETPNM
  3505. CARA A,(A)
  3506. MOVE A,(A)
  3507. PRET
  3508. PAGE
  3509. LIST:
  3510. FOO MOVEI B,CEVAL
  3511. JRST MAPCAR
  3512. ILIST: MOVEI T,0
  3513. JUMPE A,ILIST2
  3514. ILIST1: PSAVE A ;Evals list, leaving on P, & neg # in T.
  3515. CARA A,(A)
  3516. PSAVE TT
  3517. HRLM T,(P)
  3518. PCALL EVAL
  3519. ILIST3: PREST TT
  3520. HLRE T,TT
  3521. EXCH A,(P)
  3522. CDRA A,(A)
  3523. SOS T
  3524. JUMPN A,ILIST1
  3525. ILIST2: JRST (TT)
  3526. MAPCAN: TLO B,400000
  3527. MAPCON: TLOA B,100000
  3528. MAPCAR: TLO B,400000
  3529. MAPLIST:TLOA B,200000
  3530. MAPC: TLO B,400000
  3531. MAP: JUMPE A,FALSE
  3532. PSAVE A
  3533. HLLM B,(P)
  3534. HRLI B,(FCALL 1,)
  3535. PSAVE B
  3536. PSAVE A
  3537. HRLZM P,(P)
  3538. MAPL2: SKIPGE -2(P)
  3539. CARA A,(A) ;MAPC or MAPCAR.
  3540. XCT -1(P)
  3541. LDB C,[POINT 2,-2(P),2]
  3542. JUMPE C,MAP1
  3543. TRNN C,1
  3544. PCALL NCONS
  3545. JUMPE A,MAP1 ;Case of NIL returned in MAPCAN, MAPCON
  3546. HLR B,(P)
  3547. RPLCD A,(B)
  3548. TRNE C,1
  3549. PCALL LAST
  3550. HRLM A,(P)
  3551. MAP1: CDRA A,@-2(P)
  3552. HRRM A,-2(P)
  3553. JUMPN A,MAPL2
  3554. PREST AR4
  3555. P2DROP
  3556. JRST RETAR4
  3557. PAGE
  3558. PA3: 0 ;lh=0=>rh =next prog statement *
  3559. ;lh - =>rh = tag to go to
  3560. PA4: -1,,0 ;lh=-1,rh=pntr to prog less bound var list *
  3561. ;lh=+,rh return value
  3562. PROG: PSAVE PA3
  3563. PSAVE PA4
  3564. CARA T,(A)
  3565. CDRA A,(A)
  3566. HRROM A,PA4
  3567. MOVEM A,PA3
  3568. PUSH SP,[0] ;mark for unbind
  3569. JUMPE T,PG0
  3570. PG7A: CARA A,(T)
  3571. MOVEI AR4,NIL
  3572. PCALL BIND
  3573. CDRA T,(T)
  3574. JUMPN T,PG7A
  3575. PG0: SKIPA T,PA3
  3576. PG5A: MOVE T,A
  3577. PG1: JUMPE T,PG2
  3578. CARA A,(T)
  3579. CDRA T,(T)
  3580. CARA B,(A)
  3581. CAILE B,ATMIN
  3582. JRST PG1
  3583. MOVEM T,PA3
  3584. PCALL EVAL
  3585. SKIPL A,PA4
  3586. JRST PG4 ;return
  3587. SKIPL T,PA3
  3588. JRST PG1
  3589. PG5: JUMPE A,EG1
  3590. CARA TT,(A)
  3591. CDRA A,(A)
  3592. CAIN TT,(T)
  3593. JRST PG5A ;found tag
  3594. JRST PG5
  3595. PG2: TDZA A,A
  3596. PG4: HRRZS A
  3597. PCALL UNBIND
  3598. ERRP4: PREST PA4
  3599. PREST PA3
  3600. PRET
  3601. GO: CARA A,(A)
  3602. HRROM A,PA3
  3603. IFE STL,<CARA B,(A)
  3604. CAILE B,ATMIN>
  3605. JRST FALSE
  3606. IFE STL,<PCALL EVAL
  3607. JRST GO+1>
  3608. PAGE
  3609. RETURN: HRRZM A,PA4
  3610. PRET
  3611. SETQ: CARA B,(A)
  3612. PSAVE B
  3613. PCALL CADR
  3614. PCALL EVAL
  3615. MOVE B,A
  3616. PREST A
  3617. SET: MOVE AR4,B
  3618. PCALL BIND
  3619. SUB SP,[XWD 1,1]
  3620. RETAR4: CDRA A,AR4
  3621. PRET
  3622. CON2: CDRA A,(T)
  3623. COND: JUMPE A,CPOPJ ;entry
  3624. PSAVE A
  3625. CARA A,(A)
  3626. CARA A,(A)
  3627. PCALL EVAL
  3628. PREST T
  3629. JUMPE A,CON2
  3630. CARA B,(T)
  3631. JRST COND2
  3632. EG1: HRRZ A,T
  3633. ERRE1 ^D26,[SIXBIT /UNDEFINED PROG TAG-GO!/]
  3634. SUBTTL ARITHMETIC SUBROUTINES --- PAGE 12
  3635. IFE STL,<
  3636. ;macro expander -- (foo a b c) is expanded into (*foo (*foo a b) c)
  3637. EXPAND: MOVE C,B
  3638. CDRA A,(A)
  3639. PCALL REVERSE
  3640. JRST EXPA1
  3641. EXPN1: MOVE C,B
  3642. EXPA1: CDRA T,(A)
  3643. CARA A,(A)
  3644. JUMPE T,CPOPJ
  3645. PSAVE A
  3646. MOVE A,T
  3647. PCALL EXPA1
  3648. EXCH A,(P)
  3649. PCALL NCONS
  3650. PREST B
  3651. PCALL XCONS
  3652. HRL A,C
  3653. JRST DCONSA >
  3654. PAGE
  3655. ADD1: CAILE A,INUMIN
  3656. CAILE A,ATMIN-1
  3657. SKIPA B,[INUM0+1]
  3658. AOJA A,CPOPJ
  3659. .PLUS: JSP C,OP
  3660. ADD A,TT
  3661. FADR A,TT
  3662. JRST BPLUS
  3663. SUB1: CAILE A,INUMIN+1
  3664. CAILE A,ATMIN
  3665. SKIPA B,[INUM0+1]
  3666. SOJA A,CPOPJ
  3667. .DIF: JSP C,OP
  3668. SUB A,TT
  3669. FSBR A,TT
  3670. JRST BDIF
  3671. .TIMES: JSP C,OP
  3672. IMUL A,TT
  3673. FMPR A,TT
  3674. JRST BTIMES
  3675. .QUO: CAIN B,INUM0
  3676. JRST ZERODIV
  3677. JSP C,OP
  3678. IDIV A,TT
  3679. FDVR A,TT
  3680. JRST BQUO
  3681. .GREAT: EXCH A,B
  3682. JUMPE B,FALSE
  3683. .LESS: JUMPE A,CPOPJ
  3684. CAIN B,INUM0
  3685. JRST MINUSP
  3686. JSP C,OP
  3687. JRST COMP2
  3688. JRST COMP2
  3689. JRST BCMPR
  3690. COMP2: CAML A,TT
  3691. JRST FALSE
  3692. JRST TRUE
  3693. PAGE
  3694. MAKNUM: CAIN B,FIXNU
  3695. JRST FIX1A
  3696. FLO1A: MOVEI B,FLONU
  3697. JRST FQCONS
  3698. FIX1B: SUBI A,INUM0
  3699. MOVEI B,FIXNU
  3700. FQCONS: PCALL FWCONS
  3701. JRST XCONS
  3702. IF1,PURGE NUMVAL ;To avoid confusion with NUMVAL in STENEX
  3703. NUMVLX: JFCL 17,.+1
  3704. ONUMV: MOVEI B,FIXNU
  3705. CAILE A,INUMIN
  3706. JRST ONUMV1
  3707. CARA B,(A)
  3708. CAILE B,ATMIN
  3709. CAILE B,FLONU
  3710. NUMV2: ERRE1 ^D27,[SIXBIT /IS NOT A NUMBER!/]
  3711. CDRA A,(A)
  3712. CAIG B,POSNU
  3713. JRST (D) ;Normal return if bignum
  3714. SKIPA A,(A)
  3715. ONUMV1: SUBI A,INUM0
  3716. JRST 1(D) ;Return with skip if fixnum or flonum
  3717. NUMVAL: CAILE A,INUMIN
  3718. JRST FIXV1
  3719. CARA D,(A)
  3720. CAIE D,FIXNU
  3721. ERRE2 ^D46,[SIXBIT /IS NOT A WORD SIZE INTEGER/]
  3722. CDRA A,(A)
  3723. FIXV2: SKIPA A,(A)
  3724. FIXV1: SUBI A,INUM0
  3725. PRET
  3726. PAGE
  3727. FLOAT: PSAVE A
  3728. JSP D,ONUMV
  3729. JRST BFLOT
  3730. CAIN B,FLONU
  3731. JRST POPAJ
  3732. MOVEI D,FLO1A
  3733. MOVEM D,(P)
  3734. FLOAT1: IDIVI A,400000
  3735. SKIPE A
  3736. TLC A,254000
  3737. TLC B,233000
  3738. FADR A,B
  3739. PRET
  3740. FIX: PSAVE A
  3741. JSP D,ONUMV
  3742. JRST POPAJ ;BIGNUM
  3743. CAIE B,FLONU
  3744. JRST POPAJ
  3745. MOVEM A,(P)
  3746. MULI A,400
  3747. TSC A,A
  3748. JFCL 17,.+1
  3749. ASH B,-243(A)
  3750. FIX2: JFCL 10,BFIX
  3751. P1DROP
  3752. FIX1: MOVE A,B
  3753. JRST FIX1A
  3754. MINUSP: JSP D,ONUMV
  3755. JRST MINSP2 ;BIGNUM
  3756. JUMPGE A,FALSE
  3757. JRST TRUE
  3758. MINUS: JSP D,NUMVLX
  3759. JRST MINS2 ;BIGNUM
  3760. MOVNS A
  3761. ABS2IN: JFCL 10,FIXOV3
  3762. JRST MAKNUM
  3763. ABS: JSP D,NUMVLX
  3764. JRST ABS2
  3765. MOVMS A
  3766. JRST ABS2IN
  3767. PAGE
  3768. DIVIDE: CAIN B,INUM0
  3769. JRST ZERODIV
  3770. JSP C,OP
  3771. JRST RDIV
  3772. JRST ILLNUM
  3773. JRST BDIV
  3774. RDIV: JFCL 17,.+1
  3775. IDIV A,TT
  3776. JFCL 10,DIVMB ;FREAK CASE OF -2**35 IN A.
  3777. PSAVE B
  3778. PCALL FIX1A
  3779. EXCH A,(P)
  3780. PCALL FIX1A
  3781. PREST B
  3782. JRST XCONS
  3783. REMAINDER:
  3784. PCALL DIVIDE
  3785. JRST CDR
  3786. FIXOV: ERRL0 ^D135,[SIXBIT /INTEGER OVERFLOW!/]
  3787. ZERODIV:ERRL0 ^D136,[SIXBIT /ZERO DIVISOR!/]
  3788. FLOOV: ERRL0 ^D137,[SIXBIT /FLOATING OVERFLOW!/]
  3789. ILLNUM: ERRL0 ^D138,[SIXBIT /NON-INTEGRAL OPERAND!/]
  3790. GCD: JSP C,OP
  3791. JRST GCD2
  3792. JRST ILLNUM
  3793. JRST BGCD
  3794. GCD2: JFCL 17,.+1
  3795. MOVMS A
  3796. MOVMS TT
  3797. JFCL 10,DIVMB ;FREAK CASE OF -2**35 IN A OR TT.
  3798. ;euclid's algorithm
  3799. GCD3: CAMG A,TT
  3800. EXCH A,TT
  3801. JUMPE TT,FIX1A
  3802. IDIV A,TT
  3803. MOVE A,B
  3804. JRST GCD3
  3805. DIVMB: MOVEI B,FIXNU
  3806. PCALL BIGTSB
  3807. JRST @2(C)
  3808. PAGE
  3809. ;general arithmetic op code routine for mixed types
  3810. OP: CAIG A,INUMIN
  3811. JRST OPA1
  3812. SUBI A,INUM0
  3813. CAIG B,INUMIN
  3814. JRST OPA2
  3815. HRREI TT,-INUM0(B)
  3816. XCT (C) ;inum op (cannot cause overflow)
  3817. FIX1A: ADDI A,INUM0
  3818. CAILE A,INUMIN
  3819. CAILE A,ATMIN
  3820. JRST FIX1B
  3821. PRET
  3822. NONUM1: MOVE A,TT
  3823. OPA1: CARA T,(A)
  3824. CAILE T,ATMIN
  3825. CAILE T,FLONU
  3826. JRST NUMV2 ;A is not a number
  3827. CDRA A,(A)
  3828. CAIE T,FIXNU
  3829. JRST OPA6
  3830. SKIPA A,(A)
  3831. OPA2: ;first arg is a FIXNUM
  3832. MOVEI T,FIXNU
  3833. CAILE B,INUMIN
  3834. JRST OPB2
  3835. MOVE TT,B
  3836. CARA B,(B)
  3837. CAILE B,ATMIN
  3838. CAILE B,FLONU
  3839. JRST NONUM1 ;TT is not a number
  3840. CDRA TT,(TT)
  3841. CAIE B,FIXNU
  3842. JRST OPA5
  3843. SKIPA TT,(TT)
  3844. OPB2: HRREI TT,-INUM0(B)
  3845. MOVE AR4,A ;<MOVEI B,FIXNU> supplied by DIVMB.
  3846. JFCL 17,.+1
  3847. XCT (C) ;fixed pt op
  3848. OPOV: JFCL 10,FIXOVL
  3849. JRST FIX1A
  3850. OPA6: CAILE B,INUMIN ;first arg is not FIXNUM
  3851. JRST OPB7
  3852. CDRA TT,(B)
  3853. CARA B,(B)
  3854. CAIE B,FLONU
  3855. JRST OPB3 ;second arg is not a FLONUM
  3856. CAIN T,FLONU ;second arg is FLONUM; test first arg
  3857. SKIPA A,(A)
  3858. PCALL BFLT ;not a FLONUM, must be BIGNUM; float it
  3859. MOVE TT,(TT)
  3860. OPR: JFCL 17,.+1
  3861. XCT 1(C) ;flt pt op
  3862. JFCL 10,FLOOV
  3863. JRST FLO1A
  3864. PAGE
  3865. OPA5: ;first arg is FIXNUM but second arg is not
  3866. CAIE B,FLONU ;is second arg a FLONUM
  3867. JRST BIGOP ;no. it must be a bignum
  3868. PCALL FLOAT1
  3869. JRST OPR-1
  3870. OPB3: ;first arg is not fixnum, second arg is not flonum
  3871. CAIE B,FIXNU ;is second arg FIXNUM ?
  3872. JRST OPB9 ;no. it must be bignum
  3873. SKIPA TT,(TT)
  3874. OPB7: HRREI TT,-INUM0(B)
  3875. MOVEI B,FIXNU
  3876. CAIE T,FLONU
  3877. JRST BIGOP
  3878. MOVE A,(A)
  3879. EXCH A,TT
  3880. PCALL FLOAT1
  3881. OPB8: EXCH A,TT
  3882. JRST OPR
  3883. OPB9: ;second arg is bignum
  3884. CAIE T,FLONU ;is first arg a FLONUM ?
  3885. JRST BIGOP ;no
  3886. MOVE A,(A)
  3887. EXCH A,TT
  3888. EXCH B,T
  3889. PCALL BFLT
  3890. JRST OPB8
  3891. BIGOP: PCALL BIGTST
  3892. JRST @2(C)
  3893. SUBTTL BIGNUM ARITHMETIC ROUTINES --- PAGE 13
  3894. ;Power of ten
  3895. PWR10: MOVEM B,BASEX#
  3896. MOVE C,B
  3897. IMUL B,B ;BASE^2
  3898. IMUL B,B ;BASE^4
  3899. IMUL B,C ;BASE^5
  3900. IMUL B,B ;BASE^ten
  3901. MOVEM B,BASE10#
  3902. PRET
  3903. B0CONS: MOVEI A,0
  3904. BNCONS: MOVEI B,0
  3905. BCONS: PCALL FWCONS
  3906. JRST CONS
  3907. ;Bignum PRINT
  3908. BPRI: XCT "-",CTY
  3909. PCALL COPY
  3910. FOO MOVE B,VBASE
  3911. SUBI B,INUM0
  3912. PCALL PWR10
  3913. PCALL BPRJ
  3914. MOVE C,BASEX
  3915. JRST PRINI4
  3916. BPRJ: MOVE B,BASE10
  3917. PCALL Q1
  3918. JUMPE B,BPR2 ;zero quotient
  3919. PSAVE A ;remainder
  3920. MOVE A,B ;quotient
  3921. PCALL BPRJ
  3922. PREST A ;remainder
  3923. BPR1: MOVEI C,TEN ;print ten digits
  3924. SOJL C,CPOPJ
  3925. IDIV A,BASEX
  3926. HRLM B,(P)
  3927. PCALL BPR1+1
  3928. JRST FP7A1 ;particular TYO for digit
  3929. ;Ignore leading zero digits for first word
  3930. BPR2: JUMPE A,CPOPJ
  3931. IDIV A,BASEX
  3932. HRLM B,(P)
  3933. PCALL BPR2
  3934. JRST FP7A1 ;particular TYO for digit
  3935. PAGE
  3936. ;Divides bignum in A by integer in B
  3937. ;Destroys original bignum
  3938. ;Returns remainder in A, quotient in B
  3939. .Q1:
  3940. Q1: MOVEM B,Y#
  3941. PSAVE A
  3942. CDRA A,(A)
  3943. JUMPE A,Q1A
  3944. PCALL Q1+1
  3945. PREST C
  3946. RPLCD B,(C)
  3947. CARA T,(C)
  3948. MOVE B,(T)
  3949. DIV A,Y
  3950. Q1B: MOVEM A,(T) ;replace old digit
  3951. MOVE A,B
  3952. MOVE B,C
  3953. PRET
  3954. Q1A: PREST C
  3955. CARA T,(C)
  3956. MOVE A,(T)
  3957. IDIV A,Y
  3958. JUMPN A,Q1B ;non-zero quotient - keep it
  3959. HRRZM FF,(T) ;reclaim full word
  3960. MOVE FF,T
  3961. HRRZM F,(C) ;reclaim free word
  3962. HRRZ F,C
  3963. MOVEI C,0
  3964. JRST Q1B+1
  3965. PAGE
  3966. ;Bignum READ
  3967. RDBNM: PSAVE [NIL] ;initial value of bignum
  3968. MOVSI C,700
  3969. HRRI C,(SP) ;byte pointer to spec pdl
  3970. MOVEM T,TSAV#
  3971. MOVEM C,RDPTR#
  3972. HRRZ B,NUM1 ;base of number
  3973. PCALL PWR10
  3974. RDNM1: MOVEI C,TEN ;ten digits at a time
  3975. MOVEI A,0
  3976. ILDB B,RDPTR
  3977. JUMPE B,RDNM2 ;end of bignum
  3978. IMUL A,BASEX
  3979. ADDI A,-"0"(B)
  3980. SOJG C,.-4
  3981. MOVE B,BASE10
  3982. PCALL RDSUB
  3983. JRST RDNM1
  3984. RDNM2: CAIN C,TEN ;no digits in last superdigit
  3985. JRST RDNM3
  3986. HRREI C,-TEN(C) ;number of digits in last
  3987. MOVEI B,1
  3988. IMUL B,BASEX
  3989. AOJL C,.-1 ;compute basex^(number of digits)
  3990. PCALL RDSUB
  3991. RDNM3: LDB B,[POINT 1,TSAV,14] ;MINSGN
  3992. TRC B,POSNU ;sign of bignum
  3993. PREST A
  3994. P1DROP
  3995. JRST XCONS
  3996. RDSUB: MOVE C,-1(P)
  3997. PCALL BTIME1 ;bignum(C)*int(B)+int(A)
  3998. MOVEM A,-1(P)
  3999. PRET
  4000. PAGE
  4001. BTIME0: PSAVE B
  4002. PCALL COPY
  4003. MOVE C,A
  4004. PREST B
  4005. MOVEI A,0
  4006. ;big(C)*int(B)+int(A)
  4007. BTIME1: JUMPE C,BNCONS ;end of bignum
  4008. MOVEM B,MULR# ;multiplier
  4009. PSAVE C ;bignum
  4010. BT1B: MOVEM A,CARRY#
  4011. MOVS T,(C)
  4012. MOVE A,(T)
  4013. MUL A,MULR
  4014. ADD B,CARRY
  4015. TLZE B,SIGN
  4016. ADDI A,1
  4017. BT1E: MOVEM B,(T) ;store low order product+carry in bignum
  4018. HLRZS T ;(CDR bignum)
  4019. JUMPE T,BT1C ;end of bignum
  4020. MOVE C,T
  4021. JRST BT1B
  4022. BT1C: JUMPE A,POPAJ ;no high order part
  4023. PCALL BNCONS ;conses for remaining high order part
  4024. RPLCD A,(C) ;RPLACD end of bignum
  4025. JRST POPAJ
  4026. PAGE
  4027. ;Bignum copy
  4028. .COPY:
  4029. COPY: JUMPE A,CPOPJ
  4030. CARA B,(A)
  4031. PSAVE (B)
  4032. CDRA A,(A)
  4033. PCALL COPY
  4034. MOVE B,A
  4035. PREST A
  4036. JRST BCONS
  4037. ;Bignum reclaim
  4038. RECLAIM:CAILE A,INUMIN
  4039. PRET
  4040. EXCH A,F
  4041. EXCH A,(F)
  4042. HLRZ B,A ;type
  4043. HRRZS A
  4044. CAIE B,POSNU
  4045. CAIN B,NEGNU
  4046. JRST UNCONS
  4047. PRET
  4048. ;BIGNUM UNCONS
  4049. UNCONS: JUMPE A,CPOPJ
  4050. CARA B,(A)
  4051. MOVEM FF,(B)
  4052. MOVE FF,B
  4053. EXCH A,F
  4054. EXCH A,(F)
  4055. HRRZS A
  4056. JRST UNCONS
  4057. ;BIGNUM MINUSP
  4058. MINSP2: CAIN B,POSNU
  4059. JRST FALSE
  4060. JRST TRUE
  4061. ;BIGNUM MINUS
  4062. MINS2: TRCA B,1
  4063. ABS2: MOVEI B,POSNU ;BIGNUM ABS
  4064. JRST XCONS
  4065. ;compare two bignums A<B
  4066. BCMPR: PCALL BDIF
  4067. PSAVE A
  4068. PCALL MINUSP
  4069. EXCH A,(P)
  4070. PCALL RECLAIM
  4071. JRST POPAJ
  4072. PAGE
  4073. ;DIFFERENCE of two bignums
  4074. BDIF: TRC TT,1 ;complement sign of bignum in B
  4075. ;sum of two bignums
  4076. ;bignums in A and B; sign(A) in T, sign(B) in TT
  4077. BPLUS: PSAVE B
  4078. PCALL COPY
  4079. EXCH A,(P)
  4080. PCALL COPY
  4081. PREST C
  4082. MOVE B,A
  4083. MOVEI A,0
  4084. CAME T,TT
  4085. JRST BDIF1 ;signs different
  4086. PSAVE T ;sign of result
  4087. PCALL BADD
  4088. PREST B
  4089. JRST XCONS
  4090. BDIF1:
  4091. CAIN TT,POSNU
  4092. EXCH B,C
  4093. PCALL BSUB ;posnum in C, negnum in B
  4094. JUMPL B,BDIF3
  4095. PCALL SUPRSS
  4096. JRST MAKPOS
  4097. BDIF3: PCALL COMPLM
  4098. MOVEI B,NEGNU
  4099. JRST MAKBIG
  4100. BSUB: MOVNI TT,1
  4101. MOVSI T,(SUB TT,(B))
  4102. JRST BAS
  4103. BADD: MOVEI TT,1
  4104. MOVSI T,(ADD TT,(B))
  4105. PAGE
  4106. ;cry(A)(+ or -) big(B) + big(C) into A, sign into B.
  4107. ;destroys both bignums
  4108. BAS: HRRM TT,BCRY
  4109. PSAVE B
  4110. BP2A: HRRM B,BTMP
  4111. MOVS B,(B)
  4112. CARA TT,(C)
  4113. EXCH TT,FF
  4114. EXCH TT,(FF) ;reclaim full word
  4115. EXCH C,F
  4116. EXCH C,(F) ;reclaim free word
  4117. ADD TT,A
  4118. XCT T ;big(C) (+ or -) big (B)
  4119. MOVEI A,0
  4120. TLZE TT,SIGN ;turn off high bit
  4121. BCRY: HRREI A,. ;set carry if overflow or negative
  4122. BP2B: MOVEM TT,(B)
  4123. HLRZS B
  4124. HRRZS C
  4125. JUMPE B,BP2F ;end of B
  4126. JUMPN C,BP2A
  4127. JRST BP2D ;finish with carry (+ or -) big(B)
  4128. BP2F: JUMPE C,BP2H ;end of C also
  4129. EXCH B,C
  4130. RPLCD B,@BTMP ;RPLACD end of big(B) with rest of C
  4131. MOVSI T,(ADD TT,(B)) ;finish with big(C) + carry
  4132. BP2D: HRRM B,BTMP
  4133. MOVS B,(B)
  4134. MOVE TT,A
  4135. XCT T ;carry (+ or -) integer
  4136. JUMPL TT,BP2K
  4137. MOVEM TT,(B)
  4138. CAME T,[SUB TT,(B)]
  4139. JRST POSXIT ;can quit now
  4140. MOVEI A,0 ;turn off carry
  4141. JRST BP2L ;continue to negate
  4142. BP2K: HRRE A,BCRY
  4143. TLZ TT,SIGN ;make high bit zero
  4144. MOVEM TT,(B)
  4145. BP2L: HLRZS B
  4146. JUMPN B,BP2D
  4147. BP2H: JUMPLE A,XIT ;no carry
  4148. PCALL BNCONS
  4149. BTMP: HRRM A,. ;RPLACD end of bignum with carry
  4150. POSXIT: MOVEI B,0 ;sign positive
  4151. JRST POPAJ
  4152. XIT: MOVE B,A ;sign in B
  4153. JRST POPAJ
  4154. PAGE
  4155. ;suppress leading zeros from bignum
  4156. SUPRSS: SKIPA C,[JRST COMPL7]
  4157. ;complement bignum (2^35 complement)
  4158. COMPLM: MOVSI C,(SUBM T,(B))
  4159. JUMPE A,CPOPJ
  4160. PSAVE A
  4161. HRLZI T,SIGN
  4162. MOVEI TT,0
  4163. COMPL4: MOVS B,(A)
  4164. SKIPN (B)
  4165. JUMPE TT,COMPL3
  4166. XCT C
  4167. HRLOI T,SIGN-1
  4168. COMPL7: SKIPE (B)
  4169. MOVEM A,TT
  4170. COMPL3: HLRZ A,B
  4171. JUMPN A,COMPL4 ;continue
  4172. JUMPE TT,COMPL5 ;all zeros
  4173. CDRA A,(TT)
  4174. HLLZS (TT) ;RPLACD high order non-zero with NIL
  4175. COMPL6: PCALL UNCONS ;UNCONS leading zeros
  4176. JRST POPAJ
  4177. COMPL5: EXCH A,(P)
  4178. JRST COMPL6
  4179. ;sign(TT)*sign(T) into TT
  4180. MQSIGN: CAIE T,POSNU
  4181. TRC TT,1
  4182. PRET
  4183. PAGE
  4184. ;bignum multiply
  4185. ;big (A) * big (B) into A, signs in T,TT
  4186. BTIMES: PCALL MQSIGN
  4187. PSAVE TT ;save sign of result
  4188. PCALL BMUL
  4189. PREST B
  4190. JRST MAKBIG
  4191. ;0(P) is partial result
  4192. ;-1(P) is remaining reversed multiplier
  4193. ;-2(P) is multiplicand
  4194. BMUL: PSAVE B
  4195. PCALL REVERSE
  4196. PSAVE A
  4197. MOVEI A,0
  4198. PSAVE A
  4199. BTLOOP: SKIPN C,-1(P)
  4200. JRST BTEND ;end of multiplier
  4201. JUMPE A,BTLP2 ;first time
  4202. MOVE B,A
  4203. PCALL FWCONS-1
  4204. PCALL CONS ;increase length of product
  4205. BTLP2: MOVEM A,(P)
  4206. MOVE A,-2(P)
  4207. PCALL COPY
  4208. MOVS B,(C) ;next multiplier digit
  4209. MOVE C,A
  4210. HLRZM B,-1(P)
  4211. MOVE B,(B)
  4212. MOVEI A,0
  4213. PCALL BTIME1
  4214. MOVE C,(P)
  4215. JUMPE C,BTLOOP ;no add needed on first time
  4216. MOVE B,A
  4217. MOVEI A,0
  4218. PCALL BADD
  4219. JRST BTLOOP
  4220. BTEND: P3DROP
  4221. JRST SUPRSS
  4222. PAGE
  4223. ;extensions of interpreter routines and tests
  4224. REPEAT 0,<
  4225. ;ONUMVAL for bignums goes here
  4226. NUMVD2: HRRZ C,0(P) ;address of <PCALL ONUMVAL> +1
  4227. FOO CAIL C,FS ;LISP-system area of code?
  4228. PRET ; No, user or BPS gets a BIGNUM-pntr back.
  4229. P1DROP
  4230. CAIN C,ZEROP+1
  4231. JRST FALSE
  4232. CAIN C,MINUSP+1
  4233. JRST MINSP2
  4234. CAIN C,MINUS+1
  4235. JRST MINS2
  4236. CAIN C,ABS+1
  4237. JRST ABS2
  4238. CAIN C,FIX+2
  4239. JRST POPAJ
  4240. CAIN C,FLOAT+2
  4241. JRST BFLOT
  4242. IFN MOD,<CAIN C,CMOD+1
  4243. JRST CMOD1 >
  4244. PAGE
  4245. >
  4246. ;number overflow, use bignums
  4247. FIXOVL: MOVEI C,(C)
  4248. CAIN C,.TIMES+1
  4249. JRST REMUL ;TIMES overflowed. Recompute.
  4250. JUMPE A,FIXOV2 ;PLUS(mbeta mbeta) overflows 2 bits.
  4251. FIXOV3: TLC A,SIGN ;all other cases just overflowed 1 bit
  4252. MOVM B,A
  4253. MOVE TT,A
  4254. MOVEI A,1
  4255. FIXOVX: PCALL MKBG
  4256. JRST XCONS
  4257. FIXOV2: SETZ B,
  4258. SETO TT, ;(NEGATIVE).
  4259. MOVEI A,2 ;== -2*beta.
  4260. JRST FIXOVX
  4261. REMUL: MOVE A,AR4
  4262. MOVEI T,FIXNU
  4263. PCALL BIGTSB
  4264. JRST BTIMES ;use the bignum multiplication
  4265. MAKPOS: MOVEI B,POSNU
  4266. ;Make a LISP number from bignum -- A is list, B is sign
  4267. MAKBIG: JUMPE A,FIX1A ;NULL list produces zero
  4268. CDRA C,(A)
  4269. JUMPN C,XCONS ;a real bignum
  4270. CARA C,(A) ;only one word of precision
  4271. MOVE C,(C)
  4272. CAIE B,POSNU
  4273. MOVNS C ;negative
  4274. PCALL UNCONS
  4275. MOVE A,C
  4276. JRST FIX1A
  4277. PAGE
  4278. BIGTSB: MOVEI B,FIXNU
  4279. ;Transforms general numbers in (A,T),(TT,B)
  4280. ;into bignums in (A,T),(B,TT), values in A,B; signs in T,TT.
  4281. BIGTST: EXCH B,T ;funny ac usage in lisp
  4282. PSAVE T
  4283. PSAVE TT
  4284. PCALL BIGSUB ;convert number originally in A,T
  4285. EXCH B,-1(P)
  4286. EXCH A,(P)
  4287. PCALL BIGSUB ;convert number originally in TT,B
  4288. MOVE TT,B
  4289. MOVE B,A
  4290. PREST A
  4291. PREST T
  4292. PRET
  4293. BIGSUB: CAIE B,POSNU
  4294. CAIN B,NEGNU
  4295. PRET ;no conversion necessary
  4296. CAIE B,FIXNU
  4297. JRST NUMV2 ;already checked for flonum
  4298. MOVEI B,0
  4299. MOVE TT,A ;get value of number
  4300. MOVM A,TT
  4301. JUMPGE A,BIGSRT
  4302. MOVEI A,1 ;bastard case of -2^35
  4303. MKBG: PCALL MKBIG
  4304. JRST BIGSND
  4305. BIGSRT: PCALL BCONS
  4306. BIGSND: SKIPGE TT
  4307. SKIPA B,[NEGNU]
  4308. MOVEI B,POSNU
  4309. PRET
  4310. MKBIG: PSAVE B
  4311. PCALL BNCONS
  4312. MOVE B,A
  4313. PREST A
  4314. JRST BCONS
  4315. PAGE
  4316. BFLOT: MOVEI T,FLO1A
  4317. MOVEM T,(P)
  4318. MOVE T,B
  4319. ;Make a floating pt number out of a bignum
  4320. BFLT: PSAVE C
  4321. PSAVE T
  4322. CAIE T,POSNU
  4323. CAIN T,NEGNU
  4324. SKIPA T,[-200]
  4325. JRST NUMV2
  4326. BFLT2: MOVE C,B
  4327. CARA B,(A)
  4328. CDRA A,(A)
  4329. ADDI T,43
  4330. JUMPN A,BFLT2 ;find last two words of bignum
  4331. MOVE B,(B)
  4332. MOVE C,(C)
  4333. BFLT3: TLNE B,SIGN/2
  4334. JRST BFLT4
  4335. ASHC B,1
  4336. SOJA T,BFLT3 ;normalize B,C
  4337. BFLT4: JUMPGE T,FLOOV
  4338. ASH B,-10
  4339. DPB T,[POINT 8,B,8]
  4340. MOVE A,B
  4341. PREST T
  4342. PREST C
  4343. CAIE T,POSNU
  4344. MOVNS A
  4345. PRET
  4346. ;Make a bignum from a flt pt number
  4347. BFIX: MOVM A,(P)
  4348. MULI A,400
  4349. MOVEI C,-243(A) ;#left shifts needed
  4350. IDIVI C,43 ;C_#extra words-1, D_#shifts
  4351. MOVEI A,0
  4352. ASHC A,(C+1)
  4353. PSAVE B
  4354. PCALL BNCONS
  4355. MOVE B,A
  4356. PREST A
  4357. PCALL BCONS
  4358. SOJL C,BFIX2
  4359. MOVE B,A
  4360. MOVEI A,0
  4361. PCALL BCONS
  4362. SOJGE C,.-3
  4363. BFIX2: PREST TT
  4364. PCALL BIGSND
  4365. JRST XCONS
  4366. PAGE
  4367. ;Bignum divide
  4368. BDIV: PCALL MQSIGN ;complement sign of TT if T is negnum
  4369. PSAVE T ;sign of remainder
  4370. PSAVE TT ;sign of quotient
  4371. PCALL DIVSUB
  4372. BDIV2: EXCH B,(P)
  4373. PCALL MAKBIG ;quotient
  4374. MOVE B,-1(P)
  4375. MOVEM A,-1(P)
  4376. PREST A
  4377. PCALL MAKBIG ;remainder
  4378. PREST B
  4379. JRST XCONS
  4380. BQUO: PCALL MQSIGN
  4381. PSAVE TT
  4382. PCALL DIVSUB
  4383. PSAVE A
  4384. MOVE A,B
  4385. PCALL UNCONS
  4386. PREST A
  4387. PREST B
  4388. JRST MAKBIG
  4389. DIVSUB: CDRA C,(B)
  4390. JUMPN C,DIV1
  4391. ;NULL(CDR B) means single length divisor
  4392. BQUO1: PSAVE B
  4393. PCALL COPY
  4394. PREST B
  4395. CARA B,(B)
  4396. MOVE B,(B)
  4397. PCALL Q1
  4398. PSAVE B ;quotient
  4399. PCALL BNCONS
  4400. MOVE B,A
  4401. JRST POPAJ
  4402. PAGE
  4403. ;DIV1 does long division of X/Y
  4404. ;enter with x in A, Y in B.
  4405. DIV1: PSAVE A ;X
  4406. PSAVE B ;Y
  4407. MOVE A,B
  4408. PCALL HIDIG
  4409. HRLOI A,SIGN/2-1
  4410. IDIV A,(C) ;(beta/2-1)/Y[N-1]+1
  4411. ADDI A,1
  4412. MOVEM A,SCALE#
  4413. MOVE B,A
  4414. MOVE A,(P) ;Y - divisor
  4415. PCALL BTIME0 ;SCALE*Y
  4416. MOVEM A,V ;scaled divisor
  4417. MOVEM A,(P) ;protect V from GC
  4418. PCALL HIDIG
  4419. POP C,VH ;V[N-1]
  4420. POP C,VH1 ;V[N-2]
  4421. MOVE A,-1(P) ;X - numerator
  4422. PCALL COPY
  4423. PCALL EXTND
  4424. MOVE B,SCALE
  4425. MOVE C,A
  4426. PCALL BTIME1-1 ;SCALE*X -- scaled numerator
  4427. MOVEM A,-1(P) ;U
  4428. PSAVE [NIL]
  4429. HRRZM P,QUO# ;pointer to quotient list
  4430. PCALL LENGTH
  4431. PSAVE A
  4432. MOVE A,V#
  4433. PCALL LENGTH
  4434. PREST B
  4435. SUB B,A ;LENGTH(U)-LENGTH(V)
  4436. MOVE A,-2(P) ;U
  4437. JUMPLE B,DIV1X ;special case of U<V
  4438. PCALL DIV2 ;carry out division with parameters
  4439. DIV1X: PCALL SUPRSS ;suppress leading zeros of remainder
  4440. JUMPE A,DIV1Y ;zero remainder
  4441. MOVE B,SCALE
  4442. PCALL Q1 ;U/SCALE - final remainder in B
  4443. MOVE A,B
  4444. DIV1Y: EXCH A,(P)
  4445. PCALL SUPRSS ;suppress leading zeros in quotient
  4446. PREST B
  4447. JRST POP2J
  4448. PAGE
  4449. ;Recursive function to position V properly with respect to U.
  4450. ; on successive calls to DIV3 which calculates quotient digits.
  4451. ;Enter DIV2 with U in A, N in B. N= LENGTH(U)-LENGTH(V)-1.
  4452. DIV2: SOJLE B,DIV3
  4453. PSAVE A ;U
  4454. CDRA A,(A)
  4455. PCALL DIV2
  4456. RPLCD A,@(P) ;(RPLACD U,(DIV3(CDR U)))
  4457. PREST A
  4458. JRST DIV3
  4459. ;Enter with U[J] in A
  4460. DIV3: PSAVE A ;UJ
  4461. PCALL HIDIG
  4462. POP C,A ;UH
  4463. CAML A,VH#
  4464. JRST DIVCS1 ;strange case when UH>=VH
  4465. POP C,B ;UH1
  4466. DIV A,VH ;(UH*beta+UH1)/VH
  4467. PSAVE A ;quotient digit
  4468. L1: MOVEM B,REM# ;remainder
  4469. MUL A,VH1#
  4470. SUB A,REM ;(VH1*QUO)-beta*REM
  4471. CAMGE B,(C) ;UH2
  4472. SUBI A,1
  4473. JUMPG A,DIVCS2 ;quotient too big
  4474. L4: MOVE A,V
  4475. MOVE B,(P) ;quotient digit
  4476. PCALL BTIME0 ;Q*V
  4477. MOVE C,-1(P) ;UJ
  4478. MOVE B,A
  4479. MOVEI A,0
  4480. PCALL BSUB ;UJ-Q*V
  4481. JUMPL B,DIVCS3 ;quotient too big
  4482. L3: MOVEM A,-1(P) ;new UJ
  4483. PREST A ;quotient digit
  4484. MOVE B,@QUO
  4485. PCALL BCONS
  4486. MOVEM A,@QUO ;new quotient list
  4487. MOVE A,(P)
  4488. PCALL DIVSRT ;shorten UJ by one digit
  4489. JRST POPAJ
  4490. PAGE
  4491. ;Special case of UH>=VH
  4492. DIVCS1: HRLOI A,SIGN-1 ;BETA-1
  4493. PSAVE A
  4494. POP C,B ;UH1
  4495. JRST DIVC2A ;R_UH1+VH
  4496. ;Special case correction for quotient
  4497. DIVCS2: SOS A,(P) ;quotient_quotient-1
  4498. MOVE B,REM
  4499. DIVC2A: ADD B,VH ;R_R+VH
  4500. JUMPL B,L4 ;overflow ... R >= beta.
  4501. JRST L1
  4502. ;Special case of quotient too large
  4503. DIVCS3: SOS (P) ;quotient_quotient-1
  4504. PSAVE A
  4505. MOVE A,V
  4506. PCALL COPY
  4507. MOVE C,A
  4508. PREST B
  4509. MOVEI A,0
  4510. PCALL BADD ;U_U+V
  4511. MOVEM A,-1(P)
  4512. PCALL DIVSRT ;shorten overflowed digit
  4513. JRST L3+1
  4514. PAGE
  4515. ;Pushes successive digits of list in A onto pdl
  4516. ;Returns C pointing to pdl location of last digit
  4517. HIDIG: MOVE C,P
  4518. MOVS B,(A)
  4519. PSAVE (B)
  4520. HLRZ A,B
  4521. JUMPN A,HIDIG+1
  4522. EXCH C,P
  4523. PRET
  4524. ;Shorten list by one
  4525. DIVSRT: MOVE C,A
  4526. CDRA A,(A)
  4527. CDRA B,(A) ;CDDR
  4528. JUMPN B,.-3
  4529. HLLZS (C) ;NULL (CDDR C) => RPLACD(C NIL)
  4530. CARA B,(A)
  4531. JRST UNCONS
  4532. ;Lengthen list by one
  4533. EXTND: PSAVE A
  4534. PCALL LAST
  4535. MOVE T,A
  4536. PCALL B0CONS
  4537. RPLCD A,(T)
  4538. JRST POPAJ
  4539. PAGE
  4540. TA==4
  4541. TB==5
  4542. TC==6
  4543. TD==7
  4544. UP==10
  4545. VP==11
  4546. Q==12
  4547. ;Bignum GCD
  4548. BGCD: PSAVE B
  4549. PCALL COPY
  4550. EXCH A,(P) ;V
  4551. PCALL COPY
  4552. PSAVE A ;U
  4553. PCALL COPY
  4554. MOVE C,A
  4555. MOVE A,-1(P)
  4556. PCALL COPY
  4557. MOVE B,A ;U
  4558. MOVEI A,0
  4559. PCALL BSUB ;V-U
  4560. PSAVE B
  4561. PCALL BSUBND
  4562. JUMPE A,GCDSC1 ;U=V
  4563. PCALL UNCONS
  4564. PREST B
  4565. JUMPGE B,BGCD2 ;U>=V
  4566. MOVE A,(P)
  4567. EXCH A,-1(P)
  4568. MOVEM A,(P)
  4569. PAGE
  4570. ;Now V<U V in -1(P), U in (P)
  4571. BGCD2: MOVE A,-1(P)
  4572. JUMPE A,GCDEND ;V is zero
  4573. CDRA B,(A)
  4574. JUMPE B,GCDSING ;V is single precision
  4575. PCALL LENGTH ;LENGTH (V)
  4576. MOVE T,A
  4577. MOVE A,(P) ;U
  4578. PCALL LENGTH
  4579. SUB A,T ;L(U)-L(V)
  4580. JUMPE A,GCD4
  4581. SOJN A,GCD7A ;>1
  4582. MOVE A,-1(P) ;V
  4583. PCALL EXTND ;lengthen V by one high order zero
  4584. GCD4: MOVE A,(P) ;U
  4585. PCALL HIDIG
  4586. HRLOI A,SIGN/2-1 ;BETA/2-1
  4587. IDIV A,(C) ;(BETA/2-1)/U[N-1]+1
  4588. ADDI A,1
  4589. MOVEM A,SCALE
  4590. PCALL GCSB
  4591. MOVE UP,A ;SCALE*UH
  4592. MOVE A,-1(P) ;V
  4593. PCALL HIDIG
  4594. PCALL GCSB
  4595. MOVE VP,A ;SCALE*VH
  4596. MOVEI TA,1
  4597. MOVEI TD,1
  4598. SETZB TC,TB
  4599. PAGE
  4600. GCD5: MOVE A,UP
  4601. ADD A,TA
  4602. MOVE B,VP
  4603. ADD B,TC
  4604. JUMPE B,GCD7
  4605. JUMPL A,GCD5X ;overflow case
  4606. IDIV A,B ;(U'+A)/(V'+C)
  4607. GCD5A: MOVE Q,A
  4608. MOVE A,UP
  4609. ADD A,TB
  4610. MOVE B,VP
  4611. ADD B,TD
  4612. JUMPE B,GCD7
  4613. SKIPG B
  4614. TDZA A,A ;special case of V'+D = BETA
  4615. IDIV A,B ;(U'+B)/(V'+D)
  4616. CAME A,Q
  4617. JRST GCD7
  4618. MOVE A,TC
  4619. EXCH TA,TC ;A'_C
  4620. IMUL A,Q
  4621. SUB TC,A ;C'_A-Q*C
  4622. MOVE A,TD
  4623. EXCH TB,TD ;B'_D
  4624. IMUL A,Q
  4625. SUB TD,A ;D'_B-Q*D
  4626. MOVE A,VP
  4627. EXCH UP,VP ;UP'_VP
  4628. IMUL A,Q
  4629. SUB VP,A ;VP'_UP-Q*VP
  4630. JRST GCD5
  4631. PAGE
  4632. ;Special case when U'+A=BETA
  4633. GCD5X: MOVEI A,1
  4634. MOVE C,B
  4635. MOVEI B,0
  4636. DIV A,C
  4637. JRST GCD5A
  4638. GCD7: JUMPE TB,GCD7A
  4639. MOVE A,(P) ;U
  4640. MOVE B,-1(P) ;V
  4641. PSAVE TC
  4642. PSAVE TD
  4643. PCALL GCDSB ;A*U+B*V
  4644. PREST TB
  4645. PREST TA
  4646. EXCH A,(P) ;U
  4647. MOVE B,-1(P)
  4648. PCALL GCDSB ;C*U+D*V
  4649. MOVEM A,-1(P) ;V
  4650. JRST BGCD2
  4651. GCDSB: PSAVE TA
  4652. PSAVE TB
  4653. PSAVE B
  4654. MOVM B,TA
  4655. PCALL BTIME0
  4656. EXCH A,(P) ;B
  4657. MOVM B,-1(P) ;TB
  4658. PCALL BTIME0
  4659. PREST B ;A*TA
  4660. PREST TA
  4661. PREST TB
  4662. XOR TA,TB
  4663. MOVE C,A
  4664. MOVEI A,0
  4665. JUMPGE TA,BADD ;signs same
  4666. PCALL BSUB ;signs different
  4667. BSUBND: JUMPGE B,SUPRSS
  4668. JRST COMPLM
  4669. GCD7A: MOVE A,-1(P)
  4670. PCALL SUPRSS
  4671. MOVE B,A
  4672. MOVE A,(P)
  4673. PCALL DIV1 ;U/V
  4674. EXCH B,-1(P) ;V_REMAINDER
  4675. MOVEM B,(P) ;U_V
  4676. PCALL UNCONS ;dont need quotient
  4677. JRST BGCD2
  4678. PAGE
  4679. GCDSING:
  4680. PREST A ;U
  4681. MOVE B,(P) ;V - single precision
  4682. CARA B,(B)
  4683. MOVE B,(B)
  4684. MOVEM B,(P)
  4685. PCALL Q1 ;U MOD V into A
  4686. PREST B ;A < B
  4687. JUMPE A,GCDS2
  4688. ;Single precision GCD
  4689. IDIV B,A
  4690. MOVE B,A
  4691. MOVE A,C
  4692. JUMPN A,.-3
  4693. GCDS2: MOVE A,B
  4694. JRST FIX1A
  4695. GCSB: MOVE A,-1(C)
  4696. MUL A,SCALE
  4697. MOVE B,A
  4698. MOVE A,(C)
  4699. IMUL A,SCALE
  4700. ADD A,B
  4701. PRET
  4702. GCDSC1: P2DROP
  4703. PREST A
  4704. JRST MAKPOS
  4705. GCDEND: PREST A ;U is result
  4706. P1DROP
  4707. JRST MAKPOS
  4708. SUBTTL GENERALIZED GFPAK, FOR BIGNUMS --- PAGE 14
  4709. IFN MOD,< ;THE REST OF THIS PAGE IS UNDER THIS SWITCH
  4710. ;TITLE GFPAK4 -- GALOIS FIELD PACKAGE
  4711. ; THE MODULUS CANNOT BE A BIGNUM, WITH THIS VERSION OF GFPAK;
  4712. ; THE ARG TO CMOD CAN BE, THOUGH.
  4713. ; Every other arg is assumed to be FIXNUM or INUM !!!
  4714. ; THE MODULUS SHOULD ALWAYS BE SET OR RESET BY THE FUNCTION SETMOD;
  4715. ; IT SHOULD NOT BE SET BY A SETQ IN LISP/REDUCE.
  4716. ; THE MODULUS CAN BE INTERROGATED FOR ITS CURRENT VALUE BY:
  4717. ; 1) THE VALUE RETURNED FROM THE FUNCTION (SETMOD 0),
  4718. ; WHICH DOESN'T ALTER THE CURRENT VALUE; OR BY
  4719. ; 2) THE VALUE OF THE EXTERNAL VARIABLE MOD*.
  4720. ; (SETMOD NIL) IS LEGITIMATE, AND IS == (SETQ MOD* NIL).
  4721. GFP: 0 ;STRICTLY LOCAL: THE SINGLE-PRECISION MODULUS.
  4722. ;VBIGP IS THE VALUE-CELL OF THE VARIABLE MOD*,
  4723. ; AND PERMITS EXTERNAL-INTERROGATION.
  4724. ;VBIGP IS ALSO USED IN CMOD, AS A FIXNUM,
  4725. ; (TO AVOID RE-FIX1A-ING GFP EACH TIME).
  4726. ; IT IS THUS PROTECTED DURING A GC.
  4727. PAGE
  4728. ;(SETMOD A) SETS P, THE NUMBER OF ELEMENTS OF THE FIELD, TO A IF A.NE.0
  4729. ; AND RETURNS P AS A RESULT IN ANY CASE.
  4730. ; DOES NOT CHECK TO SEE IF P IS PRIME, WHICH IT SHOULD BE.
  4731. INTERNAL SETMOD
  4732. SETMOD: MOVE C,A ;Preserve pntr around NUMVAL.
  4733. JUMPE A,SETM2 ;If NIL, just reset cells.
  4734. PCALL NUMVAL
  4735. JUMPE A,SETM3 ;If "0", interrogate old value.
  4736. SETM2: MOVMM A,GFP ;Internal cell (for local use).
  4737. FOO MOVEM C,VBIGP ;External pntr (for users and CMOD).
  4738. SETM3:
  4739. FOO MOVE A,VBIGP ;Return current value.
  4740. PRET
  4741. ;(CMOD A) NORMALIZES A MOD P, REGARDLESS +/- SIZE
  4742. INTERNAL CMOD
  4743. CMOD: JSP D,ONUMV
  4744. JRST CMOD1
  4745. CAIN B,FLONU
  4746. JRST ILLNUM ;FLOATING POINT NUMBERS ARE ILLEGAL
  4747. IDIV A,GFP
  4748. SKIPGE A,B ;IF A WAS NEG, REMAINDER IS NEG
  4749. ADD A,GFP
  4750. JRST FIX1A ;CONVERT & EXIT
  4751. CMOD1: PSAVE B
  4752. PCALL COPY
  4753. MOVE B,GFP
  4754. PCALL Q1
  4755. PREST B
  4756. CAIE B,POSNU
  4757. MOVNS A
  4758. JRST CDIF1
  4759. PAGE
  4760. ;(CPLUS A B) RETURNS THE SUM OF A AND B IN THE CURRENT GALOIS FIELD
  4761. ; ASSUMES A & B ALREADY NORMALIZED.
  4762. INTERNAL CPLUS
  4763. CPLUS: MOVEM B,TMP ;SAVE B
  4764. PCALL NUMVAL ;CONVERT A
  4765. EXCH A,TMP ;SAVE A
  4766. PCALL NUMVAL ;CONVERT B
  4767. ADD A,TMP ;ADD
  4768. CAML A,GFP ;SKIP IF LESS, ELSE
  4769. SUB A,GFP ; NORMALIZE
  4770. JRST FIX1A ;CONVERT AND EXIT
  4771. TMP: 0
  4772. ;CDIF(A,B) RETURNS A-B MOD P, A,B ARE ELEMENTS OF GF(P)
  4773. INTERNAL CDIF
  4774. CDIF: MOVEM B,TMP ;SAVE B
  4775. PCALL NUMVAL ;CONVERT A
  4776. EXCH A,TMP ;SAVE A
  4777. PCALL NUMVAL ;CONVERT B
  4778. EXCH A,TMP
  4779. SUB A,TMP ;SUBTRACT
  4780. CDIF1: SKIPGE A ; SKIP IF GREATEQ 0,ELSE
  4781. ADD A,GFP ; NORMALIZE
  4782. JRST FIX1A ;CONVERT AND EXIT
  4783. ;(CTIMES A B) RETURNS THE PRODUCT OF A AND B IN THE CURRENT GALOIS FIELD
  4784. ; ASSUMES A & B NON-NEG ... NORMALIZED.
  4785. INTERNAL CTIMES
  4786. CTIMES: MOVEM B,TMP ;SAVE B
  4787. PCALL NUMVAL ;CONVERT A
  4788. EXCH A,TMP ;SAVE A
  4789. PCALL NUMVAL ;CONVERT B
  4790. MUL A,TMP ;MULTIPLY
  4791. DIV A,GFP ;DIVIDE BY P TO GET IN RANGE
  4792. MOVE A,B ;MOVE REMAINDER
  4793. JRST FIX1A ;WHICH WE CONVERT AND EXIT
  4794. PAGE
  4795. ;(CRECIP A) RETURNS THE INVERSE OF A IN THE CURRENT GALOIS FIELD.
  4796. ; COMPUTATION USES EXTENDED EUCLIDEAN ALGORITHM, WHEREBY
  4797. ; (GCD P A) IS COMPUTED, AND NUMBERS X AND Y ARE FOUND SUCH THAT
  4798. ; P*X + A*Y = (GCD P A) = 1 BECAUSE P IS PRIME (WE HOPE).
  4799. ; SINCE P*X  O (MOD P) WE DO NOT IN FACT COMPUTE X.
  4800. ; Y IS OF COURSE THE MULTIPLICATIVE INVERSE OF A.
  4801. ;ALGORITHM:
  4802. ; A(I)=A(I+1)*Q(I)+A(I+2)
  4803. ; Y(I+2)=Y(I)-Q(I)*Y(I+1)
  4804. ; A(1)=P, A(2)=A, Y(1)=0, Y(2)=1
  4805. ; A(N+2)=0, Y(N+1)=Y
  4806. ;STORAGE ALLOCATION:
  4807. ; A: A(I+1)
  4808. ; B: A(I)
  4809. ; C: A(I+2) (BECAUSE OF THE WAY IDIV WORKS)
  4810. ; AR4: Y(I)
  4811. ; AR5: Y(I+1)
  4812. INTERNAL CRECIP
  4813. CRECIP: PCALL NUMVAL ;GET VALUE OF ARGUMENT IN A(2)
  4814. SETZM AR4 ;Y(1)=0
  4815. MOVEI AR5,1 ;Y(2)=1
  4816. MOVE B,GFP ;A(1)=P
  4817. LOOP: IDIV B,A ;C=A(I+2), B=Q(I)
  4818. JUMPE C,EXIT ;IF A(I+2)=0, WE ARE THROUGH
  4819. IMUL B,AR5 ;Q(I)*Y(I+1)
  4820. EXCH AR4,AR5
  4821. SUB AR5,B ;Y(I+2)
  4822. MOVE B,A
  4823. MOVE A,C
  4824. JRST LOOP ;NEXT ITERATION
  4825. EXIT: SKIPGE A,AR5 ;A_Y(N+1). IF NEGATIVE
  4826. ADD A,GFP ;ADD P TO GET 0.LT.Y.LT.P
  4827. JRST FIX1A ;CONVERT TO LISP NUMBER AND EXIT
  4828. > ;END OF IFN MOD
  4829. SUBTTL EXPLODE, COMPRESS AND FRIENDS --- PAGE 15
  4830. IFE STL,<
  4831. FLATSIZE:HLLZS FLAT1
  4832. MOVEI R,FLAT2
  4833. PCALL PRINTA
  4834. FLAT1: MOVEI A,X ;*
  4835. JRST FIX1A
  4836. FLAT2: AOS FLAT1
  4837. PRET >
  4838. %EXPLODE:SKIPA R,.+1 ;LIKE PRIN2 & PRIN1,
  4839. EXPLODE: HRRZI R,EXPL1 ; <HRRZI>=551, negative R trick.
  4840. SKIPN OLSCNV ;READ scanner?
  4841. JRST EXPLO1 ;Yes!
  4842. PSAVE A
  4843. MOVEI A,NIL
  4844. PCALL SCANSET
  4845. EXCH A,(P)
  4846. PCALL EXPLO1
  4847. EXCH A,(P)
  4848. PCALL SCANSET
  4849. JRST POPAJ
  4850. EXPLO1: MOVSI AR4,AR4
  4851. PCALL PRINTA
  4852. JRST RETAR4
  4853. EXPL1: PSAVE B
  4854. PSAVE C
  4855. ANDI A,177
  4856. PCALL RECH1
  4857. PCALL NCONS
  4858. HLR B,AR4
  4859. RPLCD A,(B)
  4860. RPLCA A,AR4
  4861. PREST C
  4862. JRST POPBJ
  4863. PAGE
  4864. IFE STL,<
  4865. READLIST:TDZA T,T
  4866. COMPRESS:MOVNI T,1
  4867. MOVEM T,NOINFG >
  4868. IFN STL,<
  4869. COMPRESS:SETOM NOINFG >
  4870. PSAVE OLDCH
  4871. SETZM OLDCH
  4872. JUMPE A,[ERRL0 ^D141,[SIXBIT /NO LIST-COMPRESS!/]]
  4873. HRRM A,MKNAM3
  4874. MOVEI A,MKNAM2
  4875. PCALL READ0
  4876. CDRA T,MKNAM3
  4877. CAIE T,-1
  4878. JUMPN T,[ERRL0 ^D142,[SIXBIT /MORE THAN ONE S-EXPRESSION-COMPRESS!/]]
  4879. PREST OLDCH
  4880. PRET
  4881. MKNAM2: PSAVE B
  4882. PSAVE TT
  4883. MKNAM3: MOVEI TT,X
  4884. JUMPE TT,MKNAM6
  4885. CAIN TT,-1
  4886. ERRL0 ^D143,[SIXBIT /READ UNHAPPY-COMPRESS!/]
  4887. CDRA B,(TT)
  4888. HRRM B,MKNAM3
  4889. CARA A,(TT)
  4890. PCALL GTFCH
  4891. MKNAM4: PREST TT
  4892. JRST POPBJ
  4893. MKNAM6: MOVEI A," "
  4894. HLLOS MKNAM3
  4895. JRST MKNAM4
  4896. GTFCH: CAILE A,INUMIN
  4897. JRST GTFINV
  4898. GTFCH2: PCALL GETPNM
  4899. CARA A,(A)
  4900. LDB A,[POINT 7,(A),6]
  4901. PRET
  4902. GTFINV: SUBI A,INUM0-"0"
  4903. CAIG A,"9"
  4904. CAIGE A,"0"
  4905. ERRL1 ^D144,[SIXBIT /NUMBER NOT DIGIT!/]
  4906. PRET
  4907. SUBTTL EVAL APPLY -- THE INTERPRETER --- PAGE 16
  4908. EV3: CARA A,(AR4)
  4909. FOO MOVEI B,VALUE
  4910. PCALL GET+1 ;don't need to check for id
  4911. JUMPE A,UNDFUN ;function object has no definition
  4912. CDRA A,(A)
  4913. CARA B,(AR4)
  4914. CAIE A,(B) ;Error if same id
  4915. UBDPTR:
  4916. FOO CAIN A,UNBOUND
  4917. JRST UNDFUN
  4918. CDRA B,(AR4) ;eval (cons a (cdr AR4))
  4919. PCALL CONS
  4920. EVAL: HRRZM A,AR4
  4921. CAILE A,INUMIN
  4922. JRST CPOPJ
  4923. CARA T,(A)
  4924. CAILE T,ATMIN
  4925. JRST EE1 ;x is atomic
  4926. CAILE T,INUMIN
  4927. JRST UNDFUN
  4928. CARA TT,(T)
  4929. CAIN TT,ID
  4930. JRST EE2 ;car (x) is an id
  4931. CAIL TT,CODMIN
  4932. JRST EVCOD
  4933. CAIG TT,ATMIN
  4934. JRST EXP3
  4935. IFE APPL,<
  4936. UNDFUN: CARA A,(AR4)
  4937. ERRE1 ^D28,[SIXBIT /UNDEFINED FUNCTION - EVAL!/] >
  4938. IFN APPL,<
  4939. JRST RETAR4
  4940. UNDFUN==RETAR4 >
  4941. EE1: CAIE T,ID
  4942. PRET ;constant
  4943. FOO MOVEI B,VALUE
  4944. PCALL IGET
  4945. EXCH A,AR4
  4946. JUMPE AR4,UNBVAR
  4947. CDRA AR4,(AR4)
  4948. IFE APPL,<
  4949. FOO CAIN AR4,UNBOUND
  4950. UNBVAR: ERRE1 ^D29,[SIXBIT /UNBOUND VARIABLE - EVAL!/] >
  4951. IFN APPL,<
  4952. FOO CAIE AR4,UNBOUND
  4953. UNBVAR==CPOPJ >
  4954. MOVEM AR4,A
  4955. PRET
  4956. PAGE
  4957. IFN FNRG,<
  4958. ALIST: SKIPE A,-1(P)
  4959. PCALL NUMBERP
  4960. PUSH SP,[0] ;mark for unbind
  4961. JUMPN A,AEVAL7 ;number
  4962. MOVE C,SC2 ;bottom of spec pdl
  4963. MOVEM C,AEVAL5#
  4964. SETOM AEVAL2
  4965. AEVAL8: MOVE C,SP
  4966. AEVAL6: CAMN C,AEVAL5 ;bottom spec pdl
  4967. JRST AEVAL1 ;done
  4968. AEVAL4: POP C,AR4
  4969. JUMPE AR4,AEVAL6 ;thru with block
  4970. MOVSS AR4
  4971. PUSH SP,(AR4) ;save value cell
  4972. HLRZM AR4,(AR4) ;store previous value in value cell
  4973. HRLM AR4,(SP) ;save pointer to spec pdl loc
  4974. JRST AEVAL4
  4975. FNGUBD: EXCH A,(P) ;spec pdl pointer
  4976. PCALL NUMVAL
  4977. MOVE D,A
  4978. FNGUB2: POP SP,T
  4979. JUMPE T,POPAJ ;done
  4980. MOVSS T ;pointer to value cell
  4981. RPLCA T,(T)
  4982. SKIPN 1(D)
  4983. AOBJN D,.-1 ;skip over spec pdl marker
  4984. PUSH D,(T) ;put value cell in spec pdl
  4985. HLRZM T,(T) ;restore value cell
  4986. JRST FNGUB2
  4987. %EVAL: PSAVE A
  4988. PSAVE B
  4989. PCALL ALIST
  4990. PREST A
  4991. MOVEI A,UNBIND
  4992. EXCH A,(P)
  4993. JRST EVAL
  4994. PAGE
  4995. AEVAL1: SKIPGE AEVAL2
  4996. SKIPN B,-1(P)
  4997. PRET ;done with binding
  4998. MOVE A,B ;ALIST binding...
  4999. PCALL REVERSE
  5000. SKIPA
  5001. ABIND2: MOVE A,B
  5002. CDRA B,(A)
  5003. CARA A,(A)
  5004. CDRA AR4,(A)
  5005. CARA A,(A)
  5006. PCALL BIND
  5007. JUMPN B,ABIND2
  5008. PRET
  5009. ;spec pdl binding
  5010. AEVAL7: MOVE A,-1(P)
  5011. PCALL NUMVAL
  5012. SETZM AEVAL2
  5013. MOVEM A,AEVAL5 ;point to unbind to
  5014. JRST AEVAL8
  5015. AEVAL2: 0 ;0 for number, -1 for a-list *
  5016. > ;end of IFN FNRG
  5017. PAGE
  5018. EE2: CDRA T,(T)
  5019. FOO MOVEI D,FUNCELL
  5020. EE21: JUMPE T,EV3
  5021. MOVS TT,(T)
  5022. MOVS T,(TT)
  5023. CAIN D,(T)
  5024. JRA T,EE3
  5025. CARA T,TT
  5026. JRST EE21
  5027. EE3: CARA TT,T
  5028. CARA D,(T)
  5029. ;FOO CAIN TT,SUBR
  5030. ; JRST EVCOD
  5031. FOO CAIN TT,EXPR
  5032. JRST AEXPQ
  5033. ;FOO CAIN TT,FSUBR
  5034. ; JRST EFS
  5035. FOO CAIN TT,MACRO
  5036. JRST EFM
  5037. FOO CAIE TT,FEXPR
  5038. JRST UNDFUN
  5039. CAIE D,ID
  5040. CAIGE D,CODMIN
  5041. JRST AFEXP
  5042. EFS: CDRA T,(T)
  5043. CDRA A,(AR4)
  5044. JRST (T)
  5045. AFEXP: HLL T,(AR4)
  5046. PSAVE T
  5047. CDRA A,(A)
  5048. UUOS3I: TLO A,400000
  5049. PSAVE A
  5050. MOVNI T,1
  5051. JRST IAPPLY
  5052. AEXP: HLL T,(AR4)
  5053. EXP3: CDRA A,(AR4)
  5054. UUOS6: PSAVE T
  5055. CILIST: JSP TT,ILIST
  5056. EXP2: JRST IAPPLY
  5057. PAGE
  5058. AEXPQ: CAIE D,ID
  5059. CAIGE D,CODMIN
  5060. JRST AEXP
  5061. EVCOD: CDRA A,(AR4)
  5062. HLL T,(AR4)
  5063. UUOS2: CDRA T,(T)
  5064. PSAVE T ;For POPJ below --> call this addr.
  5065. JSP TT,ILIST
  5066. ESB1: MOVEI TT,CPOPJ
  5067. PDLARG: HRREI R,NACS(T)
  5068. JUMPGE R,PDLA1(R)
  5069. MOVMS R
  5070. CAILE R,NSUA-NACS
  5071. ERRL1 ^D145,[SIXBIT /TOO MANY ARGS FOR EXPR!/]
  5072. HRLI R,(R)
  5073. PXDROP R
  5074. MOVEI A,EXARG
  5075. HRLI A,1(P)
  5076. BLT A,EXARG-1(R)
  5077. PDLA1: PREST A+4
  5078. PREST A+3
  5079. PREST A+2
  5080. PREST A+1
  5081. PREST A
  5082. JRST (TT)
  5083. EFM: CALLF 1,(T)
  5084. JRST EVAL
  5085. PAGE
  5086. IFN FNRG,<
  5087. %APPLY: MOVEI R,3
  5088. JSP TT,ARGP1
  5089. MOVEM T,APFNG1#
  5090. PCALL ALIST
  5091. MOVE T,APFNG1
  5092. JSP TT,PDLARG
  5093. PSAVE C ;spec pdl pointer
  5094. PSAVE [FNGUBD] >
  5095. APPLY: PSAVE A
  5096. MOVEI T,0
  5097. AP3: JUMPE B,IAPPLY ;all args pushed; b has arg list
  5098. CARA C,(B)
  5099. PSAVE C ;push arg
  5100. CDRA B,(B)
  5101. SOJA T,AP3
  5102. IFN FNRG,<
  5103. IAP4: JUMPGE D,TOOFEW ;special case for fexprs
  5104. AOJN R,TOOFEW
  5105. PSAVE B
  5106. MOVE A,SP
  5107. PCALL FIX1A
  5108. EXCH A,(P)
  5109. MOVE B,A
  5110. MOVNI R,2
  5111. SOJA T,IAP5
  5112. FUNCT: PSAVE A
  5113. MOVE A,SP
  5114. PCALL FIX1A
  5115. PREST B
  5116. HLL A,(B)
  5117. PCALL DCONSA
  5118. FOO HRLI A,FUNARG
  5119. JRST DCONSA
  5120. PAGE
  5121. APFNG: SOS T
  5122. MOVEM T,APFNG1
  5123. JSP TT,PDLARG ;get args and funarg list
  5124. CDRA A,(A)
  5125. CDRA D,(A) ;a-list pointer
  5126. CARA A,(A) ;function
  5127. MOVN R,APFNG1 ;Positive no. of args
  5128. PSAVE D
  5129. PSAVE [FNGUBD]
  5130. JSP TT,ARGP1 ;replace args and fn name
  5131. PSAVE D ;a-list pointer
  5132. PCALL ALIST ;set up spec pdl
  5133. PREST D
  5134. AOS T,APFNG1
  5135. > ;end of IFN FNRG
  5136. IAPPLY: MOVE C,T ;state of world at entrance
  5137. ADDI C,(P) ;t has - number of args on pdl
  5138. ILP1A: CDRA B,(C) ;next pdl slot has function- poss fun name in lh
  5139. CAILE B,INUMIN
  5140. JRST UNDTAG
  5141. CARA TT,(B)
  5142. CAILE TT,ATMIN
  5143. JRST IAP1 ;fn is atomic
  5144. FOO CAIN TT,LAMBDA
  5145. JRST IAPLMB
  5146. IFN FNRG,<
  5147. FOO CAIN TT,FUNARG
  5148. JRST APFNG >
  5149. FOO CAIN TT,LABEL
  5150. JRST APLBL
  5151. PSAVE T
  5152. MOVE A,B
  5153. PCALL EVAL
  5154. PREST T
  5155. MOVE C,T
  5156. ADDI C,(P)
  5157. ILP1B: MOVEM A,(C)
  5158. JRST ILP1A
  5159. UNDTAG: MOVE A,(C) ;FN NAME,,FN
  5160. TLNE A,-1 ;Any function name ?
  5161. HLRZS A ;Yes!
  5162. ERRE1 ^D30,[SIXBIT /UNDEFINED FUNCTION - APPLY!/]
  5163. PAGE
  5164. IAP1: CAIGE TT,CODMIN
  5165. JRST UNDTAG
  5166. CAIE TT,ID
  5167. JRST APCOD
  5168. FOO MOVEI D,FUNCELL
  5169. CDRA B,(B)
  5170. IAPL1: JUMPE B,IAP2
  5171. MOVS TT,(B)
  5172. MOVS B,(TT)
  5173. CAIN D,(B)
  5174. JRA B,IAPL2
  5175. CARA B,TT
  5176. JRST IAPL1
  5177. IAPL2: CARA TT,B
  5178. ;FOO CAIN TT,SUBR
  5179. ; JRST APCOD
  5180. FOO CAIE TT,EXPR
  5181. ERRE1 ^D31,[SIXBIT /NOT EXPR - APPLY!/]
  5182. CARA D,(B)
  5183. CAIE D,ID
  5184. CAIGE D,CODMIN
  5185. JRST IAPXPR
  5186. APCOD: CDRA B,(B)
  5187. HRRZM B,(C)
  5188. JRST ESB1
  5189. IAPXPR: CDRA A,B
  5190. JRST ILP1B
  5191. PAGE
  5192. IAPLMB: CDRA B,(B)
  5193. CARA TT,(B)
  5194. CDRA B,(B)
  5195. CARA D,(TT)
  5196. CAIN D,ID
  5197. JUMPN TT,[ERRL1 ^D146,[SIXBIT /ILLEGAL LAMBDA FORMAT!/]]
  5198. MOVE R,T
  5199. IPLMB1: JUMPE T,IPLMB2 ;no more args
  5200. JUMPE TT,TOMANY ;too many args supplied
  5201. IAP5: CARA A,(TT)
  5202. MOVEI AR4,1(T)
  5203. ADD AR4,P
  5204. HLLZ D,(AR4) ;tested in IAP4
  5205. RPLCA A,(AR4)
  5206. CDRA TT,(TT)
  5207. AOJA T,IPLMB1
  5208. IFE FNRG,IAP4==TOFEW
  5209. IPLMB2: JUMPN TT,IAP4 ;too few args supplied
  5210. PUSH SP,[0] ;mark for unbind
  5211. JUMPE R,IAP69
  5212. IPLMB4: PREST AR4
  5213. CARA A,AR4
  5214. PCALL BIND
  5215. AOJL R,IPLMB4
  5216. IAP69: PREST AR4
  5217. TLNE AR4,-1
  5218. FOO SKIPN BACTRF
  5219. JRST .+3
  5220. HRRI AR4,CPOPJ
  5221. PSAVE AR4
  5222. PCALL PROGN1
  5223. JRST UNBIND
  5224. TOMANY: ERRL1 ^D147,[SIXBIT /TOO MANY ARGUMENTS SUPPLIED - APPLY!/]
  5225. TOOFEW: ERRL1 ^D148,[SIXBIT /TOO FEW ARGUMENTS SUPPLIED - APPLY!/]
  5226. PAGE
  5227. APLBL: PUSH SP,[0] ;mark for unbind
  5228. CDRA B,(B)
  5229. CARA A,(B)
  5230. CDRA B,(B)
  5231. CARA AR4,(B)
  5232. MOVEM AR4,(C)
  5233. PCALL BIND
  5234. MOVEI A,APLBL1
  5235. EXCH A,-1(C)
  5236. EXCH A,LBLAD#
  5237. HRLI A,LBLAD
  5238. PUSH SP,A
  5239. JRST IAPPLY
  5240. APLBL1: PSAVE LBLAD
  5241. JRST SPECSTR
  5242. IAP2: CDRA A,(C)
  5243. FOO MOVEI B,VALUE
  5244. PCALL GET+1 ;don't need to check for id
  5245. JUMPE A,UNDTAG
  5246. CDRA A,(A)
  5247. CDRA B,(C)
  5248. CAIE A,(B)
  5249. FOO CAIN A,UNBOUND
  5250. JRST UNDTAG
  5251. JRST ILP1B
  5252. RETB:
  5253. PROG2: HRRZ A,B
  5254. PRET
  5255. PAGE
  5256. BIND: JSP D,CHKID
  5257. FOO CAIE A,TRUTH
  5258. JUMPN A,BIND4
  5259. ERRE2 ^D32,[SIXBIT /MAY NOT BE CHANGED!/]
  5260. BIND4: PSAVE B
  5261. PCALL BIND1 ;get value cell
  5262. PUSH SP,(A)
  5263. RPLCA A,(SP)
  5264. HRRZM AR4,(A)
  5265. POPBJ: PREST B
  5266. PRET
  5267. BIND1: HRRZM A,BIND3#
  5268. FOO MOVEI B,VALUE
  5269. PCALL GET+1
  5270. JUMPN A,CPOPJ
  5271. FOO MOVEI A,UNBOUND
  5272. PCALL DCONSA
  5273. MOVE TT,A
  5274. FOO HRLI A,VALUE
  5275. PCALL DCONSA
  5276. CDRA B,@BIND3
  5277. PCALL CONS
  5278. RPLCD A,@BIND3
  5279. MOVE A,TT
  5280. PRET
  5281. TUNBIND:SETZM SPSAV
  5282. MOVE B,SC2
  5283. UBD: CAMN SP,B
  5284. PRET
  5285. PCALL UNBIND
  5286. JRST UBD
  5287. SPECSTR: ;LAP...<PCALL SPECSTR>
  5288. UNBIND: POP SP,T
  5289. JUMPE T,CPOPJ
  5290. MOVSS T
  5291. HLRZM T,(T)
  5292. JRST UNBIND
  5293. PAGE
  5294. PROGBIND:MOVEI D,PROGB1 ;LAP...<CALL 0,PROGBIND><0 0 (FLUID --)>
  5295. SPEC1: PREST T
  5296. PUSH SP,[0] ;mark for unbind
  5297. SPEC2: LDB R,[POINT 13,(T),ACFLD]
  5298. CAIG R,377
  5299. JRST (D) ;prog- or lam-bind
  5300. JRST (T) ;next is opcode, so quit.
  5301. LAMBIND:JSP D,SPEC1 ;LAP...<CALL 0,LAMBIND><0 x (FLUID --)>
  5302. JUMPE R,SPEC3 ;Init = NIL
  5303. CAIG R,NACS
  5304. JRST LAMB1
  5305. CAIG R,NSUA ;Extended regs.
  5306. JRST LAMB2 ;Yes
  5307. MOVNI R,(R) ;From pdl
  5308. ADDI R,NSUA+1(P)
  5309. LAMB1: SKIPA R,(R)
  5310. PROGB1: SETZ R,
  5311. SPEC3: EXCH R,@(T)
  5312. HRL R,(T)
  5313. PUSH SP,R ;<address,,old-value>.
  5314. AOJA T,SPEC2
  5315. LAMB2: MOVE R,EXARG-NACS-1(R)
  5316. JRST SPEC3
  5317. ;Miscellaneous special case compiler run time routines
  5318. %AMAKE: PSAVE A ;make alist for fsubr that requires it
  5319. MOVE A,SP
  5320. PCALL FIX1A
  5321. MOVE B,A
  5322. JRST POPAJ
  5323. IFE STL,<
  5324. %UDT: PCALL ERHED ;error print for undefined computed go tag
  5325. PCALL PRIN1
  5326. STRTIP [SIXBIT / UNDEFINED COMPUTED GO TAG IN !/]
  5327. MOVEI R,INUM0+17
  5328. HRRM R,ERRX
  5329. CDRA R,(P)
  5330. PCALL ERSUB3
  5331. JRST ERREND-1
  5332. %LCALL: MOVN A,T ;set up routine for compile lsubr
  5333. ADDI A,INUM0
  5334. ADDI T,(P)
  5335. PSAVE T
  5336. PCALL (3)
  5337. PREST T
  5338. SUBI T,(P)
  5339. HRLI T,-1(T)
  5340. ADD P,T
  5341. PRET >
  5342. SUBTTL ARRAY SUBROUTINES --- PAGE 17
  5343. IFN ASARY,<
  5344. ARRERR=-1
  5345. ARRAY: PCALL ARRAYS
  5346. HRRI AR5,1(R)
  5347. MOVE A,AR5
  5348. PUSH R,[0]
  5349. AOBJN A,.-1
  5350. ARREND: MOVE A,BPPNR#
  5351. MOVEM AR5,-1(A)
  5352. MOVEI A,1(R)
  5353. PCALL FIX1A ;MOVEI A,INUM0+1(R)
  5354. FOO MOVEM A,VBPORG
  5355. PRET
  5356. ARRAYS: PSAVE A
  5357. FOO MOVE A,VBPORG
  5358. PCALL NUMVAL ;SUBI A,INUM0
  5359. MOVEM A,BPPNR
  5360. FOO MOVE A,VBPEND
  5361. PCALL NUMVAL ;MOVNI A,-INUM0-2(A)
  5362. MOVN A,A
  5363. ADDI A,2
  5364. ADD A,BPPNR ;bporg-bpend+2
  5365. HRLM A,BPPNR
  5366. HRRZ A,BPPNR
  5367. ADDI A,2
  5368. PCALL IMKCODE
  5369. FOO MOVEI B,EXPR
  5370. PREST A
  5371. CDRA AR4,(A) ;(cdr l)
  5372. CARA A,(A) ;(car l)name
  5373. PCALL IPUTD
  5374. CARA A,(AR4) ;(cadr l)mode
  5375. PSAVE AR4
  5376. PCALL EVAL ;eval mode
  5377. PREST AR4
  5378. MOVEM A,AMODE#
  5379. MOVEI C,44
  5380. JUMPE A,ARRY1
  5381. MOVEI C,-INUM0(A)
  5382. CAILE A,INUMIN
  5383. JRST ARRY1
  5384. MOVEI C,22
  5385. MOVE A,GCMKL
  5386. HRL A,BPPNR
  5387. PCALL DCONSA ;IFF Lisp-pntrs requested,
  5388. MOVEM A,GCMKL ;record for GC marking of arrays.
  5389. ARRY1: MOVEM C,BSIZE#
  5390. MOVEI A,44
  5391. IDIV A,C
  5392. MOVEM A,NBYTES#
  5393. CDRA A,(AR4) ;(cddr l)bound pair list
  5394. JSP TT,ILIST
  5395. AOS R,BPPNR
  5396. MOVEI AR4,1 ;AR4 is array size
  5397. MOVEI AR5,0 ;AR5 is cumulative residue
  5398. AOJGE T,ARRYS ;single dimension
  5399. MOVEI D,A-1
  5400. SUB D,T ;D is next ac for array code generation
  5401. ARRY2: PCALL ARRB0
  5402. TLC TT,(IMULI)
  5403. DPB D,[POINT 4,TT,ACFLD]
  5404. PUSH R,TT
  5405. CAIN D,A
  5406. JRST ARRY3
  5407. MOVSI TT,(ADD)
  5408. ADDI TT,1(D)
  5409. DPB D,[POINT 4,TT,ACFLD]
  5410. PUSH R,TT
  5411. SOJA D,ARRY2
  5412. ARRB0: PREST TT ;E.G., after ARRAY XX(5,6),
  5413. EXCH TT,(P) ; extents= (0:5,0:6), =42, = 0:41,
  5414. CAILE TT,INUMIN ; generates SUBR #22002, say, and
  5415. JRST ARRB1 ;22000/ -25,,22016 ;-N/2,,data
  5416. CARA A,(TT) ; 001/ 5,,-10 ;INUM0*8
  5417. CDRA TT,(TT) ; 002/ IMULI A,7
  5418. SUBI TT,(A) ; 003/ ADD A,B
  5419. ADDI TT,1 ; 004/ SUB A,22001
  5420. JRST ARRB2 ; 005/ JUMPL A,ARRERR;indexing .LT. (0,0)
  5421. ; 006/ CAIL A,^D42
  5422. ARRB1: MOVEI A,INUM0 ; 007/ JRST ARRERR
  5423. SUB TT,A ; 010/ IDIVI A,2 ;half-word pntrs.
  5424. ARRB2: IMUL A,AR4 ; 011/ IMULI B,-^D18_12 ;bytesize.
  5425. IMULB AR4,TT ; 012/ HRLZI C,(POINT 18,0(B),17)
  5426. ADDM A,AR5 ; 013/ ADDI C,22016(A)
  5427. PRET ; 014/ LDB A,C ;proper halfword.
  5428. ; 015/ PRET ;returning pntr, etc.
  5429. ARRY3: PUSH R,[ADD A,B] ; 016/ ...,,... ;INITIALLY 0 or NIL.
  5430. ARRYS: PCALL ARRB0
  5431. HRRZ TT,BPPNR
  5432. MOVEM AR5,(TT) ;SUBR-1, e.g. 22001.
  5433. HRLI TT,(SUB A,)
  5434. PUSH R,TT
  5435. PUSH R,[JUMPL A,ARRERR]
  5436. MOVE TT,AR4
  5437. HRLI TT,(CAIL A,)
  5438. PUSH R,TT
  5439. PUSH R,[JRST ARRERR]
  5440. IDIV AR4,NBYTES ;calc #words in array
  5441. SKIPE AR5 ;correct for remainder non-zero
  5442. ADDI AR4,1
  5443. MOVE TT,NBYTES
  5444. SOJE TT,ARRY6
  5445. ADDI TT,1
  5446. HRLI TT,(IDIVI A,)
  5447. PUSH R,TT
  5448. MOVN TT,BSIZE
  5449. LSH TT,14
  5450. HRLI TT,(IMULI B,)
  5451. PUSH R,TT
  5452. MOVEI TT,44+200
  5453. SUB TT,BSIZE
  5454. LSH TT,6
  5455. ARRY6: ADD TT,BSIZE
  5456. LSH TT,6
  5457. SKIPE AR5,AMODE
  5458. CAIL AR5,INUMIN
  5459. ADDI TT,40 ;mode not = T
  5460. TLC TT,(MOVSI C,)
  5461. PUSH R,TT
  5462. MOVEI TT,4(R)
  5463. HRLI TT,(ADDI C,(A))
  5464. PUSH R,TT
  5465. PUSH R,[LDB A,C]
  5466. MOVSI AR5,(PRET)
  5467. SKIPN TT,AMODE
  5468. MOVE AR5,[JRST FLO1A]
  5469. CAIL TT,INUMIN
  5470. MOVE AR5,[JRST FIX1A]
  5471. PUSH R,AR5
  5472. MOVS AR5,AR4
  5473. MOVNS AR5
  5474. PRET
  5475. STORE: PSAVE A
  5476. PCALL CADR
  5477. PCALL EVAL ;value to store
  5478. EXCH A,(P)
  5479. CARA A,(A)
  5480. PCALL EVAL ;byte pointer returned in c
  5481. PREST A
  5482. NSTR: PSAVE A
  5483. TLNE C,40
  5484. JSP D,ONUMV ;numerical array
  5485. JRST BIGNER ;BIGNUM IS ERROR
  5486. DPB A,C
  5487. PREST A
  5488. PRET > ;end of IFN ASARY from line 300
  5489. PAGE
  5490. IFN ALOD&ASARY,<
  5491. EXARRAY:PSAVE A
  5492. CARA A,(A)
  5493. PCALL GETSYM
  5494. JUMPE A,POPAJ
  5495. PCALL NUMVAL
  5496. EXCH A,(P)
  5497. PCALL ARRAYS
  5498. PREST A
  5499. HRRM A,-2(R)
  5500. HRR AR5,A
  5501. JRST ARREND > ;end of IFN ALOD&ASARY
  5502. DLVECT:
  5503. IFN ASARY,SETZ AR4, ;To reduce GC overhead, or GCing of
  5504. JSP D,ATMTYP
  5505. CAIE TT,VECT
  5506. IFN ASARY,<
  5507. JRST .+2
  5508. JRST ISVC ; obsolete array in BPS overlays, e.g.
  5509. MOVE AR4,A
  5510. PCALL GETD
  5511. JUMPE A,FALSE ;Gone.
  5512. CARA D,(A)
  5513. FOO CAIE D,EXPR >
  5514. JRST FALSE
  5515. ISVC: CDRA A,(A)
  5516. MOVEI TT,GCMKL ;Delete a Lisp array from the GC list,
  5517. DLARRLP:CDRA T,(TT) ; If done with it, tho can't reclaim core yet.
  5518. CARA C,(T)
  5519. CAIN C,-2(A)
  5520. JRST DLFOUND
  5521. CDRA TT,(TT)
  5522. JUMPN TT,DLARRLP
  5523. JRST FALSE ;Not found.
  5524. DLFOUND:CDRA T,(T)
  5525. RPLCD T,(TT) ;Cut out of list.
  5526. IFN ASARY,<SKIPE A,AR4
  5527. PCALL REMD> ;Delete the SUBR pointer from the Lisp array
  5528. JRST TRUE
  5529. PAGE
  5530. MKVECT: PCALL NUMVAL
  5531. JUMPL A,VECOV+1
  5532. PSAVE A
  5533. LSH A,-1
  5534. PSAVE A
  5535. FOO MOVE A,VBPORG
  5536. PCALL NUMVAL
  5537. EXCH A,(P)
  5538. ADD A,(P)
  5539. ADDI A,3
  5540. PCALL FIX1A
  5541. PSAVE A
  5542. FOO MOVE B,VBPEND
  5543. PCALL .GREAT
  5544. JUMPN A,VECOV
  5545. FOO PREST VBPORG ;set new bporg
  5546. MOVE A,GCMKL
  5547. HRL A,(P)
  5548. PCALL DCONSA
  5549. HRRM A,GCMKL
  5550. PREST A ;old bporg, i.e. beginning of vector
  5551. MOVE B,(P)
  5552. LSH B,-1
  5553. ADDI B,1
  5554. MOVNS B
  5555. HRLM B,(A)
  5556. ADDI A,2
  5557. HRRM A,-2(A)
  5558. MOVE B,-2(A)
  5559. SETZM (B) ;fill vector with NIL
  5560. AOBJN B,.-1
  5561. PREST -1(A) ;Upper limit for vector
  5562. HRLI A,VECT
  5563. JRST DCONSA
  5564. PAGE
  5565. GETV: JSP T,OPV
  5566. CARA A,(B)
  5567. CDRA A,(B)
  5568. PUTV: JSP T,OPV
  5569. RPLCA A,(B)
  5570. RPLCD A,(B)
  5571. OPV: JSP D,ATMTYP
  5572. CAIE TT,VECT
  5573. ERRE2 ^D33,[SIXBIT /IS NOT A VECTOR!/]
  5574. CDRA TT,(A)
  5575. MOVE A,C
  5576. SUBI B,INUM0
  5577. JUMPL B,INXOV
  5578. CAMLE B,-1(TT) ;compare with upper limit
  5579. JRST INXOV ;too big
  5580. TRNE B,1 ;odd or eaven
  5581. ADDI T,1 ;odd
  5582. LSH B,-1
  5583. ADDI B,(TT)
  5584. XCT (T)
  5585. PRET
  5586. VECTORP:
  5587. UPBV: JSP D,ATMTYP
  5588. CAIE TT,VECT
  5589. JRST FALSE
  5590. CDRA A,(A)
  5591. MOVE A,-1(A)
  5592. JRST FIX1A
  5593. INXOV: MOVEI A,INUM0(B)
  5594. ERRE2 ^D34,[SIXBIT /SUBSCRIPT IS OUT OF RANGE!/]
  5595. VECOV: MOVE A,-2(P)
  5596. ADDI A,INUM0
  5597. ERRE2 ^D35,[SIXBIT /TOO BIG VECTOR!/]
  5598. SUBTTL EXAMINE, DEPOSIT , ETC --- PAGE 18
  5599. BOOLE: SUBI A,INUM0
  5600. DPB A,[POINT 4,BOOLI,OPFLD-2]
  5601. MOVE A,B
  5602. PCALL NUMVAL
  5603. EXCH C,A
  5604. BOOLL: PCALL NUMVAL
  5605. BOOLI: SETZB C,A
  5606. JRST FIX1A
  5607. EXAMINE:PCALL NUMVAL ;<MOVE A,-INUM0(A)>
  5608. MOVE A,(A)
  5609. JRST FIX1A
  5610. DEPOSIT:MOVE C,B
  5611. PCALL NUMVAL ;<MOVEI C,-INUM0(A)
  5612. EXCH A,C ; MOVE A,B >
  5613. JSP D,ONUMV
  5614. BIGNER: ERRL0 ^D139,[SIXBIT /BIGNUM UNSUITABLE AS ARG!/] ;AASCII,BOOLE,etc.
  5615. MOVEM A,(C)
  5616. JRST MAKNUM
  5617. LSH: MOVEI C,-INUM0(B)
  5618. PCALL NUMVAL
  5619. LSH A,(C)
  5620. JRST FIX1A
  5621. SUBTTL GARBAGE COLLECTOR --- PAGE 19
  5622. GC: PCALL AGC
  5623. JRST FALSE
  5624. AGC2: SKIPE GCFFLG ;did we just do a GC from top ?
  5625. PRET ;yes, don't do it again
  5626. SETOM GCFFLG ;indicate GC from top
  5627. AGC: MOVEM R,ACSAV+R
  5628. AGC1: MOVEM SP,SPSAV ;save in case of ^C
  5629. MOVE NIL,CNIL3 ;set NIL
  5630. PSAVE .JBUUO
  5631. PSAVE UUOH
  5632. GCPK1: PSAVE PA3
  5633. PSAVE PA4
  5634. PSAVE UBDPTR ;special atom UNBOUND; not on OBLIST
  5635. PSAVE MKNAM3
  5636. PSAVE GCMKL ;i/o channel input lists and arrays
  5637. PSAVE BIND3
  5638. GCPK2: PSAVE [XWD 0,GCP6] ;this is a return address
  5639. MOVEI D,ACSAV
  5640. BLT D,ACSAV+11 ;save ACs 0 through 11
  5641. GCP2: SETZB NIL,X ;gc indicator, init. for bit table zero
  5642. MOVE A,C3GC
  5643. GCP5: BLT A,X ;zero bit tables, .=top of bit tables
  5644. FOO SKIPN GCGAGV
  5645. JRST GCP5A
  5646. CAIN F,ILLAD
  5647. STRTIP [SIXBIT /_*** FREE STG EXHAUSTED_!/]
  5648. SKIPN FF
  5649. STRTIP [SIXBIT /_*** FULL WORD SPACE EXHAUSTED_!/]
  5650. GCP5A: MOVEI TT,1
  5651. MOVEI A,0
  5652. CALLI A,STIME ;time
  5653. MOVEM A,GCTIMT#
  5654. GCP3: MOVEI C,X ;.=bottom of reg pdl
  5655. GCP6B: MOVE S,P
  5656. HLL C,P
  5657. MOVEI B,0
  5658. GC1: CAMN C,S
  5659. PRET
  5660. HRRZ A,(C)
  5661. GCP: CAIGE A,X ;.=bottom of bit tables
  5662. GCPP1:
  5663. FOO CAIGE A,FS
  5664. JRST GCEND
  5665. GCP1: CAIL A,X ;.=bottom of full word space (fws)
  5666. JRST GCMFWS
  5667. MOVE F,(A)
  5668. LSHC A,-5
  5669. ROT B,5
  5670. MOVE AR4,GCBT(B)
  5671. GCBTP2: TDOE AR4,X(A) ;bit tab- (fs_-5), .=magic number for sync
  5672. JRST GCEND
  5673. GCBTP1: MOVEM AR4,X(A) ;bit tab- (fs_-5)
  5674. PSAVE F
  5675. CARA A,F
  5676. JRST GCP
  5677. GCMFWS: MOVEI AR4,X(A) ;.=- bottom of fws
  5678. IDIVI AR4,44
  5679. MOVNS AR5
  5680. LSH AR5,36
  5681. ADD AR5,C2GC
  5682. DPB TT,AR5
  5683. GCEND: CAMN P,S
  5684. AOJA C,GC1
  5685. PREST A
  5686. HRRZS A
  5687. JRST GCP
  5688. CNIL3:
  5689. FOO XWD ID,CNIL2 ;NIL header to refresh ac 0
  5690. GCMKL: XWD 0,.+1+X ;Appended to, for each Lisp-pntr array.
  5691. XWD .+1,.+2
  5692. XWD -NSUA+NACS-1,EXARG
  5693. XWD .+1,.+2
  5694. XWD -11,ACSAV ;Reg 0 - 10 are saved from gc this way
  5695. XWD .+1,NIL
  5696. XWD -NIOCH,CHTAB+FSTCH
  5697. C2GC: XWD 430100+AR4,X ;.=bottom of fws bit table
  5698. C3GC: 0 ;<bottom bit table,,bottom bit table+1>
  5699. GCBT: XWD 400000,0
  5700. ZZ==1B1
  5701. XLIST
  5702. REPEAT ^D31,<ZZ
  5703. ZZ==ZZ/2>
  5704. LIST
  5705. PAGE
  5706. GCP6: HRRZ R,SC2
  5707. GCP6C: CAILE R,(SP) ;mark sp
  5708. JRST GCP6A
  5709. PSAVE (R)
  5710. HRRZ C,P
  5711. PCALL GCP6B
  5712. P1DROP
  5713. AOJA R,GCP6C
  5714. GCP6A: HRRZ R,GCMKL ;mark arrays
  5715. GCP6D: JUMPE R,GCSWP
  5716. CARA A,(R)
  5717. MOVE D,(A) ;<-N,,ADDR>
  5718. GCP6E: PSAVE (D)
  5719. CDRA C,P
  5720. PSAVE (D)
  5721. MOVSS (P)
  5722. PCALL GCP6B
  5723. P2DROP
  5724. AOBJN D,GCP6E
  5725. CDRA R,(R)
  5726. JRST GCP6D
  5727. GFSWPP:
  5728. PHASE 0
  5729. GFSP1==.
  5730. JUMPL S,.+3
  5731. HRRZM F,(R)
  5732. HRRZ F,R
  5733. ROT S,1
  5734. AOBJN R,.-4
  5735. MOVE S,(D)
  5736. HRLI R,-40
  5737. AOBJN D,GFSP1
  5738. LPROG==.
  5739. JRST GFSPR
  5740. DEPHASE
  5741. PAGE
  5742. ;garbage collector sweep
  5743. GCSWP: MOVSI R,GFSWPP
  5744. BLT R,LPROG
  5745. MOVEI F,ILLAD
  5746. MOVE D,C3GCS
  5747. FOO MOVEI R,FS
  5748. GCBTL1: HRLI R,X ;-(32-<fs&37>
  5749. MOVE S,(D)
  5750. GCBTL2: ROT S,X ;fs&37
  5751. AOBJN D,GFSP1
  5752. GFSPR: MOVE A,C1GCS
  5753. MOVE B,C2GCS
  5754. PCALL GCS0
  5755. FOO SKIPN GCGAGV
  5756. JRST GCSP1
  5757. PCALL WHEAD
  5758. MOVE A,F
  5759. PCALL GCPNT
  5760. STRTIP [SIXBIT / FREE STG,!/]
  5761. MOVE A,FF
  5762. PCALL GCPNT1
  5763. STRTIP [SIXBIT / FULL WORDS AVAILABLE!/]
  5764. PCALL TOURET
  5765. GCSP1: PXDROP [XWD GCPK2-GCPK1,GCPK2-GCPK1] ;restore p
  5766. PREST UUOH
  5767. PREST .JBUUO
  5768. MOVE NIL,ACSAV
  5769. SETZM SPSAV
  5770. CAIN F,ILLAD
  5771. ERRG ^D260,[SIXBIT /NO FREE STG LEFT!/]
  5772. JUMPE FF,[ERRG ^D261,[SIXBIT /NO FULL WORDS LEFT!/]]
  5773. MOVEI A,0
  5774. CALLI A,STIME ;time
  5775. SUB A,GCTIMT
  5776. ADDM A,GCTIM#
  5777. MOVSI D,ACSAV
  5778. BLT D,S ;reload ac's
  5779. MOVE R,ACSAV+R
  5780. IFN OPSYS,<
  5781. SKIPE KBINTF ;Any user ^char interrupts from KB?
  5782. JRST KBINTH > ; Yes, process.
  5783. PRET
  5784. PAGE
  5785. GCS0: MOVEI FF,0
  5786. GCS1: ILDB C,B
  5787. JUMPN C,GCS2
  5788. HRRZM FF,(A)
  5789. HRRZ FF,A
  5790. GCS2: AOBJN A,GCS1
  5791. PRET
  5792. C1GCS: 0 ;<- length of fws,,bottom of fws>
  5793. C2GCS: POINT 1,X,35 ;.=bottom of fws bit table
  5794. C3GCS: 0 ;-n wds in bt,,bt
  5795. GCTIME: MOVE A,GCTIM
  5796. JRST FIX1A
  5797. TIME: MOVEI A,0
  5798. CALLI A,STIME
  5799. JRST FIX1A
  5800. SPEAK: MOVE A,CONSVAL#
  5801. JRST FIX1A
  5802. GCPNT1: MOVEI B,0
  5803. JUMPE A,LOOP0
  5804. HRRZ A,(A)
  5805. AOJA B,.-2 ; B:=LENGTH(A)
  5806. GCPNT: MOVEI B,0
  5807. JRST .+2
  5808. HRRZ A,(A)
  5809. CAIE A,ILLAD
  5810. AOJA B,.-2
  5811. LOOP0: PCALL FIX1
  5812. JRST PRIN1
  5813. SUBTTL GETSYM,PUTSYM --- PAGE 20
  5814. IFN ALOD,< ;this entire page
  5815. R50MAK: PCALL PNAMUK
  5816. PUSH C,[0]
  5817. HRLI C,700
  5818. HRRI C,(SP)
  5819. MOVEI B,0
  5820. MK3: ILDB A,C
  5821. LDB A,R50FLD
  5822. CAMGE B,[50*50*50*50*50]
  5823. SKIPN A
  5824. PRET
  5825. IMULI B,50
  5826. ADD B,A
  5827. JRST MK3
  5828. GETSYM: PCALL R50MAK
  5829. TLO B,040000 ;04 for globals
  5830. MOVE C,.JBSYM
  5831. MK7: CAMN B,(C)
  5832. JRST MK10 ;found
  5833. AOBJP C,.+2
  5834. AOBJN C,MK7
  5835. TLC B,140000 ;10 for locals
  5836. TLNN B,100000
  5837. TLON B,400000 ;Suppressed to DDT
  5838. JRST MK7-1
  5839. JRST FALSE
  5840. MK10: MOVE A,1(C) ;value
  5841. JRST FIX1A
  5842. PUTSYM: PSAVE B
  5843. PCALL R50MAK
  5844. MOVE A,B
  5845. TLO A,040000 ;make global
  5846. SKIPL .JBSYM
  5847. AOS .JBSYM ;increment initial symbol table pointer
  5848. PSAVE A
  5849. MOVEI A,2
  5850. PCALL EXPND2
  5851. MOVN B,[XWD 2,2]
  5852. ADDB B,.JBSYM
  5853. PREST (B) ;Name
  5854. PREST 1(B) ;value
  5855. JRST FALSE
  5856. > ;end of IFN ALOD
  5857. SUBTTL FASLOAD --- PAGE 21
  5858. ;From MIT-ML, converted to LISP 1.6 of Utah
  5859. ;By KRK, Last edit: 09 Aug 76
  5860. IFN OFLD,<
  5861. LDFNM2==137 ;Address of Lisp version number (if any).
  5862. LDGPRO==0 ;Address (relative to reg P) of internal QLIST
  5863. LDPRLS==-1 ; - " - P.URCLOBRL
  5864. LDAAOB: 0 ;Currently highest index in Atomtable
  5865. LDAGCM: 0 ;Address of GCMKL word for Atomtable
  5866. LDAPTR: 0(TT) ;Base address for Atomtable. Index in TT
  5867. LDBYTS: 0 ;Holds word being unpacked into bytes
  5868. LDEOFJ: 0 ;Error index
  5869. LDF2DP: 0 ;XOR between current and file version number
  5870. LDGROW: 0 ;For extended Atomtable. Not used
  5871. LDHLOC: 0 ;Not used
  5872. LDOFST: 0(TT) ;Start of currently loaded routine. Relocation base
  5873. ;LDPRDF: 0 ;Internal !*PREDEF flag
  5874. ;Error indices
  5875. LOOK==-1
  5876. EMPTYF==0
  5877. FORMAT==1
  5878. GCPROT==2
  5879. BPFULL==3
  5880. FTFULL==4
  5881. PAGE
  5882. ; FASLOD('ArrayForFisl);
  5883. FASLOD: ;MOVEM B,LDPRDF ;"Print redefined funcs".
  5884. FOO SKIPN C,VPURIFY
  5885. TLOA C,(1B0)
  5886. FOO CDRA C,VP.URCLOBRL
  5887. PSAVE C ;- to omit; 0 or old-addr to purify.
  5888. PSAVE C ;LDGPRO zeroed below.
  5889. SETZM LDEOFJ ;An EOF is erroneous until LDBEND byte.
  5890. JSP D,ATMTYP
  5891. CAIE TT,VECT
  5892. JRST LDFERR
  5893. CDRA A,(A) ;Lookup ATOMTABLE's access addr...
  5894. MOVEI B,-2(A)
  5895. MOVEM B,LDAGCM ;Addr of array's allocation-wd (GCMKL).
  5896. MOVE B,-2(A)
  5897. HRRM B,LDAPTR ;Addr of array's data base-wd.
  5898. SETZ TT,
  5899. SETZM @LDAPTR ;0th is NIL [N.B. indirection-addr uses TT].
  5900. LDMORE: JSP T,LDGTWD ; ...except that can get empty file.
  5901. JUMPE TT,.-1 ;Sluff leading/trailing 0 words.
  5902. SETZM LDEOFJ ;(Reset after a new file's LDMORE).
  5903. AOS LDEOFJ ;Now 1 for "Format error".
  5904. CAME TT,[ASCII /FASLP/]
  5905. JSP D,LDFERR ;Improper format for FASL file.
  5906. JSP T,LDGTWD ;Get 2nd word of each file.
  5907. XOR TT,LDFNM2 ;Compare to Lisp's version&flags.
  5908. MOVEM TT,LDF2DP ;Nonzero if different.
  5909. SETZM FFFSUB#
  5910. SETZM LDGPRO(P) ;Internal QLIST effectively.
  5911. HLLZ A,@LDAGCM ;[-length,,0]
  5912. AOBJN A,.+1
  5913. MOVEM A,LDAAOB ;Commence with 1th cell; NIL is 0th.
  5914. FOO MOVE A,VBPORG
  5915. PCALL NUMVAL
  5916. HRRM A,LDOFST ;Also a TT indirection pntr.
  5917. HRRZM A,R ;Form AOBJP wd in R for BPS storage...
  5918. MOVE B,LDAGCM ; [Use this rather than BPEND1].
  5919. SUBI A,-1(B)
  5920. JUMPL A,USE.IT
  5921. FOO MOVE A,VBPEND
  5922. PCALL NUMVAL
  5923. MOVE B,A
  5924. MOVE A,R
  5925. SUBI A,(B)
  5926. JUMPGE A,FASLNC
  5927. USE.IT: HRLI R,(A) ; [-<available BPS>,,<starting BPORG>]
  5928. SETZM LDHLOC ;Initialize for the BPS section.
  5929. MOVE AR4,[000400,,LDBYTS] ;Initialize for accessing each
  5930. JRST LDBIN ; 9*4 series of bytes.
  5931. PAGE
  5932. ;;; FROM THIS POINT ON, UNTIL A FATAL ERROR OCCURS OR LOCATION LDFEND IS REACHED,
  5933. ;;; THESE ACCUMULATORS ARE DEDICATED TO THE FOLLOWING PURPOSES:
  5934. ;;; AR4 BYTE POINTER FOR GETTING SUCCESSIVE RELOCATION TYPES
  5935. ;;; R AOBJN POINTER FOR PUTTING WORDS INTO BINARY PROGRAM SPACE
  5936. LDREL: HRRI TT,@LDOFST ;[RELOCATABLE WORD]
  5937. LDABS: MOVEM TT,(R) ;[ABSOLUTE WORD]
  5938. LDABS1: AOBJP R,FASLNC ;EXCEEDED AVAILABLE BPS -- NO CORE.
  5939. LDBIN: TLNN AR4,770000
  5940. JRST LDBIN2 ;OUT OF RELOCATION BYTES - GET MORE.
  5941. LDBIN1: JSP T,LDGTWD ;GET WORD FROM INPUT FILE
  5942. ILDB T,AR4 ;GET CORRESPONDING RELOCATION BYTE
  5943. JSP D,@LDTTBL(T) ; - IT TELLS US WHERE TO GO
  5944. LDTTBL: LDABS ; 0 ABSOLUTE
  5945. LDREL ; 1 RELOCATABLE
  5946. LDSPC ; 2 SPECIAL
  5947. LDPRC ; 3 PURIFIABLE CALL
  5948. LDQAT ; 4 QUOTED ATOM
  5949. LDQLS ; 5 QUOTED LIST
  5950. LDGLB ; 6 GLOBALSYM PATCH
  5951. LDGET ; 7 GET DDT SYMBOL PATCH
  5952. LDAREF ; 10 ARRAY REFERENCE
  5953. LDPEN ; 11 PUT ENTRY POINT
  5954. LDATM ; 12 ATOMTABLE ENTRY
  5955. LDENT ; 13 ENTRY POINT INFO
  5956. LDLOC ; 14 LOC TO ANOTHER PLACE
  5957. LDPUT ; 15 PUT DDT SYMBOL
  5958. LDEVAL ; 16 EVALUATE MUNGEABLE
  5959. LDBEND ; 17 END OF BINARY
  5960. LDBIN2: JSP T,LDGTWD ;GET WORD OF RELOCATION BYTES
  5961. MOVEM TT,LDBYTS
  5962. SOJA AR4,LDBIN1 ;INIT BYTE POINTER AND GO GET DATA WORD
  5963. PAGE
  5964. LDSPC: MOVE T,TT ;[SPECIAL]
  5965. MOVE A,@LDAPTR
  5966. HLR TT,A ;GET ADDRESS OF SPECIAL CELL
  5967. TRNE TT,777000 ;WAS SUCH AN ADDRESS REALLY THERE?
  5968. JRST LDABS ; YES, WIN
  5969. TRNE TT,6 ; NO, IS THIS ATOM A NUMBER?
  5970. JSP D,LDFERR ; YES - LOSE!!!
  5971. TRZE TT,20 ;IS IT NON INTERNED ID ?
  5972. PCALL %GCPRO ;YES. PROTECT IT
  5973. MOVE TT,T
  5974. HRRZ A,@LDAPTR
  5975. SKIPN A
  5976. JSP D,LDFERR ;NO, LOSE IF NIL...ELSE
  5977. PCALL BIND1 ;GET VALUE CELL
  5978. MOVE TT,T
  5979. HRLM A,@LDAPTR ;SAVE VC ADDR IN ATOMTABLE (LH).
  5980. HRR TT,A ;AT LAST WE WIN
  5981. JRST LDABS
  5982. LDQAT: MOVE D,@LDAPTR ;[QUOTED ATOM]
  5983. TLNN D,777001 ;SKIP IF SPECIAL OR ALREADY USED
  5984. TLO D,1 ;ELSE TURN ON REFERENCE BIT
  5985. MOVEM D,@LDAPTR
  5986. HRRI TT,(D) ;GET ADDRESS OF ATOM
  5987. JRST LDABS
  5988. LDGLB: JSP D,LDFERR
  5989. REPEAT 0,<
  5990. SKIPL TT ;[GLOBALSYM PATCH]
  5991. SKIPA TT,LSYMS(TT) ;GET VALUE OF GLOBAL SYMBOL
  5992. MOVN TT,LSYMS(TT) ;OR MAYBE NEGATIVE THEREOF
  5993. ADD TT,-1(R) ;ADD TO ADDRESS FIELD OF
  5994. HRRM TT,-1(R) ; LAST WORD LOADED
  5995. JRST LDBIN
  5996. >
  5997. PAGE
  5998. LDQLS: MOVSI C,11 ;[QUOTED LIST]
  5999. PCALL LDLIST ;GOBBLE UP A LIST
  6000. JUMPE C,.+2
  6001. MOVEM TT,(R) ;PUT WORD IN BPS
  6002. PSAVE A
  6003. JSP T,LDGTWD ;GET HASH KEY FOR LIST
  6004. PREST A
  6005. PCALL %GCPRO ;PROTECT NEW LIST FROM GC.
  6006. JUMPE C,LDEVL7 ;IF -2, THIS LIST GOES INTO ATOMTABLE.
  6007. JRST LDABS1 ;OR -1, JUST INTO BPS.
  6008. LDLIS0: JSP T,LDGTWD
  6009. LDLIST: LDB T,[POINT 2,TT,2] ;[CONSTRUCT LIST]
  6010. JRST @LDLTBL(T)
  6011. LDLTBL: LDLATM ;ATOM
  6012. LDLLST ;LIST
  6013. LDLDLS ;DOTTED LIST
  6014. LDLEND ;END OF LIST
  6015. LDLATM: MOVE A,@LDAPTR
  6016. TLNN A,777011
  6017. IOR A,C
  6018. MOVEM A,@LDAPTR
  6019. PSAVE A
  6020. JRST LDLIS0
  6021. LDLLST: TDZA A,A
  6022. LDLDLS: PREST A
  6023. HRRZS TT
  6024. JUMPE TT,LDLLS3
  6025. LDLLS1: PREST B
  6026. PCALL XCONS
  6027. SOJG TT,LDLLS1
  6028. LDLLS3: PSAVE A
  6029. JRST LDLIS0
  6030. LDLEND: HLRZ C,TT
  6031. TRC C,777776 ;-1 to 1, -2 to 0.
  6032. TRNE C,777776 ;Any other?
  6033. JSP D,LDFERR ; is error.
  6034. PREST A
  6035. MOVSS TT
  6036. HRRI TT,(A)
  6037. PRET
  6038. PAGE
  6039. LDPRC: MOVE D,@LDAPTR ;[PURIFIABLE CALL]
  6040. TLNE D,777000
  6041. JRST LDPRC1 ;JUMP IF ATOM HAS SPECIAL CELL
  6042. TLNE D,6
  6043. JSP D,LDFERR ;LOSE IF NUMBER
  6044. TLO D,1 ;ELSE TURN ON REFERENCE BIT
  6045. MOVEM D,@LDAPTR
  6046. LDPRC1: TRNN D,-1 ;MUST HAVE NON-NIL ATOM TO CALL
  6047. JSP D,LDFERR
  6048. HRR TT,D ;PUT ADDRESS OF ATOM IN CALL
  6049. SKIPGE T,LDPRLS(P) ;SKIP FOR PURIFYING HACKERY
  6050. JRST LDABS ; Not active...DONE.
  6051. MOVEM TT,(R) ;Store the call-word,
  6052. HRRZ C,R ; and get its address...
  6053. JSP AR5,TRYSMSH ;NOW TRY TO SMASH IT
  6054. JRST LDABS1 ;SMASHED
  6055. HRLI A,(R) ;NOT SMASHED ...
  6056. HRR A,LDPRLS(P) ; APPEND ADDR TO PURE LIST
  6057. PCALL DCONSA ; TO RE-TRY AT LDFEND.
  6058. MOVEM A,LDPRLS(P)
  6059. JRST LDABS1
  6060. IFN 0,<
  6061. LDSMSH: LDB T,[POINT 9,(AR5),8]
  6062. CAIL T,34 ;CALL
  6063. CAILE T,35 ;JCALL
  6064. PRET
  6065. HRRZ A,(AR5) ;Pntr to atomhead.
  6066. PCALL GETD ;TRY TO GET EXPR, FEXPR PROP
  6067. LDB D,[POINT 4,(AR5),12] ;Destroys A,B,C,T,TT
  6068. JUMPE A,CPOPJ1 ;Can't be smashed since undefined yet.
  6069. CARA B,(A)
  6070. MOVE T,APOPJ1
  6071. FOO CAIN B,EXPR
  6072. MOVE T,[CAILE D,NSUA]
  6073. FOO CAIN B,FEXPR
  6074. MOVE T,[CAIE D,17]
  6075. XCT T
  6076. APOPJ1: JRST CPOPJ1 ;Don't smash if wrong # args wanted.
  6077. CDRA A,(A) ;ELSE WIN - SMASH THE CALL
  6078. CARA TT,(A)
  6079. CAIE TT,ID
  6080. CAIGE TT,CODMIN
  6081. JRST CPOPJ1
  6082. CDRA A,(A)
  6083. MOVE TT,(AR5)
  6084. MOVSI T,(PCALL) ;FCALL BECOMES PCALL
  6085. TLNE TT,1000
  6086. MOVSI T,(JRST) ;JCALL BECOMES JRST
  6087. IOR T,A
  6088. MOVEM T,(AR5) ;***SMASH!***
  6089. PRET > ;End of IFN 0
  6090. PAGE
  6091. LDGET: JSP D,LDFERR
  6092. REPEAT 0,<
  6093. CAMN TT,XC-1
  6094. JRST LDLHRL
  6095. MOVE D,TT ;[GET DDT SYMBOL PATCH]
  6096. TLNN D,200000 ;MAYBE THE ASSEMBLER LEFT US A VALUE?
  6097. JRST LDGET2
  6098. JSP T,LDGTWD ;FETCH IT THEN
  6099. SKIPE LDF2DP
  6100. JRST LDGET2 ;CAN'T USE IT IF VERSIONS DIFFER
  6101. LDGET1: TLNE D,400000 ;MAYBE NEGATE SYMBOL?
  6102. MOVNS TT
  6103. LDB D,[400200,,D] ;GET FIELD NUMBER
  6104. XCT LDXCT(D) ;HASH UP VALUE FOR FIELD
  6105. MOVE T,LDMASK(D) ;ADD INTO FIELD
  6106. ADD TT,-1(R) ; MASKED APPROPRIATELY
  6107. AND TT,T
  6108. ANDCAM T,-1(R)
  6109. IORM TT,-1(R)
  6110. JRST LDBIN
  6111. LDGET2: PSAVE . ;RANDOM P SLOT
  6112. PSAVE AR4 ;SAVE UP ACS
  6113. PSAVE D
  6114. PSAVE R
  6115. PSAVE F
  6116. MOVEI R,0
  6117. TLZ D,740000
  6118. CAME D,LAPFIV(R) ;IF DDTSYM REQUEST IS FOR A GLOBAL SYM
  6119. JRST LDGT5A ;THEN FIND IT IN THE LAPFIV TABLE, AND GET ITS
  6120. LSHC R,-2 ;GLOBALSYM INDEX FROM THE PERMUTATION TABLE
  6121. LSH F,-42
  6122. LDB TT,LDGET6(F)
  6123. MOVE TT,LSYMS(TT)
  6124. JRST LDGT5B
  6125. LDGT5A: MOVEI TT,R70
  6126. CAMN D,[SQUOZE 0,R70]
  6127. JRST LDGT5B
  6128. PCALL UNSQOZ ;CONVERT SQUOZE TO A LISP SYMBOL
  6129. MOVEI C,(A)
  6130. MOVEI B,QSYM ;TRY TO FIND SYM PROPERTY
  6131. PCALL GET
  6132. JUMPN A,LDGETJ ;WIN
  6133. SKIPN JOBSYM
  6134. JRST LDGETX
  6135. LDB D,[004000,,-2(P)]
  6136. LDGET4: MOVE TT,D
  6137. IDIVI D,50
  6138. JUMPE R,LDGET4
  6139. PCALL GETDD0
  6140. JRST LDGETX
  6141. PAGE
  6142. LDGT5B: MOVEM TT,-4(P) ;WIN, WIN - USE RANDOM P SLOT
  6143. MOVEI A,-4(P) ; TO FAKE UP A FIXNUM
  6144. JRST LDGETJ
  6145. LDGETX: MOVEI A,(C)
  6146. PCALL NCONS
  6147. MOVEI B,QGETDDTSYM ;DO A FAIL-ACT
  6148. PCALL XCONS
  6149. PCALL LDGETQ
  6150. LDGETJ: PREST F ;RESTORE ACS
  6151. PREST R
  6152. PREST D
  6153. PREST AR4
  6154. MOVE TT,(A)
  6155. PCALL TYPEP ;FIGURE OUT WHAT WE GOT BACK
  6156. PREST -1(P) ;POP RANDOM SLOT (REMEMBER THE LOCKI!)
  6157. CAIN A,FIXNU
  6158. JRST LDGET1
  6159. LDGETV: CAIN A,FLONU ;USE A FLONUM IF WE GET ONE
  6160. JRST LDGET1
  6161. LDGETW: SKIPE TT,JOBSYM
  6162. MOVSI TT,1
  6163. MOVEM TT,LDDDTP(P)
  6164. JRST LDGET2
  6165. LDGETQ:; FAC [CAN'T GET DDT SYMBOL - FASLOAD!]
  6166. LDGET6: REPEAT 4,<<11_^D24>+<<<3-.RPCNT>*11>_^D30> LAP5P(R)
  6167. >
  6168. LDXCT: MOVSS TT ;INDEX FIELD
  6169. HRRZS TT ;ADDRESS FIELD
  6170. LSH TT,^D23 ;AC FIELD
  6171. JFCL ;OPCODE FIELD
  6172. LDMASK: -1 ;INDEX FIELD
  6173. 0,,-1 ;ADDRESS FIELD
  6174. 0 17, ;AC FIELD
  6175. -1 ;OPCODE FIELD
  6176. LDLHRL: HRLZ TT,LDOFST
  6177. ADDM TT,-1(R)
  6178. JRST LDBIN
  6179. >
  6180. PAGE
  6181. LDAREF: JSP D,LDFERR
  6182. REPEAT 0,<
  6183. PSAVE TT ;[ARRAY REFERENCE]
  6184. MOVE D,@LDAPTR
  6185. TLNN D,777001
  6186. TLO D,11
  6187. MOVEM D,@LDAPTR
  6188. MOVEI A,(D)
  6189. PCALL TTSR+1 ;NCALL TO TTSR
  6190. HLL TT,(P)
  6191. PXDROP R70+1
  6192. JRST LDABS
  6193. >
  6194. LDATM: LDB T,[POINT 3,TT,3] ;[ATOMTABLE ENTRY]
  6195. JRST @LDATBL(T)
  6196. LDATBL: LDATPN ;INTERNED ID
  6197. LDATPI ;NON INTERNED ID
  6198. LDATPS ;STRING
  6199. LDATFX ;FIXNUM
  6200. LDATFL ;FLONUM
  6201. LDATBP ;POSNUM (POSITIVE BIGNUM)
  6202. LDATBN ;NEGNUM (NEGATIVE BIGNUM)
  6203. LDAREF ;TO GET ERROR
  6204. LDATPB: MOVSI C,(TT)
  6205. MOVN C,C
  6206. HRRI C,0(SP)
  6207. JSP T,LDGTWD
  6208. MOVEM TT,1(C)
  6209. AOBJN C,LDGTWD ; T still has return address
  6210. PRET
  6211. LDATPN: PCALL LDATPB ;[ATOMTABLE INTERNED ID ENTRY]
  6212. PCALL INTER0
  6213. LDATP8: MOVE TT,LDAAOB
  6214. MOVEM A,@LDAPTR
  6215. AOBJP TT,LDAEXT
  6216. MOVEM TT,LDAAOB
  6217. JRST LDBIN
  6218. LDATPI: PCALL LDATPB ;[ATOMTABLE NON INTERNED ID ENTRY]
  6219. PCALL NOINTR
  6220. TLO A,20 ;Mark for saving
  6221. JRST LDATB2
  6222. PAGE
  6223. LDATPS: PCALL LDATPB ;[ATOMTABLE STRING ENTRY]
  6224. PCALL MSTR1
  6225. JRST LDATB2
  6226. LDATFX: JSP T,LDGTWD ;[ATOMTABLE FIXNUM ENTRY]
  6227. PCALL FIX1A
  6228. CAILE A,INUMIN
  6229. TLOA A,12 ;INUM -- doesn't need GC pro.
  6230. TLO A,2
  6231. JRST LDATP8
  6232. LDATFL: JSP T,LDGTWD ;[ATOMTABLE FLONUM ENTRY]
  6233. PCALL FLO1A
  6234. TLO A,4
  6235. JRST LDATP8
  6236. LDATBN: SKIPA C,[NEGNU] ;[ATOMTABLE NEGNUM ENTRY]
  6237. LDATBP: MOVEI C,POSNU ;[ATOMTABLE POSNUM ENTRY]
  6238. PSAVE C
  6239. MOVEI C,(TT)
  6240. MOVEI B,NIL
  6241. LDATB1: JSP T,LDGTWD
  6242. PCALL FWCONS
  6243. PCALL CONS
  6244. MOVE B,A
  6245. SOJG C,LDGTWD ;T STILL HAS RETURN ADDRESS
  6246. PREST B
  6247. PCALL XCONS
  6248. LDATB2: TLO A,6
  6249. JRST LDATP8
  6250. LDAEXT: MOVEI T,FTFULL
  6251. JRST LDERRT
  6252. REPEAT 0,<
  6253. MOVM T,LDGROW ;[ATOMTABLE EXTEND]
  6254. MOVNS T
  6255. HRL TT,T
  6256. MOVEM TT,LDAAOB ; Another page or so.
  6257. MOVS TT,@LDAGCM
  6258. ADD TT,T ; and protect the extension.
  6259. MOVSM TT,@LDAGCM
  6260. JRST LDBIN
  6261. >
  6262. PAGE
  6263. LDENT: PCALL LDEPIN ;[ENTRY POINT INFO]
  6264. FOO SKIPN VPREDEF
  6265. JRST LDNRDF
  6266. MOVE A,-1(P)
  6267. PCALL GETD
  6268. JUMPE A,LDNRDF
  6269. MOVE A,-1(P)
  6270. PSAVE R
  6271. PSAVE AR4
  6272. PCALL WHEAD
  6273. PCALL PRIN1
  6274. STRTIP [SIXBIT / REDEFINED!/]
  6275. PCALL TOURET
  6276. PREST AR4
  6277. PREST R
  6278. LDNRDF: PREST B
  6279. PREST C
  6280. PREST A
  6281. FOO CAIE B,SUBR
  6282. JRST .+3
  6283. FOO MOVEI B,EXPR
  6284. JRST .+4
  6285. FOO CAIE B,FSUBR
  6286. JRST .+3
  6287. FOO MOVEI B,FEXPR
  6288. SETOM FFFSUB
  6289. PCALL IPUTD ;USES T,TT
  6290. JRST LDBIN
  6291. LDPEN: PCALL LDEPIN ;[PUT ENTRY POINT]
  6292. PREST B
  6293. PREST A
  6294. PREST C
  6295. PCALL PUT
  6296. JRST LDBIN
  6297. LDEPIN: HRRZ C,@LDAPTR ;[ENTRY POINT INFO]
  6298. MOVSS TT
  6299. HRRZ A,@LDAPTR
  6300. PSAVE A ;ENTRY NAME.
  6301. PSAVE C ;SUBR TYPE.
  6302. JSP T,LDGTWD ;TT_<ARGS,,ENTRY-RELOC>...
  6303. MOVEI A,@LDOFST
  6304. CAILE A,(R)
  6305. JSP D,LDFERR
  6306. PCALL IMKCODE
  6307. EXCH A,-2(P)
  6308. JRST (A)
  6309. PAGE
  6310. LDLOC: JSP D,LDFERR
  6311. REPEAT 0,<
  6312. MOVEI TT,@LDOFST
  6313. MOVEI D,(R)
  6314. CAMLE D,LDHLOC
  6315. MOVEM D,LDHLOC
  6316. CAMG TT,LDHLOC
  6317. JRST LDLOC5
  6318. MOVE D,LDHLOC
  6319. SUBI D,(R)
  6320. MOVSI D,(D)
  6321. ADD R,D
  6322. HRR R,LDHLOC
  6323. SETZ TT,
  6324. ADD AR4,[040000,,]
  6325. JRST LDABS
  6326. LDLOC5: HRRZ D,LDOFST
  6327. CAIGE TT,(D)
  6328. JSP D,LDFERR
  6329. MOVEI D,(TT)
  6330. SUBI D,(R)
  6331. MOVSI D,(D)
  6332. ADD R,D
  6333. HRRI R,(TT)
  6334. JRST LDBIN >
  6335. PAGE
  6336. LDPUT: JSP D,LDFERR
  6337. REPEAT 0,<
  6338. SKIPN A,V$SYMBOLS ;[PUT DDT SYMBOLS]
  6339. JRST LDPUT3
  6340. CAIE A,SYMBOLS
  6341. JRST LDPUT7
  6342. TLNN TT,40000
  6343. JRST LDPUT3
  6344. LDPUT7: SKIPN JOBSYM
  6345. JRST LDPUT3
  6346. PSAVE AR4
  6347. JUMPL TT,LDPUT2
  6348. MOVE D,R
  6349. LDPUT0: PSAVE D
  6350. PSAVE F
  6351. TLZ TT,740000
  6352. LDPUT1: MOVE T,TT
  6353. IDIVI TT,50
  6354. JUMPE D,LDPUT1
  6355. MOVEI B,-1(P)
  6356. MOVSI R,400000
  6357. PCALL PUTDD0
  6358. JRST LDRSTX
  6359. LDPUT2: MOVE D,TT
  6360. JSP T,LDGTWD
  6361. EXCH TT,D
  6362. TLNN TT,100000
  6363. JRST LDPT2A
  6364. MOVE T,LDOFST
  6365. ADD T,D
  6366. HRRM T,D
  6367. LDPT2A: TLNN TT,200000
  6368. JRST LDPUT0
  6369. HRLZ T,LDOFST
  6370. ADD D,T
  6371. JRST LDPUT0
  6372. LDPUT3: JUMPGE TT,LDBIN ;DON'T WANT TO PUT DDT SYM, BUT
  6373. JSP T,LDGTWD ; MAYBE NEED TO FLUSH EXTRA WORD
  6374. JRST LDBIN
  6375. >
  6376. PAGE
  6377. LDEVAL: SETZ C, ;[EVALUATE MUNGEABLE]
  6378. PCALL LDLIST
  6379. PSAVE A
  6380. PSAVE C
  6381. PSAVE AR4
  6382. PSAVE R
  6383. MOVEI A,(R)
  6384. PCALL FIX1A
  6385. FOO MOVEM A,VBPORG ;Permit the mungeable to alter BPORG.
  6386. SKIPL A,LDPRLS-4(P)
  6387. FOO HRRZM A,VP.URCLOBRL ;Save us in case of ERR.
  6388. MOVE A,-3(P)
  6389. PCALL EVAL
  6390. EXCH A,-3(P) ;Save value, retrieve S-expr.
  6391. PSAVE A
  6392. FOO CDRA A,VP.URCLOBRL
  6393. HRRM A,LDPRLS-5(P)
  6394. FOO MOVE A,VBPORG
  6395. PCALL NUMVAL
  6396. PREST B
  6397. PREST R
  6398. SUBI A,(R) ;If BPORG unchanged,
  6399. JUMPE A,LDEVL5 ; then leave R & FARRAY alone.
  6400. JUMPLE A,LDEVL4 ; If lowered, keep R, just fix FARRAY.
  6401. ADDM A,LDOFST ;Hence can't do future LDLOC **********
  6402. HRLI A,(A)
  6403. ADD R,A ;Else decrease space-avail left.
  6404. LDEVL4:
  6405. FOO MOVE A,VFARRY ;Save S-exprs which change BPORG.
  6406. PCALL XCONS
  6407. FOO HRRZM A,VFARRY
  6408. LDEVL5: PREST AR4
  6409. PREST C
  6410. PREST A
  6411. JUMPN C,LDBIN ;IF -1, THROW AWAY VALUE;
  6412. PCALL %GCPRO ;OR -2, PROTECT & ENTER IN ATOMTABLE.
  6413. LDEVL7: TLO A,16 ;FROM LDQLS, IS ALREADY PROTECTED
  6414. JRST LDATP8
  6415. %GCPRO: HRRZ B,LDGPRO-1(P)
  6416. PCALL CONS
  6417. HRRM A,LDGPRO-1(P)
  6418. CARA A,(A) ;RETURN WHAT WE JUST APPENDED.
  6419. PRET
  6420. PAGE
  6421. LDBEND: CAME TT,[ASCII \FASLP\] ;[END OF BINARY]
  6422. JSP D,LDFERR
  6423. AOS LDEOFJ ;Now have seen End-of-Data in a file...
  6424. ; Update BPS bounds and protect atoms
  6425. ; from GC, then try for next file.
  6426. LDFEND: ;[END OF FILE]
  6427. HRRZ A,R
  6428. CAMGE A,LDHLOC
  6429. MOVE A,LDHLOC
  6430. PCALL FIX1A
  6431. FOO MOVEM A,VBPORG ;UPDATE BPORG
  6432. HRRZ R,LDAAOB
  6433. LDGCPR: SOJLE R,LDSDPL ;[GC PROTECT AS YET UNPROTECTED ATOMS]
  6434. MOVEI TT,(R)
  6435. MOVE AR5,@LDAPTR
  6436. HRRZ A,AR5
  6437. TLNN AR5,777010 ;IF VALUE-CELL OR ALREADY PROTECTED,
  6438. TLNN AR5,1 ;OR NO NEED (NEVER REF'D),
  6439. JRST LDGCPR ; PASS BY.
  6440. TLNE AR5,26
  6441. JRST LDGCP1 ;FIX,FLO,BIG,string or non-interned id
  6442. JRST LDGCPR
  6443. LDGCP1: HRRZ A,AR5
  6444. PCALL %GCPRO
  6445. JRST LDGCPR
  6446. LDSDPL: SKIPGE TT,LDPRLS(P) ;[RE-TRY SMASHING DOWN PURE LIST]
  6447. JRST LDEOMM
  6448. FOO MOVEM TT,VP.URCLOBRL ;Following retains locs unsmashed.
  6449. FOO MOVEI R,VP.URCLOBRL
  6450. LDSDP1: SKIPN TT,LDPRLS(P)
  6451. JRST LDEOMM
  6452. LDSDP2: CDRA T,(TT)
  6453. MOVEM T,LDPRLS(P)
  6454. CARA C,(TT)
  6455. JSP AR5,TRYSMSH
  6456. JRST LDSDP3
  6457. CDRA R,(R)
  6458. JRST LDSDP1
  6459. LDSDP3: MOVE TT,LDPRLS(P)
  6460. RPLCD TT,(R)
  6461. JRST LDSDP1
  6462. PAGE
  6463. LDEOMM: SKIPN A,LDGPRO(P) ;Have processed a FASL file completely,
  6464. JRST LDFNIL
  6465. FOO MOVE B,VF.LIST ; and protected internal Lisp node refs
  6466. PCALL CONS ; off the PDL with this final save.
  6467. FOO MOVEM A,VF.LIST
  6468. LDFNIL: MOVE A,LDAGCM
  6469. MOVE A,(A) ;Now clear array (so won't be SSAVEd),
  6470. SETZM 0(A) ; and read til true EOF does ERR $EOF$
  6471. AOBJN A,.-1 ; or see start of next FASL in series.
  6472. ;However, doesn't clear access routine.
  6473. SETOM LDEOFJ ;EOF will be okay, or start of next file.
  6474. JRST LDMORE ;Continue, with the extra PDL cells.
  6475. LDGTWD: PCALL TYID ;This is BINI w/o Lisp # conversion...
  6476. MOVE TT,A ; so inputting a 36-bit word or $EOF$.
  6477. JRST 0(T)
  6478. FASLNC: MOVEI T,BPFULL
  6479. JRST LDERRT
  6480. LDFERR: SKIPGE T,LDEOFJ ;Externally invoked after any ERRSET.
  6481. JRST LDFSUB ; OK - return after proper EOF.
  6482. MOVE T,LDEOFJ
  6483. LDERRT: MOVEI A,LDERRN ;Change...
  6484. MOVEM A,LDEOFJ ; Avoid doubly-printed LERRs.
  6485. CAILE T,LDERRN
  6486. ERRL1 ^D149,[SIXBIT \FASLOAD BUG!\]
  6487. JRST .+1(T) ;Else dispatch to the various errs...
  6488. LDERR0: ERRL1 ^D150,[SIXBIT \FASLOAD EMPTY FILE!\]
  6489. ERRL1 ^D151,[SIXBIT \FASLOAD FORMAT ERR!\]
  6490. ERRL1 ^D152,[SIXBIT \FASLOAD GC-PRO ERR!\]
  6491. ERRL1 ^D153,[SIXBIT \FASLOAD EXCEEDS BPS!\]
  6492. ERRL1 ^D154,[SIXBIT \FISLTABLE FULL!\]
  6493. LDERRN==.-LDERR0
  6494. ERRL1 ^D155,[SIXBIT \NOGO!\]
  6495. LDFSUB: SKIPN FFFSUB
  6496. PRET
  6497. SETZM FFFSUB
  6498. FOO SKIPE %MSG
  6499. STRTIP [SIXBIT /_*** (F)SUBR CONVERTED TO (F)EXPR_!/]
  6500. PRET
  6501. > ;End of IFN OFLD
  6502. IFN OFLD!NFLD,<
  6503. ;Try convert slow link to fast link
  6504. TRYSMSH:HRRZ A,(C) ;right half of instruction
  6505. HLRZ T,(C) ;left half
  6506. CAIL T,(FCALL) ;is it FCALL or
  6507. CAILE T,777(JCALL) ; JCALL
  6508. JRST (AR5) ;No! Treat as sucessful, i.e. never smash
  6509. PCALL GETD ;get function definition
  6510. JUMPE A,1(AR5) ; unsucessful if wasn't there
  6511. MOVSI TT,(PCALL) ; replacement FCALL - PCALL
  6512. TRNE T,1000
  6513. MOVSI TT,(JRST) ; JCALL - JRST
  6514. ANDI T,740 ;Now check EXPR - FEXPR
  6515. FOO MOVEI D,EXPR
  6516. CAIN T,740
  6517. FOO MOVEI D,FEXPR ;argcount 17 means call a FEXPR
  6518. CARA B,(A) ;get function type
  6519. CAIE B,(D) ;is it right type for the call?
  6520. JRST 1(AR5) ;No! unsucessful
  6521. CDRA A,(A) ;code part
  6522. CARA D,(A) ;check tag
  6523. CAIE D,ID
  6524. CAIGE D,CODMIN
  6525. JRST 1(AR5) ;not a code pointer! unsucessful
  6526. HRR TT,(A) ;get code address into new instruction
  6527. MOVEM TT,(C) ;change instruction
  6528. JRST (AR5) ;sucessful
  6529. > ;End of IFN OFLD!NFLD
  6530. IFN NFLD,<
  6531. ;New version of FASLOD
  6532. FASLOAD:PSAVE [0] ;internal F.LIST
  6533. HRRM P,LDQLIS ;save its pointer
  6534. FOO SKIPE VPURIFY ;want to try converting slow links to fast?
  6535. TDZA B,B ;yes
  6536. SETO B, ;no! make negative to indicate that
  6537. PSAVE B ;internal P.URCLOBRL
  6538. HRRM P,LDPURC ;save its pointer
  6539. MOVEM P,LDSTCK# ;save for stack check at end
  6540. JSP D,ATMTYP ;check F.ISLTABLE
  6541. CAIE TT,VECT ;is it a vector?
  6542. ERRL2 ^D168,[SIXBIT /NO TABLE FOR FASL!/] ;no! error
  6543. CDRA A,(A) ;get its base address
  6544. SETZM (A) ;first element is NIL
  6545. HRRM A,CTOPAT ;current top of table
  6546. HRRM A,LDATBAS ;base of table
  6547. JSP T,RSTBPO ;set internal BPORG and BPEND
  6548. SETZM CALHLF ;indicate need new word in half word buffer
  6549. MOVEI D,LDLOP+1 ;return address for LDBYT
  6550. LDNWD: PCALL TYID ;byte buffer is empty. get new word
  6551. MOVEM A,LDBTWD ;save word in buffer
  6552. MOVE A,[POINT 6,LDBTWD] ;get byte pointer
  6553. MOVEM A,LDBTPO# ;save it
  6554. LDBYT: ILDB A,LDBTPO ;get a byte
  6555. JUMPN A,(D) ;not 0 means not empty buffer
  6556. HRRZ TT,LDBTPO ;buffer might be empty
  6557. CAIN TT,LDBTWD ;does pointer still point to buffer?
  6558. JRST (D) ;yes! 0 byte
  6559. JRST LDNWD ;no! buffer empty
  6560. LDID: JSP D,LDHLF ;Get length of id
  6561. PCALL %FSLID+1 ;make interned id
  6562. LDPUTA: AOS .+1 ;update top of table
  6563. CTOPAT: MOVEM A,X ;move object into table
  6564. ;this is the loader loop
  6565. LDLOP: JSP D,LDBYT ;get new loader code byte
  6566. CAIG A,LDBTMX ;is it a legal code
  6567. JRST @LDJTAB(A) ;Yes! Dispatch
  6568. ERRL2 ^D169,[SIXBIT /FASL FORMAT ERROR!/] ;No! Error
  6569. LDJTAB: LDEND
  6570. LDID
  6571. LDGENSYM
  6572. LDSTRNG
  6573. LDPOSN
  6574. LDNEGN
  6575. LDFIXN
  6576. LDFLON
  6577. LDQUO
  6578. LDCAL
  6579. LDRLO
  6580. LDAXCON
  6581. LDXCON
  6582. LDOFFSET
  6583. LDENTRY
  6584. LDXPR
  6585. LDLAPBLOCK
  6586. LDNCON
  6587. LDPUTV
  6588. LDMKVCT
  6589. .LDABS
  6590. LDPUSH
  6591. .LDEVAL
  6592. LDFLUID
  6593. LDSYM
  6594. LDEVID
  6595. LDSETQ
  6596. LDIPUT
  6597. .LDPUT
  6598. LDIPTD
  6599. LDPUTD
  6600. LDNUMP
  6601. LDXPRS
  6602. LDPOP
  6603. LDEVIX
  6604. .LDLIST
  6605. LDPOPN
  6606. LDPROTECT
  6607. LDBTMX==.-LDJTAB-1
  6608. LDGENSYM: ;make non interned id
  6609. FOO MOVEI C,PNAME
  6610. PCALL MKFWLIS ;make print name list
  6611. PCALL IDCONS-1 ;make into id
  6612. JRST LDPUTA ;put into table
  6613. LDPOSN: SKIPA C,CPOSNU ;positive bignum
  6614. LDNEGN: MOVEI C,NEGNU ;negative bignum
  6615. JRST LDSTRNG+1
  6616. LDSTRNG:MOVEI C,STRNG ;string
  6617. PCALL MKFWLIS ;read and make full word list
  6618. JRST LDPUTA ;put into table
  6619. MKFWLIS:JSP D,LDHLF ;read length of list
  6620. MOVE TT,A ;save count
  6621. SKIPA B,[0] ;start with NIL
  6622. MOVE B,A ;current list
  6623. PCALL TYID ;read a word
  6624. PCALL BCONS ;cons into list
  6625. SOJG TT,.-3 ;go back for more
  6626. HRL A,C ;get tag
  6627. JRST DCONSA ;cons it
  6628. LDFIXN: PCALL BINI ;read a fixnum
  6629. JRST LDPUTA ;put into table
  6630. LDFLON: PCALL TYID ;read a word
  6631. PCALL FLO1A ;tag as floating point number
  6632. JRST LDPUTA ;put into table
  6633. LDMKVCT:JSP T,SAVBPO ;allow BPORG to be changed
  6634. JSP D,LDHLF ;get uplim for vector
  6635. PCALL MKVECT+1 ;make vector
  6636. HRRZ C,(A) ;vector address
  6637. HRRM C,CLIPTV ;update "current vector base"
  6638. MOVE C,A
  6639. JSP T,RSTBPO ;update internal BPORG
  6640. MOVE A,C
  6641. JRST LDPUTA ;put vector into table
  6642. LDPUSH: MOVEI T,LDPU1 ;return address, push on stack
  6643. LGETVX: JSP D,LDHLF ;get table index
  6644. HRRZ A,@LDATBAS ;get element from table
  6645. JRST (T)
  6646. .LDABS: MOVEI D,LDPU1 ;push on stack
  6647. LDHLF: SETZ A,
  6648. EXCH A,CALHLF#
  6649. JUMPN A,.+3
  6650. PCALL TYID ;half word buffer empty. read new word
  6651. HLROM A,CALHLF ;save in buffer, -1 in lh make non-zero
  6652. MOVEI A,(A) ;get right half (get rid of -1)
  6653. JRST (D) ;return
  6654. LDAXCON:MOVEI D,.+3 ;make list ending with absolute
  6655. JRST LDHLF
  6656. LDXCON: JSP T,LGETVX ;make list ending with table element
  6657. SKIPA TT,A ;save table element in TT
  6658. LDNCON: SETZ TT, ;end with NIL (ordinary list)
  6659. JSP D,LDHLF ;length of list
  6660. EXCH A,TT ;get end into A
  6661. PREST B ;get element from stack
  6662. PCALL XCONS ;cons into list
  6663. SOJG TT,.-2 ;maybee more
  6664. LDPU1: PSAVE A ;save on stack
  6665. JRST LDLOP ;return to loop
  6666. ;execute EXPR, arguments are on stack. put result on stack
  6667. LDXPR: JSP T,LGETVX ;get function id from table
  6668. PSAVE A ;save it
  6669. LDXPRS: JSP T,SAVBPO ;function is on stack
  6670. JSP D,LDBYT ;number of args
  6671. PREST REL ;function
  6672. DPB A,[POINT 4,LDCALL,ACFLD] ;update call instruction
  6673. MOVN T,A
  6674. JSP TT,PDLARG ;put args into regs
  6675. LDCALL: CALLF X,(REL) ;call function
  6676. PSAVE A ;save result on stack
  6677. MOVEI T,LDLOP ;return address
  6678. RSTBPO: ;Update internal BPORG and BPEND as the might have been changed
  6679. FOO HRRZ A,VBPEND
  6680. PCALL NUMVAL
  6681. HRRM A,LDBPEN ;update internal BPEND
  6682. FOO HRRZ A,VBPORG
  6683. PCALL NUMVAL
  6684. HRRM A,LDBPOR ;update internal BPORG
  6685. JRST (T)
  6686. .LDEVAL:JSP T,SAVBPO
  6687. JSP T,LGETVX ;get fexpr id
  6688. PREST B ;argument list
  6689. PCALL CONS
  6690. PCALL EVAL ;evaluate fexpr
  6691. JRST LDCALL+1
  6692. LDPOP: P1DROP ;remove top of stack
  6693. JRST LDLOP
  6694. LDEVID: JSP T,LGETVX ;get id from table
  6695. PCALL EVAL ;get its value
  6696. JRST LDPU1 ;push it on stack
  6697. LDSETQ: JSP T,LGETVX ;get id from table
  6698. PCALL BIND1 ;get its value cell
  6699. PREST (A) ;update value cell from stack
  6700. JRST LDLOP
  6701. LDIPUT: JSP T,LGETVX ;get id from table
  6702. HRRM A,CLIPUT ;update "current property indicator"
  6703. JRST LDLOP
  6704. LDIPTD: JSP T,LGETVX
  6705. HRRM A,CLIPTD ;update "current function type"
  6706. JRST LDLOP
  6707. .LDPUT: JSP T,LGETVX
  6708. PREST C ;property value
  6709. CLIPUT: MOVEI B,X ;property indicator
  6710. PCALL PUT
  6711. JRST LDLOP
  6712. LDPUTD: JSP T,LGETVX
  6713. PSAVE A ;save function id
  6714. FOO MOVEI B,TRACE ;remove TRACE property
  6715. PCALL REMP1
  6716. FOO SKIPN VPREDEF ;want to warn for redefined function
  6717. JRST NOPRDF ;no!
  6718. MOVE A,(P) ;is function
  6719. PCALL GETD ; already defined
  6720. JUMPE A,NOPRDF
  6721. MOVE A,(P) ;yes!
  6722. PCALL WHEAD ;warning header
  6723. PCALL PRIN1 ;print function name
  6724. STRTIP [SIXBIT / REDEFINED!/]
  6725. PCALL TOURET ;return to current output
  6726. NOPRDF: PREST C ;function id
  6727. PREST A ;function body
  6728. CLIPTD: MOVEI B,X ;function type
  6729. PCALL IPUTD ;define it
  6730. JRST LDLOP
  6731. LDPUTV: JSP D,LDHLF ;get vector index
  6732. PREST C ;value to put into vector
  6733. SETZ B,
  6734. LSHC A,-1
  6735. JUMPN B,.+3 ;B = 0 means even index
  6736. CLIPTV: HRLM C,X(A) ;X is current vector base. updated by LDMKVCT
  6737. JRST LDLOP
  6738. HRRM C,@CLIPTV ;odd index. value goes into right half
  6739. JRST LDLOP
  6740. LDLAPBLOCK: ;load a block of code
  6741. JSP D,LDHLF ;no of words to load
  6742. LDBPORG:MOVEI R,X ;internal BPORG
  6743. MOVEI C,(R)
  6744. ADDI C,(A) ;new BPORG
  6745. LDBPEND:CAILE C,X ;compare with internal BPEND
  6746. JRST BINER2 ;error if bigger
  6747. HRRM C,LDBPOR ;update BPORG
  6748. HRRM R,LDRLBAS ;set block base addres for relocation
  6749. SOJ R,
  6750. HRRM R,LDRSTRT ;set patch address base
  6751. HLLZS MPAFUN ;no patch function seen
  6752. MOVNI C,(A) ;make
  6753. HRL R,C ; iowd
  6754. PCALL TYID ;read a word
  6755. MOVEM A,1(R) ;deposit in BPS
  6756. AOBJN R,.-2 ;maybee more
  6757. JRST LDLOP
  6758. MAPAT: MOVEI C,X ;old patch address
  6759. ADDI C,77
  6760. MOVEI T,(T) ;patching function
  6761. CAIE T,@MPAFUN ;same as old
  6762. LDRSTRT: MOVEI C,X ;no! use patch base address. set by LDLAPBLOCK
  6763. HRRM T,MPAFUN ;set current patch function
  6764. MPARET: JSP D,LDBYT ;Get relative patch address. Patch funs return here
  6765. JUMPE A,[HRRM C,MAPAT ;0 byte means save patch address
  6766. JRST LDLOP] ; and end patching
  6767. ADDI C,(A) ;update patch address
  6768. HRRZ A,(C) ;get index or address
  6769. MPAFUN: JRST X ;go patch
  6770. LDRLO: JSP T,MAPAT ;enter patch loop
  6771. LDRLBAS:ADDI A,X ;relocation base
  6772. HRRM A,(C) ;put into instruction
  6773. JRST MPARET ;return to patch loop
  6774. LDQUO: JSP T,MAPAT ;enter patch loop
  6775. HRRZ A,@LDATBAS ;get element from table
  6776. HRRM A,(C) ;put in instruction
  6777. JRST MPARET
  6778. LDCAL: JSP T,MAPAT ;enter patch loop
  6779. HRRZ A,@LDATBAS ;get table element
  6780. HRRM A,(C) ;put in instruction
  6781. LDPURC: SKIPL REL,X ;If iternal PURIFY switch is on
  6782. JSP AR5,TRYSMSH+1 ; try to convert slow link to fast
  6783. JRST MPARET ;did it or no PURIFY! return to patch loop
  6784. MOVE A,REL ;couldn't do it. get internal P.URCLOBRL
  6785. HRLI A,(C) ;cons instruction address
  6786. PCALL DCONSA ; into list
  6787. MOVEM A,@LDPURC ; and move into P.URCLOBRL
  6788. JRST MPARET ;return to loop
  6789. LDFLUID:JSP T,LGETVX ;get id from table
  6790. PCALL BIND1 ;get its value cell
  6791. JRST LDPUTA ;put it into table
  6792. LDEVIX: MOVE A,(P) ;top of stack
  6793. JSP D,NATMTYP ;check if it needs to be gc-protected
  6794. JRST LDEPRO ;not atom! needs protection
  6795. JUMPE TT,.LDLIST ;INUM doesn't need potection
  6796. CAIE TT,ID ;is an id?
  6797. JRST LDEPRO ;no! protect
  6798. PCALL .INTERNP ;is it interned
  6799. JUMPN A,.LDLIST ;if yes, don't protect
  6800. MOVE A,(P) ;get top of stack
  6801. LDEPRO: CDRA B,@LDQLIS ;internal F.LIST
  6802. PCALL CONS
  6803. HRRM A,@LDQLIS ;update internal F.LIST
  6804. .LDLIST:PREST A ;take top of stack
  6805. JRST LDPUTA ;put it into table
  6806. LDSYM: JSP T,LGETVX ;get id from table
  6807. MOVE T,A ;save in case of error
  6808. FOO MOVEI B,SYM ;get SYM
  6809. PCALL GET ; property
  6810. JUMPE A,[MOVE A,T ;if none
  6811. ERRE2 ^D38,[SIXBIT / IS NOT A SYM!/]] ;error
  6812. PCALL NUMVAL ;get address
  6813. JRST LDPUTA ;put into table
  6814. LDOFFSET:
  6815. JSP T,LGETVX ;get address from table
  6816. MOVE T,A ;save it
  6817. JSP D,LDHLF ;get offset
  6818. ADDI A,(T) ;update address
  6819. JRST LDPUTA ;put it into table
  6820. LDNUMP: JSP T,LGETVX ;get object from table
  6821. PCALL FIX1A ;convert to number
  6822. JRST LDPU1 ;put on stack
  6823. LDPOPN: PREST A ;get top of stack
  6824. PCALL NUMVAL ;convert to address
  6825. JRST LDPUTA ;put into table
  6826. LDPROTECT: ;protect objects by consing them into internal F.LIST
  6827. LDQLIS: CDRA B,X ;get internal F.LIST
  6828. JRST .+3 ;enter loop
  6829. PCALL CONS ;cons object into list
  6830. MOVE B,A ;save list
  6831. JSP T,LGETVX ;get new object
  6832. JUMPN A,.-3 ;if not NIL go back
  6833. HRRM B,@LDQLIS ;update internal F.LIST
  6834. JRST LDLOP
  6835. LDENTRY:HRRZ C,LDRLBAS ;get start of lap block
  6836. JSP D,LDHLF ;get relative address
  6837. ADDI C,(A) ;get real address
  6838. JSP D,LDBYT ;no of args
  6839. EXCH A,C
  6840. PCALL IMKCODE ;make code pointer
  6841. JRST LDPU1 ;push on stack
  6842. LDEND: CAME P,LDSTCK ;end of loading. check stack consistency
  6843. ERRL2 ^D170,[SIXBIT /FASL STACK OUT OF SYNC!/]
  6844. PREST B ;internal P.URCLOBRL
  6845. JUMPL B,NOPURC ;negative if PURIFY is off
  6846. FOO MOVEI A,VP.URCLOB
  6847. PCALL NCONC ;concatenate to P.URCLOBRL
  6848. MOVE REL,A ;try smash instructions on list
  6849. CDRA AR4,(REL)
  6850. JRST SMSHLE ;enter loop
  6851. SMSHLP: CARA C,(AR4) ;get instruction address
  6852. JSP AR5,TRYSMSH ;try smash instruction
  6853. JRST .+2 ;Smashed!
  6854. MOVE REL,AR4 ;Not smashed! keep address in list
  6855. CDRA AR4,(AR4) ;next element
  6856. HRRM AR4,(REL) ;this will remove address of smashed instruction
  6857. SMSHLE: JUMPN AR4,SMSHLP ;if more go back
  6858. NOPURC: PREST B ;internal F.LIST
  6859. FOO HRRZ A,VF.LIST ;F.LIST
  6860. PCALL XCONS ;save internal F.LIST on F.LIST
  6861. FOO HRRM A,VF.LIST ;update F.LIST
  6862. MOVEI T,CPOPJ ;return address
  6863. SAVBPO: HRRZ A,LDBPEN
  6864. PCALL FIX1A
  6865. FOO HRRZM A,VBPEND
  6866. HRRZ A,LDBPOR
  6867. PCALL FIX1A
  6868. FOO HRRZM A,VBPORG ;Allow change of BPORG
  6869. JRST (T)
  6870. LDBTWD: X
  6871. LDATBAS:Z X(A) ;First six bits of this word must be 0 to make LDBYT correct
  6872. ;%FSLID is an EXPR that reads an id from a FSL file, it is used by
  6873. ; the PRELOAD device.
  6874. %FSLID: PCALL TYID ;Get length of id
  6875. MOVN C,A ;make
  6876. HRLZI C,(C) ;
  6877. HRRI C,(SP) ; iowd
  6878. PCALL TYID ;get a word
  6879. MOVEM A,1(C) ;put in buffer
  6880. AOBJN C,.-2 ;get more if not finished
  6881. JRST INTER0 ;intern it
  6882. > ;End of IFN NFLD
  6883. SUBTTL ALVINE AND LOADER INTERFACES --- PAGE 22
  6884. ;interface to alvine
  6885. IFN AED,<
  6886. ED: MOVEI REL,X ;Reset to EDP2 by: STRT, EXCISE, EXCORE.
  6887. JRST (REL)
  6888. EDP2: PSAVE A
  6889. HRRZ A,CORUSE
  6890. HRRM A,LST
  6891. AOS A
  6892. HRRM A,ED
  6893. MOVSI A,(SIXBIT /ED/)
  6894. PCALL SYSINI
  6895. HRLM A,LST
  6896. MOVNS A
  6897. PCALL MORCOR
  6898. PCALL SYSINQ
  6899. PREST A
  6900. JRST ED
  6901. GRINDEF:PSAVE A
  6902. PCALL ED
  6903. PREST A
  6904. JRST 2(REL)
  6905. > ;end of IFN AED
  6906. EXCISE: MOVE A,JRELO
  6907. IFN AED,<MOVEI B,EDP2
  6908. HRRM B,ED>
  6909. IFN ALOD,SETZM LDFLG ;initial loader symbol table flag
  6910. CALLI A,CORE
  6911. JRST .+1
  6912. JSR IOBRST
  6913. IFE HCBPS,PCALL CHKVBP ;Ensure BPORG and BPEND in low BPS.
  6914. JRST TRUE
  6915. PAGE
  6916. VAR
  6917. LIT
  6918. PAGE
  6919. ; lisp loader interface
  6920. IFN ALOD,<
  6921. LOAD: AOS B,CORUSE
  6922. MOVEM B,OLDCU#
  6923. MOVEM A,LDPAR#
  6924. JUMPE A,LOAD2 ;If NIL, @.JBREL+1
  6925. FOO MOVE A,VBPORG ; else into BPS @BPORG.
  6926. PCALL NUMVAL
  6927. MOVE B,A
  6928. LOAD2: MOVEM B,RVAL ;final destination of loaded code
  6929. MOVSI A,(SIXBIT /LOD/)
  6930. PCALL SYSINI
  6931. SUBI A,150 ;extra room for locations 0 to 137 and slop
  6932. MOVNS A ;length(loader) = 5400 approx.
  6933. HRRZM A,LODSIZ#
  6934. ADDI A,10 ;Space for start of symbol table etc.
  6935. PCALL MORCOR ;expand core for loader
  6936. MOVEM A,LOWLSP# ;location of blt'ed low lisp
  6937. MOVE B,LODSIZ
  6938. ADD B,A
  6939. MOVEM B,HVAL ;temporary destination of loaded code
  6940. HRLI A,0 ;<0,,LOWLSP> -- HVAL.
  6941. BLT A,(B) ;blt up low lisp
  6942. HLL A,NAME+3 ;IOWD length(loader),137 .
  6943. HRRI A,137-1
  6944. PCALL SYSINP
  6945. SKIPE LDFLG#
  6946. JRST LOAD3 ;If already have them, skip SYMs.
  6947. MOVSI A,(SIXBIT /SYM/)
  6948. PCALL SYSINI
  6949. MOVNS A ;length symbols
  6950. PCALL MORCOR ;expand core for symbols
  6951. SKIPGE B,.JBSYM
  6952. SOS B ;if no symbol table, use original jobsym.
  6953. HLRZ A,NAME+3 ;-length(symbols)
  6954. ADDB A,B
  6955. HLL A,NAME+3 ;symbol table iowd
  6956. PCALL SYSINP
  6957. HRRM B,.JBSYM
  6958. HLLZ A,NAME+3
  6959. ADDM A,.JBSYM
  6960. SETOM LDFLG ;Lisp symbols loaded, until next EXCISE.
  6961. SKIPA
  6962. LOAD3: SOS .JBSYM ;want jobsym to point one below 1st symbol
  6963. MOVE 3,HVAL ;h
  6964. MOVE 5,RVAL ;r
  6965. MOVE 2,3
  6966. SUB 2,5 ;x=h-r
  6967. HRLI 5,12 ;(w) -- LH index needed because
  6968. HRLI 2,11 ;(v) uses @X, etc.
  6969. SETZB 1,4 ;(N,S)
  6970. IFN SYDEV,<MOVE 4,SYSNUM> ;Tell Loader current SYS: used by Lisp.
  6971. JSP 0,140 ;call the loader
  6972. LOAD4: HRRZM 5,RLAST# ;last location loaded(in final area)
  6973. MOVE T,OLDCU
  6974. MOVE A,.JBSYM
  6975. MOVEM A,.JBSYM(T)
  6976. MOVE A,.JBREL
  6977. MOVEM A,.JBREL(T) ;update jobrel
  6978. HRLZ 0,LOWLSP
  6979. SOS LODSIZ
  6980. AOBJN 0,.+1 ;<LOWLSP+1,,A> -- LODSIZ.
  6981. BLT 0,@LODSIZ ;blt down low lisp
  6982. MOVE 0,@LOWLSP ;<LOWLSP,,NIL> -- all accs now restored.
  6983. MOVE B,RLAST
  6984. MOVE A,RVAL
  6985. HRL A,HVAL ;<HVAL,,RVAL> -- RLAST.
  6986. SKIPE LDPAR
  6987. JRST BINLD ;If into BPS, check room first.
  6988. MOVE C,RLAST ;new coruse
  6989. LDRET2: BLT A,(B) ;blt down loaded code
  6990. HRRZM C,CORUSE ;top of code loaded
  6991. MOVEI B,1
  6992. ANDCAM B,.JBSYM
  6993. SUB C,.JBSYM ;length of free core
  6994. ORCMI C,776000
  6995. AOJGE C,START ;no contraction
  6996. ADD C,.JBREL ;new top of core
  6997. MOVE B,C
  6998. PCALL MOVDWN
  6999. HRLM C,.JBSA
  7000. CALLI C,CORE ;contract core
  7001. JRST .+1
  7002. JRST START
  7003. BINLD: PSAVE A ;Check for BPS exceeded...
  7004. PSAVE B ;<MOVEI C,INUM0(B)
  7005. CDRA A,B ; CAML C,VBPEND
  7006. PCALL FIX1A ; JRST BPSERR
  7007. PSAVE A ; MOVEM C,VBPORG>
  7008. FOO MOVE B,VBPEND
  7009. PCALL .LESS
  7010. JUMPE A,[SETOM BPSFLG ;Flag "BPS exceeded" for LISP2 check.
  7011. JRST START ]
  7012. FOO PREST VBPORG ;Update it; loading fits.
  7013. PREST B
  7014. PREST A
  7015. SOS C,OLDCU ;old top of core
  7016. JRST LDRET2
  7017. > ;end of IFN ALOD
  7018. PAGE
  7019. IFN AED!ALOD,<
  7020. SYSINI: MOVEM A,NAME+1
  7021. IFLE <OPSYS+SYDEV-1>,<SETZM NAME+3 >
  7022. IFN SYDEV,<PSAVE SYSNUM
  7023. IFLE OPSYS,<PREST .+2>
  7024. IFG OPSYS,<PREST NAME+3> >
  7025. INIT 17
  7026. IFE SYDEV,<SIXBIT /SYS/ >
  7027. IFN SYDEV,<
  7028. IFLE OPSYS,< X >
  7029. IFG OPSYS,<SIXBIT /DSK/ > >
  7030. 0
  7031. JRST AIN.4+1
  7032. LOOKUP NAME
  7033. JRST SYSINER ;error
  7034. INPUT [IOWD 1,NAME+3 ;input size of file
  7035. 0]
  7036. HLRO A,NAME+3
  7037. PRET
  7038. SYSINER:RELEASE
  7039. IFE ALOD,<ERRL1 ^D156,[SIXBIT /LISP.ED MISSING!/]>
  7040. IFN ALOD,<
  7041. MOVSI B,(SIXBIT /SYM/)
  7042. CAME A,B ;Are we in LOAD mode?
  7043. IFN AED,ERRL1 ^D156,[SIXBIT /LISP.ED OR LOD MISSING!/] ;No, safe to use
  7044. IFE AED,ERRL1 ^D156,[SIXBIT /LISP.LOD MISSING!/] ; low core routines.
  7045. OUTSTR [ASCIZ /
  7046. LISP.SYM not found!! No load.
  7047. /] ; Yes -- Loader in low core, though,
  7048. MOVE 5,RVAL ; so have to fake the BLT
  7049. JRST LOAD4 ; with original RVAL.
  7050. > ;end of IFN ALOD
  7051. NAME: SIXBIT /LISP/ ;Filename of system,
  7052. 0 ; .* auxiliaries (e.g. SYM, LOD, ED).
  7053. 0
  7054. 0
  7055. > ;end of IFN ALOD!AED
  7056. PAGE
  7057. IFN ALOD,<
  7058. SYSINP: MOVEM A,LST> ;LOAD
  7059. IFN ALOD!AED!RWB,<
  7060. SYSINQ: ;ED, RBLK
  7061. IFN OPSYS,< ;KLUDGE to circumvent bug in PA1050...
  7062. MOVS A,LST ; to wit: uses SIN which plants a nul,
  7063. SUB A,LST ; which clobbers wd after input-blk.
  7064. HLRZ A,A
  7065. IFN HCBPS,<CAIGE A,400000>
  7066. CAMGE A,.JBREL
  7067. PSAVE 1(A)
  7068. INPUT LST
  7069. IFN HCBPS,<CAIGE A,400000>
  7070. CAMGE A,.JBREL
  7071. PREST 1(A) >
  7072. IFE OPSYS,<INPUT LST> ;ELSE just input it.
  7073. STATZ 740000
  7074. ERRL1 ^D157,AIN.8
  7075. RELEASE
  7076. PRET
  7077. LST: 0
  7078. 0
  7079. > ;end of IFN ALOD!AED!RWB
  7080. AIN.8: SIXBIT /INPUT ERROR!/
  7081. PAGE
  7082. IFN ALOD,<
  7083. MOVDWN: HLRZ A,.JBSYM
  7084. JUMPE A,MOVS1
  7085. ADDI A,1(B)
  7086. HRL A,.JBSYM
  7087. HRRM A,.JBSYM
  7088. BLT A,(B) ;downward blt
  7089. PRET
  7090. MOVSYM: MOVE B,.JBREL
  7091. HRLM B,.JBSA
  7092. HLRE A,.JBSYM
  7093. JUMPE A,MOVS1
  7094. ADDI B,1(A) ;new bottom of symbol table
  7095. MOVNI A,1(A)
  7096. ADD A,.JBSYM ;last loc of old symbol table
  7097. HRRM B,.JBSYM
  7098. PSAVE C
  7099. MOVE B,.JBREL ;last loc of new symbol table
  7100. MOVE C,(A) ;simulated upward blt
  7101. MOVEM C,(B)
  7102. SUBI B,1
  7103. ADDI A,-1 ;lf+1,rt-1
  7104. JUMPL A,.-4
  7105. PREST C
  7106. PRET
  7107. MOVS1: HRRZM B,.JBSYM
  7108. PRET> ;end of IFN ALOD
  7109. ;enter with size needed in a
  7110. ;exit with pointer in a to core
  7111. MORCOR: PSAVE B
  7112. PCALL EXPND2
  7113. MOVE B,CORUSE#
  7114. ADDM A,CORUSE
  7115. MOVE A,B
  7116. PREST B
  7117. PRET
  7118. EXPND2: HRRZ B,.JBSYM
  7119. SUB B,CORUSE
  7120. SUBM A,B
  7121. JUMPL B,EXPND3
  7122. ADD B,.JBREL ;new core size
  7123. CALLI B,CORE ;expand core
  7124. TCORE3: ERRL1 ^D158,[SIXBIT /CAN'T EXPAND CORE!/]
  7125. IFN ALOD,<PSAVE A
  7126. PCALL MOVSYM
  7127. PREST A>
  7128. IFE ALOD,<MOVE B,.JBREL
  7129. HRRZM B,.JBSYM
  7130. HRLM B,.JBSA>
  7131. EXPND3: PRET
  7132. SUBTTL SOSLINK INLINE WITH LISP MAIN --- PAGE 23
  7133. %FPAGE: SUBI A,INUM0 ;FIND-PAGE N, IN THE FILE.
  7134. PSAVE A
  7135. %FP.LP: SOSG A,0(P)
  7136. JRST POPAJ ;Stop when get there, returning 0=NIL.
  7137. PCALL TYI ;(ERR $EOF$) if too few <ff>.
  7138. CAIE A,14
  7139. JRST .-2
  7140. JRST %FP.LP
  7141. %NEXTTYI: PCALL TYI ;Doing a PEEKC().
  7142. MOVEM A,OLDCH
  7143. JRST FIX1A
  7144. FILEP: PCALL FILEPX
  7145. RELEASE 0,
  7146. PRET
  7147. FILEPX: PSAVE A ;Test for a file's existence.
  7148. MOVSI B,(SIXBIT /DSK/);Clear any left over.
  7149. MOVEM B,DEV
  7150. SETZM PPN
  7151. JUMPE A,.+3
  7152. JSP D,ATMTYP
  7153. PCALL NCONS
  7154. MOVE T,A ;Permit @((F.E)) or full @(DIR: D F.E)) .
  7155. PCALL IOSUB
  7156. MOVEM A,LOOKIN
  7157. IFN SYDEV,<PCALL SYSDEV > ;Change SYS: if necessary.
  7158. MOVE A,DEV
  7159. MOVEM A,DEV2
  7160. INIT 0,17
  7161. DEV2: X
  7162. 0
  7163. JRST AIN.7
  7164. PREST A
  7165. LOOKUP 0,LOOKIN ;Using chan 0 (no INC or INPUT needed).
  7166. MOVEI A,NIL ; file not found.
  7167. PRET
  7168. PAGE
  7169. IFN SOSSW,<
  7170. %SOSSWAP:
  7171. SUBI 2,INUM0 ;(PAGE # .LT. 2^16, OF COURSE).
  7172. SUBI 4,INUM0
  7173. LSH 4,^D16 ;ERGO, 2 BECOMES 400000
  7174. PSAVE 4
  7175. PSAVE 2
  7176. PSAVE 1 ;FILE SPECIFICATION
  7177. MOVE 1,3
  7178. PCALL NUMVAL ;(LINE # .LT. 99999).
  7179. MOVE 4,[POINT 7,T,34]
  7180. MKLIN1: IDIVI 1,^D10
  7181. ADDI 2,60
  7182. DPB 2,4
  7183. ADD 4,[XWD 70000,0]
  7184. TLNN 4,400000
  7185. JRST MKLIN1
  7186. TRO T,1
  7187. EXCH T,(P) ;T WILL NOW CONTAIN FILE SPECIFICATION
  7188. SETZM DEV
  7189. PCALL IOSUB ;RETURNS FILENM IN A
  7190. MOVEM 17,ACSAV+17
  7191. MOVEI 17,ACSAV
  7192. BLT 17,ACSAV+16 ;SAVE ACCS 0-17 for return from subr.
  7193. PREST 15
  7194. PREST 16
  7195. PREST 13 ;00/01/02 == GET,R-O,CREATE.
  7196. MOVEM P,ACSAV+P
  7197. MOVE 14,A
  7198. HLL 13,EXT ;SET BY IOSUB
  7199. IFGE OPSYS,<CALLI 11,24 ;GETPPN UUO
  7200. SETZ 11,
  7201. HRRZS 11 >
  7202. IFL OPSYS,<GJINF
  7203. MOVE 11,2 >
  7204. SETZB 1,12
  7205. ;HIGH ACCS FOR SOS ARE NOW SET ... TO WIT:
  7206. ;
  7207. ;ACC 11 = PPN
  7208. ; 12 = (UNUSED).
  7209. ; 13 = EXT,,FLAGS ;BITS 18-19 = 0 (GET FILE), 1 (READ-ONLY), 2 (CREATE IT)
  7210. ; 14 = FILENM
  7211. ; 15 = LINE #, IN ASCID FORM (BIT 35 ON);
  7212. ; 16 = PAGE #.
  7213. PAGE
  7214. IFE OPSYS, < ;USE LABORIOUS METHOD OF MAKING CORE-IMAGE.
  7215. ; == FOR 10/50 SYSTEMS...VESTIGIAL.
  7216. ;SWAP IS NOT DECLARED INTERNAL/SUBR (THO IT COULD BE).
  7217. ;FIRST SAVES ALL ACCUMULATORS AS FILE 'QQSVAC.TMP'
  7218. ;SAV -- SWAPS OUT (EFFECTIVELY) 116 THRU MIN(LH(E+2),.JBREL)
  7219. ; -- MUST GO TO THE DISK (& WILL, REGARDLESS OF DEVICE).
  7220. ; -- USES 1; DOES NOT SAVE ANY HIGH SEGMENT !!!
  7221. ; -- THE FORMAT IS A NON-ZERO-COMPRESS (75--END).
  7222. ; -- THE ACCS ARE RESTORED IF A RUN IS NOT DONE.
  7223. ;RUN -- USES THE DEC RUN-UUO WHICH DESTROYS THE ACCUMULATORS
  7224. ; -- THEREFORE, IF YOU WISH TO PASS ARGUMENTS (IN THE ACCS)
  7225. ; -- TO THE NEW PROGRAM, PICK THEM UP FROM THE TMP FILE.
  7226. EXTERNAL .JBCOR,.JBS41,.JBDDT
  7227. SLOC==74
  7228. .JBSDD==114
  7229. SWAP: MOVEI 1,ACBLK
  7230. BLT 1,ACBLK+17 ;CAN'T OUTPUT FROM BELOW LOC 115
  7231. MOVE 1,[XWD ACSAV,6] ;RESTORE UNCLOBBERED HI-ACCS
  7232. BLT 1,17
  7233. CALLI 1,30 ;PJOB
  7234. IDIVI 1,^D10
  7235. LSH 1,6
  7236. OR 1,2
  7237. LSH 1,^D24
  7238. OR 1,[SIXBIT/00SVAC/]
  7239. MOVEM 1,ACHEAD
  7240. ADDI 1,5460-4143 ;'LP' - 'AC'
  7241. INIT 17 ;DUMP MODE
  7242. SIXBIT /DSK/
  7243. 0 ;NO BUFFERS
  7244. JRST AOUT.4+1
  7245. SETZM ACHEAD+2
  7246. SETZM ACHEAD+3
  7247. ENTER ACHEAD
  7248. ERRL1 ^D159,SWOUT2
  7249. OUTPUT [IOWD 20,ACBLK
  7250. 0]
  7251. STATZ 740000
  7252. ERRL2 ^D160,SWOUT2
  7253. CLOSE
  7254. STATZ 740000
  7255. ERRL2 ^D161,SWOUT2
  7256. MOVEM 1,IOFILE
  7257. SETZM IOFILE+2
  7258. SETZM IOFILE+3
  7259. ENTER IOFILE
  7260. ERRL2 ^D162,SWOUT2
  7261. HRRZ 2,.JBCOR
  7262. MOVEM 2,OLDCOR
  7263. MOVE 2,.JBREL
  7264. HRRM 2,.JBCOR
  7265. SUBI 2,SLOC ;NOT OUTPUTTING FIRST 0-SLOC LOCS
  7266. MOVEM 2,1 ;N WORDS OF DATA
  7267. MOVN 2,2
  7268. SUBI 2,1 ;-(N+1) == DATA + NULL HEADER WORD
  7269. HRLM 2,OLIST
  7270. MOVE 2,.JBREL
  7271. HRRM 2,MVX+^D9 ;HIGHEST LOC BEFORE RELOC = DITTO BLT
  7272. ADDI 2,2000
  7273. CALLI 2,CORE ;SPACE TO RELOCATE INTO
  7274. ERRL2 ^D163,SWOUT2
  7275. MOVE 3,[XWD MVX,MV]
  7276. BLT 3,MVE
  7277. MOVE 3,[XWD 216,116]
  7278. JRST MV
  7279. MVX: PHASE 4
  7280. MV: MOVE 2,SLOC(1)
  7281. MOVEM 2,SLOC+100(1) ;MOVE 100 UPWARD
  7282. SOJG 1,MV
  7283. SETZM SLOC+100 ;NULL HEADER WORD
  7284. MOVE 2,.JBDDT
  7285. MOVEM 2,.JBSDD+100
  7286. MOVE 2,.JB41
  7287. MOVEM 2,.JBS41+100
  7288. OUTPUT OLIST+100 ;AT RELOCATED IOWD
  7289. BLT 3,0-0 ;MOVE BACK DOWN
  7290. MVE: JRST MVY
  7291. DEPHASE
  7292. MVY: MOVE 2,[XWD ACSAV,6]
  7293. BLT 2,17 ;RESTORE AGAIN OVER CODE
  7294. HRRZ 2,MVX+^D10
  7295. CALLI 2,CORE ;REDUCE CORE BY 1K TO PREVIOUS
  7296. STRTIP [SIXBIT /_*** WOULDN'T REDUCE CORE_!/]
  7297. STATZ 740000 ;NOW CHECK FOR OUTPUT ERRORS
  7298. ERRL2 ^D164,SWOUT2
  7299. CLOSE 0,
  7300. STATZ 740000
  7301. ERRL2 ^D165,SWOUT2
  7302. RELEAS 0,
  7303. MOVE 2,OLDCOR
  7304. HRRM 2,.JBCOR
  7305. RUNUUO: SETZM NEWCOR
  7306. MOVSI 1,1 ;SA INC
  7307. HRRI 1,DEVC2
  7308. CLRBFI ;DELETE CR,LF IF ANY...DISTURB SOS.
  7309. CALLI 1,35 ;RUN UUO
  7310. HALT ; POSSIBLY RECOVERABLE, BUT EXIT ANYWAY
  7311. ACBLK: BLOCK 20
  7312. DEVC2: SIXBIT/SYS/
  7313. SIXBIT/SOS/
  7314. SIXBIT/SAV/
  7315. 0
  7316. 0
  7317. NEWCOR:
  7318. OLDCOR: 0-0
  7319. IOFILE:
  7320. ACHEAD: SIXBIT/QQSVAC/
  7321. SIXBIT/TMP/
  7322. 0
  7323. 0
  7324. OLIST: XWD 0-0,SLOC+100-1
  7325. 0
  7326. SWOUT2: SIXBIT /COULDN'T SWAP SUCCESSFULLY_!/
  7327. > ;******** CLOSE OF IFE OPSYS, FROM SWAP: ********.
  7328. PAGE
  7329. IFN OPSYS, < ;EASIER WITH TENEX
  7330. %SWAP:
  7331. MOVSI 1,1 ;SET B17
  7332. MOVE 2,[POINT 7,FILSOS]
  7333. GTJFN
  7334. JRST SOSER1
  7335. HRRZ 3,1 ;AC1(RH) NOW HAS DESIRED JFN.
  7336. MOVSI 1,(1B1+1B3) ;Spec. cap. & use AC2.
  7337. MOVEI 2,0 ;VIRTUAL ADDRESS OF ACCS.
  7338. CFORK ;CREATE INFERIOR FORK.
  7339. JRST SOSER2
  7340. EXCH 1,3
  7341. HRL 1,3 ;SET UP (LH) WITH HANDLE
  7342. JSYS 200 ;GET JSYS
  7343. HRRZ 1,3
  7344. MOVEI 2,2 ;INDEX INTO ENTRY-VEC
  7345. SFRKV ;START THAT FORK
  7346. ;AC1 HAS INFERIOR-F HANDLE!
  7347. WFORK ;CURRENT FORK WAITS UNTIL THE
  7348. ; INFERIOR FORK TERMINATES.
  7349. KFORK ;INF-FORK STILL EXISTS, SO!
  7350. SWAPEX: MOVSI 17,ACSAV
  7351. BLT 17,17 ;Restore accs
  7352. PRET ; and return.
  7353. FILSOS: ASCIZ /<SUBSYS>SOS.SAV/
  7354. SOSER1: OUTSTR FILSOS
  7355. OUTSTR [ASCIZ / NOT FOUND
  7356. /]
  7357. SOSER2: OUTSTR [ASCIZ /COULDN'T SOSSWAP/]
  7358. JRST SWAPEX
  7359. > ;CLOSE OF IFN OPSYS.
  7360. > ;******* Close of IFN SOSSW, from %SOSSWAP: ****
  7361. %ACSAV:
  7362. ACSAV: BLOCK 20
  7363. PAGE
  7364. IFN JSYXEQ,< ;The rest of this page is under this switch
  7365. COMMENT 
  7366. The JSYS function executes a JSYS and returns the result. It is
  7367. called as JSYS(jsysno,arg1,arg2,arg3,retreg) where jsysno is the
  7368. number of the JSYS, retreg is the number of the register in which the
  7369. executed JSYS will return its value and argN is loaded into register
  7370. N as argument to the JSYS. The value of the global variable JSYSAR4
  7371. is taken as arg4 (initial value is 0).
  7372. If argN is a number then that number is converted to machine-
  7373. representation and loaded into reg N.
  7374. If argN is not the list (BUF) then it must be a string or an id.
  7375. This string or id is written in a buffer as a ASCIZ string and a
  7376. pointer to that string is loaded into reg N.
  7377. If argN is (BUF) then a pointer to a stringbuffer is loaded into reg
  7378. N. Only one of the argN may be (BUF).
  7379. If there is a (BUF) this indicates that the JSYS will write a string
  7380. into the string buffer, using retreg as updated string- pointer and
  7381. return as value the string converted into a LISP string.
  7382. If there is no (BUF) among the arguments, then the content of the
  7383. retreg register is converted into a LISP number and returned as value
  7384. of JSYS. 
  7385. %JSYS: PSAVE B ; A1 arg.
  7386. PSAVE C ; A2 arg.
  7387. PSAVE AR4 ; A3 arg.
  7388. FOO PSAVE VJSYSAR4 ; A4 arg.
  7389. CAIG A,INUM0+777 ; JSYS number
  7390. CAIGE A,INUM0+1
  7391. ERRE2 ^D39,[SIXBIT /NOT A JSYS!/]
  7392. SUBI A,INUM0
  7393. HRRM A,JSY ; Set which JSYS.
  7394. MOVE A,AR5
  7395. CAIG A,INUM0+4
  7396. CAIGE A,INUM0+1
  7397. ERRE2 ^D40,[SIXBIT /NOT A RETURN REGISTER!/]
  7398. SUBI A,INUM0
  7399. HRRM A,RETREG ; Set which register contains the value
  7400. MOVEI AR5,1
  7401. HRRM AR5,RBUFAR ; No string returned.
  7402. MOVEM SP,STRST# ;Start of string buffer. Special stack is used
  7403. HRREI B,-3
  7404. JSARLP: HRRM B,NJSAR
  7405. NJSAR: MOVE A,X(P) ; Get arg.
  7406. JSP D,ATMTYP ; What type is it?
  7407. CAIE TT,FIXNU ; If not a fixnum
  7408. JUMPN TT,JSASTB ; or an Inum must be string or buffer
  7409. PCALL NUMVAL ; A number. Convert to machine format
  7410. MOVEM A,@NJSAR ; and set arg.
  7411. JRST JSARLE
  7412. JSASTB: CAIE TT,ID ; An id
  7413. CAIN TT,STRNG ; or a string ?
  7414. JRST JSASTR ; Yes!
  7415. FOO CAIE TT,BUF ; Return string buffer?
  7416. ERRE2 ^D41,[SIXBIT /ILLEGAL JSYS ARG!/] ; No! Error.
  7417. HRRM B,RBUFAR ; Arg no for return string pointer.
  7418. JRST JSARLE
  7419. JSASTR: MOVE C,STRST ; String buffer position.
  7420. MOVEI B,1(C)
  7421. HRROM B,@NJSAR ; Set arg to string pointer.
  7422. PCALL PNAMUD ; Unpack into buffer
  7423. PUSH C,[0] ; Deposit zero at end of string.
  7424. MOVEM C,STRST ; Update string buffer.
  7425. JSARLE: HRRE B,NJSAR ; Next arg.
  7426. AOJLE B,JSARLP
  7427. HRRZ B,RBUFAR ; Return string?
  7428. SOJE B,NORST ; No!
  7429. MOVE B,STRST ; String buffer position.
  7430. PUSH B,[0] ; Zero first word.
  7431. RBUFAR: HRROM B,X(P) ; Set arg to string pointer for return string.
  7432. NORST: HRRZM B,STRST ; 0 or address of output string.
  7433. PREST 4 ; A4 arg.
  7434. PREST 3 ; A3 arg.
  7435. PREST 2 ; A2 arg.
  7436. PREST 1 ; A1 arg.
  7437. JSY: JSYS X
  7438. ERJMP JSYERR
  7439. ERJMP JSYERR
  7440. RETREG: MOVE A,X ; Load return value into register 1.
  7441. SKIPE B,STRST ; Return string?
  7442. JRST MKSTR ; Yes! Convert to Lisp string.
  7443. JRST FIX1A ;No! Convert to LISP number and return
  7444. ;JSYS error return
  7445. JSYERR: PCALL ERRSTR
  7446. ERRE2 ^D42,[SIXBIT /JSYS ERROR!/]
  7447. ; ERRSTR returns the last system error message as a Lisp string;
  7448. ERRSTR: HRROI A,1(SP) ; Pointer to buffer for string.
  7449. HRLOI B,400000 ; .FHSLF
  7450. SETZ 3,
  7451. ERSTR
  7452. ERJMP EER
  7453. ERJMP EER
  7454. MKSTR1: MOVEI B,1(SP)
  7455. MKSTR: SKIPG C,A ; Convert from ASCII string to LISP string.
  7456. JRST FALSE ; Return NIL if no string.
  7457. LDB AR4,A ; Last character.
  7458. JUMPN AR4,NOBCKP ; O.k. if not null.
  7459. CAIN B,(A) ; Only one word?
  7460. JRST NOBCKP ; Yes! Never step back pointer.
  7461. HLRZ AR4,A
  7462. CAIN AR4,350700 ; Null in beginning of word?
  7463. MOVEI C,-1(A) ; Yes! Step back pointer.
  7464. NOBCKP: HRL A,B ; Start of string.
  7465. SUBI B,1(SP) ; - expected start of string.
  7466. JUMPE B,LMKSTR ; Don't need to move string if start is o.k..
  7467. HRRI A,1(SP) ; Expected start of string.
  7468. SUBI C,(B) ; Updated end of string.
  7469. BLT A,(C) ; Move string.
  7470. JRST LMKSTR ; Make into LISP string.
  7471. EER:
  7472. FOO MOVEI A,QST ;Couldn't get error string return ?
  7473. PRET
  7474. GETAB$: PCALL NUMVAL
  7475. HRRM A,GETALO
  7476. HLLZ B,A
  7477. MOVE C,SP
  7478. GETALO: MOVEI A,X
  7479. HRL A,B
  7480. GETAB
  7481. JRST GERR
  7482. PUSH C,A
  7483. AOBJN B,GETALO
  7484. GERR: MOVSI A,700
  7485. HRR A,3
  7486. JRST MKSTR1
  7487. ; !%XEQ generates inferior forks
  7488. %XEQ: MOVEM A,FORKH# ; FILENAME OR PREVIOUS FORK HANDLE #.
  7489. MOVEM B,STAD# ; T=START, NIL=RESUME, 0-N = EVEC POS.
  7490. MOVEM C,KILL# ; T=KFORK, NIL=KEEP FOR A RESUME-FORK.
  7491. MOVEM AR4,ACSADR# ; NIL=NONE, N=ADDR OF ACCBLK
  7492. MOVEM AR5,ARGSTR# ; NIL=NONE, RSCAN . TTYINP Tops20, TTYINP Tenex
  7493. IFL OPSYS,< ;RSCAN not defined in TENEX
  7494. JUMPE AR5,NORTYI
  7495. CARA A,(AR5)
  7496. JUMPE A,NRSCN ; NO RSCAN
  7497. PCALL PNAMUK
  7498. PUSH C,[0] ; Must end with 0
  7499. HRROI A,1(SP)
  7500. RSCAN
  7501. JRST FAIL6
  7502. NRSCN: MOVE A,FORKH > ;END OF IFL OPSYS
  7503. NORTYI: PCALL NUMBERP ; IF NUMBERP FILE/FORKH
  7504. JUMPN A,OLDFORK ; THEN GOTO OLDFORK;
  7505. MOVE A,FORKH
  7506. PCALL PNAMUK
  7507. PUSH C,[0] ; Must end with 0
  7508. MOVSI A,100001 ; OLD FILES ONLY.
  7509. HRROI B,1(SP)
  7510. GTJFN ; GTJFN OF STRING ON SP STACK.
  7511. JRST FAIL1
  7512. MOVEM A,SAVJFN#
  7513. MOVSI A,200000 ; 1B1
  7514. SETZ B, ; SETUP ACS BELOW, IF ANY.
  7515. CFORK
  7516. JRST FAIL2
  7517. MOVEM A,FORKH
  7518. HRRZ A,SAVJFN
  7519. HRL A,FORKH
  7520. JSYS 200 ; GET OF FORK,,JFN.
  7521. SKIPN A,STAD
  7522. FOO MOVEI A,TRUTH ; START, NOT RESUME.
  7523. MOVEM A,STAD
  7524. JRST TRYIT
  7525. OLDFORK:MOVE A,FORKH
  7526. PCALL NUMVAL
  7527. CAIL A,400001
  7528. CAIL A,400035
  7529. ERRE2 ^D43,[SIXBIT /NOT A FORK HANDLE!/]
  7530. MOVEM A,FORKH
  7531. RFSTS
  7532. TLNN A,777777
  7533. ERRL2 ^D168,[SIXBIT /DEAD FORK IN XEQ!/]
  7534. MOVEM B,FORKPC#
  7535. TRYIT: MOVEI A,100 ;PRIMARY INPUT
  7536. CFIBF ;Flush buffer to be safe
  7537. RFMOD
  7538. MOVEM B,OTTMOD#
  7539. SKIPN A,ACSADR
  7540. JRST NOACS
  7541. PCALL NUMVAL
  7542. MOVE B,A
  7543. MOVE A,FORKH
  7544. SFACS
  7545. NOACS: MOVE A,FORKH
  7546. SKIPN C,STAD
  7547. JRST DOSFORK ; IF NULL STAD THEN START FORK
  7548. FOO CAIN C,TRUTH
  7549. TDZA C,C ; IF STAD=T THEN START AT EVEC+0
  7550. SUBI C,INUM0 ; UNBOX NUMBER
  7551. GEVEC
  7552. ADD B,C
  7553. MOVEM B,FORKPC
  7554. HLRZ AR4,B ; CHECK LH LENGTH VERSUS STAD
  7555. CAIE AR4,(JRST)
  7556. JRST ITENEX
  7557. CAIL C,2
  7558. JRST FAIL5 ; 10/50 CAN ONLY ST/REE 0/1.
  7559. JRST DOSFORK
  7560. ITENEX: CAIL C,(AR4)
  7561. JRST FAIL5
  7562. DOSFORK:HRRZ B,FORKPC
  7563. SFORK ; SFORK AT PC, RATHER THAN RFORK
  7564. IFG OPSYS,<SKIPN A,ARGSTR
  7565. JRST NTAR>
  7566. IFL OPSYS,<SKIPN C,ARGSTR
  7567. JRST DOWFORK
  7568. CDRA A,(C)
  7569. JUMPE A,NTAR>
  7570. PCALL PNAMUK
  7571. HRRZ C,SP
  7572. HRLI C,700
  7573. MOVEI A,100 ;Primary output designator;
  7574. XL1: MOVEI AR4,127
  7575. XL2: ILDB B,C
  7576. JUMPE B,NTAR
  7577. STI
  7578. SOJG AR4,XL2
  7579. DIBE
  7580. JRST XL1
  7581. NTAR: MOVE A,FORKH
  7582. DOWFORK:WFORK
  7583. MOVEI A,100
  7584. MOVE B,OTTMOD
  7585. SFMOD
  7586. MOVE A,FORKH
  7587. SKIPN B,KILL
  7588. JRST FIX1A ; RETURN FORKH# FOR FUTURE RESUME.
  7589. KFORK ; KFORK IF NON-NIL FLAG.
  7590. JRST FALSE
  7591. FAIL1: PSAVE FORKH
  7592. PCALL ERRSTR
  7593. PCALL NCONS
  7594. PRET B
  7595. PCALL XCONS
  7596. MOVE B,A
  7597. MOVEI A,INUM0
  7598. JRST .ERROR
  7599. FAIL6: CARA A,ARGSTR
  7600. PSAVE A
  7601. JRST FAIL1+1
  7602. FAIL2: MOVE A,SAVJFN
  7603. RLJFN
  7604. JFCL
  7605. PCALL ERRSTR
  7606. ERRE2 ^D44,[SIXBIT /ERROR IN XEQ!/]
  7607. FAIL5: MOVE A,STAD
  7608. ERRE2 ^D45,[SIXBIT /BAD ENTRY VECTOR IN XEQ!/]
  7609. > ;End of IFN JSYXEQ
  7610. SUBTTL BPS SWAPPING ROUTINES --- PAGE 24
  7611. IFN RWB,< ;to end of page
  7612. INTERNAL RBLK, WBLK
  7613. RBLK: PCALL FILEPX ; (RBLK <FILE>) no 2nd arg anymore.
  7614. JUMPE A,RBLK0 ; Not found.
  7615. INPUT [IOWD 1,LST
  7616. 0]
  7617. JRST SYSINQ
  7618. RBLK0: RELEASE 0,
  7619. JRST AIN.7
  7620. WBLK: INIT 17 ; (WBLK <file> <start-addr> <end-addr>)
  7621. SIXBIT /DSK/
  7622. 0
  7623. JRST AOUT.4+1
  7624. HRLZM A,DEV
  7625. MOVE A,B ;IN CASE ADDRESSES OVER 64K.
  7626. PCALL NUMVAL
  7627. EXCH A,C
  7628. PCALL NUMVAL
  7629. SUBI C,1
  7630. SUBM C,A ;A_ -(A-(C-1)) == ARG1:ARG2 INCLUSIVE
  7631. HRL C,A
  7632. MOVEM C,LST
  7633. MOVEI T,DEV
  7634. PCALL IOSUB
  7635. MOVEM A,ENTR
  7636. SETZM ENTR+2 ;CREATION DATE
  7637. ENTER ENTR
  7638. JRST OUTERR+1
  7639. OUTPUT [IOWD 1,LST
  7640. 0]
  7641. OUTPUT LST
  7642. CLOSE
  7643. STATZ 740000
  7644. JRST TYO2X+2 ;"OUTPUT ERROR".
  7645. PRET
  7646. > ;end of IFN RWB
  7647. SUBTTL CORE EXPANDING ROUTINES --- PAGE 25
  7648. INTERNAL TCORE
  7649. TCORE: SUBI A,INUM0 ;== ^C, CORE N, START EXCEPT FOR N =<0
  7650. JUMPL A,TCORE0 ;JUST RETURN CURRENT LISP-ALLOC SIZE
  7651. JUMPE A,TCORE0+1 ;JUST RETURN CURRENT CORE SIZE
  7652. CAILE A,MAXCORE ;LIMIT .LT. 124K OR SO, ALLOWING FOR I/O BUFFS
  7653. JRST TCORE3
  7654. LSH A,^D10
  7655. SUBI A,1
  7656. CAMGE A,JRELO
  7657. JRST TCORE1 ;Smaller than current Lisp area alloc.
  7658. CAML A,.JBREL
  7659. JRST TCORE2 ;LARGER THAN CURRENT CORE, SO EXPAND.
  7660. IFE HCBPS,<
  7661. SKIPN VXCORE
  7662. JRST TCORE4
  7663. STRTIP [SIXBIT /_*** CAN'T EXCISE_!/]
  7664. JRST TCORE0+1
  7665. >
  7666. TCORE4: CAMG A,JRELO
  7667. PCALL TCORE5
  7668. TCORE2: CALLI A,CORE
  7669. JRST TCORE3
  7670. JRST LISPGO ;GO ALLOCATE CORE
  7671. TCORE1: STRTIP [SIXBIT /_*** CAN'T CUT CORE INTO ALLOCATED SPACE_!/]
  7672. TCORE0: SKIPA A,JRELO ;-1 GIVES CURRENT LISP-ALLOC AREA
  7673. HRRZ A,.JBREL ; 0 GIVES CURRENT TOTAL CORE ASSIGNED
  7674. ADDI A,1777
  7675. LSH A,-^D10
  7676. JRST FIXI
  7677. TCORE5: MOVE B,JRELO
  7678. CAME B,CORUSE
  7679. FOO SKIPN %MSG
  7680. PRET
  7681. ; OUTSTR [ASCIZ /
  7682. ;*** EXCISED
  7683. ;/]
  7684. PRET
  7685. PAGE
  7686. ; EXCORE( n ) permits arbitrary expansion of BPS above Lisp spaces,
  7687. ; by: 1) flagging STRT allocator not to alloc extra core,
  7688. ; 2) creating or extending a high BPS area of nK,
  7689. ; 3) setting BPORG and BPEND up there appropriately,
  7690. ; 4) doing an I/O reset, to get the buffers above BPS,
  7691. ; permitting future LOADs, EDs, etc.
  7692. ; EXCORE( 0 ) forces the BPORG and BPEND pntrs down to their last
  7693. ; positions in low BPS, but doesn't clear the high...which
  7694. ; is retained indefinitely or until an EXCISE.
  7695. ; EXCORE(NIL) permits ALLOC() or ST to allocate extra core as usual.
  7696. ; Has also the effect of EXCORE(0).
  7697. IFN SZBPS,< ;Only defined when not maximal BPS.
  7698. EXCORE:
  7699. IFE HCBPS,< ;Only when BPS in low core
  7700. MOVEM A,VXCORE# ;If NIL, flag for STRT allocation,
  7701. JUMPE A,CHKVBP
  7702. HRREI C,-INUM0(A) ;else
  7703. JUMPL C,EXCORT
  7704. LSH C,^D10 ; Convert nK to n*1024 words.
  7705. JUMPE C,CHKVBP ; If arg=0, put BP pntrs back to low BPS.
  7706. FOO MOVE A,VBPEND
  7707. PCALL NUMVAL
  7708. CAML A,FSO ;Are the pntrs in low BPS still?
  7709. JRST EXCOR2 ; No, extend from this BPEND.
  7710. MOVEM A,OBPEND# ; Yes, save positions for a later CHKVBP.
  7711. FOO MOVE A,VBPORG
  7712. PCALL NUMVAL
  7713. MOVEM A,OBPORG#
  7714. SKIPA A,JRELO ;Start BPS. [Could use CORUSE instead]
  7715. EXCOR2: SETZ B, ;If 0, pntrs were already in high BPS.
  7716. ADD A,C ;Extend by amt of arg.
  7717. IORI A,777 ; End of page.
  7718. CAIGE A,MAXCORE*^D1024 ;More than 124K requested,
  7719. CALLI A,CORE ; or can't get it?
  7720. JRST TCORE3 ; Say so.
  7721. JUMPE B,EXCOR3 ;Got it -- set pntrs to it.
  7722. MOVE A,JRELO ;[or CORUSE]
  7723. ADDI A,1
  7724. PCALL FIX1A
  7725. FOO MOVEM A,VBPORG
  7726. EXCOR3: MOVE A,.JBREL
  7727. PCALL FIX1A
  7728. FOO MOVEM A,VBPEND
  7729. JSR IOBRST ;Set JOBSA and clear I/O pntrs.
  7730. CALLI RESET ;Set JOBFF.
  7731. JSR APRSET
  7732. PCALL TTYRET
  7733. EXCORT: MOVE A,VXCORE
  7734. PRET
  7735. PAGE
  7736. CHKVBP:
  7737. FOO MOVE A,VBPEND ;Ensure BP pntrs to low BPS.
  7738. PCALL NUMVAL
  7739. CAMGE A,FSO
  7740. JRST EXCORT ;Already low, no change needed.
  7741. MOVE A,OBPEND
  7742. PCALL FIX1A
  7743. FOO MOVEM A,VBPEND
  7744. MOVE A,OBPORG
  7745. PCALL FIX1A
  7746. FOO MOVEM A,VBPORG
  7747. JRST EXCORT
  7748. >
  7749. IFN HCBPS,<
  7750. JUMPE A,CPOPJ ;Do nothing if argument NIL.
  7751. PCALL NUMVAL
  7752. JUMPLE A,CPOPJ
  7753. LSH A,^D10
  7754. MOVE AR5,A
  7755. FOO MOVE A,VBPEND
  7756. PCALL NUMVAL
  7757. ADD AR5,A
  7758. IORI AR5,777
  7759. HRLZ A,AR5
  7760. TLNN AR5,-1
  7761. CALLI A,CORE
  7762. JRST TCORE3
  7763. MOVE A,AR5
  7764. PCALL FIX1A
  7765. FOO MOVEM A,VBPEND
  7766. PRET
  7767. >
  7768. > ;End of IFN SZBPS
  7769. PAGE
  7770. FREEZE: SKIPE A ;If going to toplevel, then
  7771. PCALL TUNBIND ; unbind to toplevel
  7772. MOVEM 17,ACSAV+17 ;This routine halts Lisp in a manner
  7773. MOVEI 17,ACSAV ; that can be later re-started.
  7774. BLT 17,ACSAV+16
  7775. IFL OPSYS,<
  7776. MOVE 1,VBPORG
  7777. PCALL NUMVAL
  7778. MOVEM 1,.JBHRL >
  7779. IFN OPSYS,<
  7780. MOVEI 1,400000
  7781. MOVE 2,[2,,ENTFRZ]
  7782. SEVEC > ;Tell it where to start or continue.
  7783. MOVEI 1,NEWST ;Unfortunately, need to do this
  7784. MOVEI 2,NEWREE ; in order to thwart PA1050,
  7785. HRRM 1,.JBSA ; if ST or REE w/o clearing it.
  7786. HRRM 2,.JBREN
  7787. IFN OPSYS,< HALTF >
  7788. IFE OPSYS,<EXIT 1,>
  7789. NEWST: TDZA NIL,NIL
  7790. NEWREE: SETO NIL,
  7791. IFN OPSYS,<
  7792. MOVEI 1,400000 ;Tell it the normal Lisp entries.
  7793. MOVE 2,[2,,ENTVEC]
  7794. SEVEC >
  7795. IFL OPSYS,<
  7796. MOVE 1,.JBREL
  7797. HRLI 1,676777
  7798. CALLI 1,CORE
  7799. JRST .+1 >
  7800. MOVEI 1,LISPGO
  7801. MOVEI 2,DEBUGO
  7802. HRRM 1,.JBSA
  7803. HRRM 2,.JBREN
  7804. JSR IOBRST ;Clear I/O bufs.
  7805. JUMPN NIL,[MOVE NIL,ACSAV
  7806. SETZM RETFLG
  7807. JRST START ] ;REE to get past INITFN.
  7808. CALLI RESET
  7809. JSR APRSET ;Reset 10/50 or Tenex interrupts.
  7810. MOVSI 17,ACSAV
  7811. BLT 17,17
  7812. PCALL TTYRET
  7813. SKIPN A,ACSAV+1 ;Test arg of FREEZE...
  7814. PRET ; NIL -- Return, no files open.
  7815. MOVE A,.JBREL ; Non-NIL -- GOTO top-level INITFN.
  7816. CAMN A,JRELO
  7817. JRST LSPRET ;Unexpanded core. G.c. not necessary.
  7818. JRST LISPGO
  7819. IFN OPSYS,<
  7820. ENTVEC: JRST LISPGO
  7821. JRST DEBUGO
  7822. ENTFRZ: JRST NEWST
  7823. JRST NEWREE >
  7824. SUBTTL AUXILIARY ROUTINES --- PAGE 26
  7825. IFN OPSYS,<
  7826. LSSAVE: MOVEM 17,ACSAV+17 ;This routine SSAVEs Lisp in a manner
  7827. MOVEI 17,ACSAV ; that can be later run, no files open.
  7828. BLT 17,ACSAV+16
  7829. MOVE 17,ACSAV+17 ;Restore it.
  7830. MOVEI 1,400000
  7831. MOVE 2,[2,,ENTFRZ]
  7832. SEVEC
  7833. MOVSI 1,(1B0+1B17)
  7834. HRROI 2,LSSFIL
  7835. GTJFN
  7836. JRST LSSER1
  7837. HRLI 1,400000
  7838. MOVEI 2,LSSTBL
  7839. SETZ 3,
  7840. SSAVE
  7841. HRRZS 1
  7842. RLJFN
  7843. JRST LSSER1
  7844. MOVEI 1,400000
  7845. MOVE 2,[2,,ENTVEC]
  7846. SEVEC
  7847. JRST TRUE ;Distinguish from a NEWST's NIL!
  7848. LSSER1: MOVEI 1,400000
  7849. MOVE 2,[2,,ENTVEC]
  7850. SEVEC
  7851. ERRL2 ^D166,[SIXBIT /COULDN'T SSAVE/]
  7852. LSSFIL:
  7853. IFL OPSYS,ASCIZ /LSSAVE.EXE/
  7854. IFG OPSYS,ASCIZ /LSSAVE.SAV/
  7855. LSSTBL: -700,,520B26+0 ;Pages 0-677 below PA1050.
  7856. 0
  7857. >
  7858. PAGE
  7859. IFN SYDEV,<
  7860. SETSYS:
  7861. IFG OPSYS,<SUBI A,INUM0 ;CHANGE SYS: <DIR> NUMBER.
  7862. CAIGE A,0 ; Permit 0 ... user's dir.
  7863. SKIPA A,SYSNUM#
  7864. MOVEM A,SYSNUM
  7865. JRST FIXI>
  7866. IFLE OPSYS,<MOVE T,A
  7867. PCALL ATOM
  7868. JUMPE A,GVDV
  7869. MOVE A,T
  7870. PCALL SIXMAK
  7871. TRC A,":"-40
  7872. TRNE A,77
  7873. JRST GVDV
  7874. HLLZM A,SYSNUM#
  7875. MOVE A,T
  7876. PRET
  7877. GVDV: SETZB A,B
  7878. SKIPA AR4,[POINT 6,SYSNUM]
  7879. ADDI A,40(B)
  7880. LSH A,7
  7881. ILDB B,AR4
  7882. JUMPN B,.-3
  7883. ADDI A,":"
  7884. LSH A,1
  7885. SKIPA AR4,[1]
  7886. LSH A,7
  7887. TLNN A,774000
  7888. JRST .-2
  7889. MOVEM A,1(SP)
  7890. MOVEI C,1(SP)
  7891. JRST MSTR1 >
  7892. >
  7893. SUBTTL REALLOC CODE --- PAGE 27
  7894. STRT: MOVE P,C2
  7895. SKIPE SP,SPSAV
  7896. PCALL TUNBIND
  7897. MOVE A,.JBREL ;New top of core -- becomes JRELO below.
  7898. HRLM A,.JBSA
  7899. SUB A,JRELO# ;length of extra core
  7900. JUMPE A,RREL4 ;no expansion
  7901. SKIPG A
  7902. HALT ;smaller core -- bitch.
  7903. IFN AED,<MOVEI B,EDP2
  7904. HRRM B,ED>
  7905. IFE HCBPS,<SKIPE VXCORE ;If XCORE(Nil), go ahead and allocate,
  7906. JRST RREL4 > ; else retain as is...usually expanded BPS.
  7907. MOVE A,.JBREL
  7908. TRO A,1777
  7909. CALLI A,CORE
  7910. SKIPA A,.JBREL
  7911. MOVE A,.JBREL
  7912. HRLM A,.JBSA
  7913. SUB A,JRELO
  7914. PCALL TCORE5
  7915. IFN ALOD,SETZM LDFLG ;initial loader symbol table flag
  7916. MOVE F,EFWSO#
  7917. SUB F,FWSO# ;old length of fws
  7918. HRRZS B,A
  7919. ACHLOC: ASH A,-2+X ;1/4 of new core to fws * User-patchable *
  7920. ADD A,F ;new length of fws
  7921. MOVE C,B
  7922. STKLOC: ASH C,-6 ;1/64 of new core to each pdl
  7923. MOVE AR4,C
  7924. HRL AR4,C
  7925. HLRZ AR5,SC2 ;-old length of spec pdl
  7926. ADD AR5,.JBREL ;new bottom of spec pdl
  7927. HLL AR5,SC2 ;old length of spec pdl
  7928. SUB AR5,AR4 ;new pointer for spec pdl
  7929. MOVEM AR5,SC2
  7930. IFN EPDL,<
  7931. HLRZ EP,EC2 ;-old length of exp pdl
  7932. ADD AR5,EP ;new bottom of exp pdl
  7933. HLL AR5,EC2 ;old length of exp pdl
  7934. SUB AR5,AR4 ;new pointer for exp pdl
  7935. MOVEM AR5,EC2 >
  7936. MOVNS C2 ;old reg pdl pointer
  7937. HLRZ AR4,C2 ;old length of reg pdl
  7938. ADD C,AR4 ;new length of reg pdl
  7939. HRRZ B,AR5 ;new bottom of reg pdl
  7940. SUB B,FSO#
  7941. MOVEI T,44 ;1/36 space for fws bit tables
  7942. IDIVM A,T ;new length of fws bit tables
  7943. AOS T
  7944. SUB B,T ;B:=SPL-FSO-(FWS/36+1)-FWS-PL, then
  7945. SUB B,A ;B:=B-(B/33+1)+FSO
  7946. SUB B,C
  7947. MOVEI TT,41 ;1/33 space for fs bit table
  7948. IDIVM B,TT ;new length of fs bit table
  7949. SUBI B,1(TT) ;new length of fs
  7950. ADD B,FSO ;new bottom of fs
  7951. HRRM B,GCP1
  7952. MOVN SP,B ;- new bottom of fws
  7953. HRRM SP,GCMFWS
  7954. HRLZM A,C1GCS
  7955. MOVNS C1GCS ;- new length of fws
  7956. HRRM B,C1GCS
  7957. ADDI B,-1(A) ;new top of fws
  7958. AOS B
  7959. MOVE SP,FSO
  7960. LSH SP,-5
  7961. SUBM B,SP
  7962. HRRM SP,GCBTP2 ;magic number for bit table references
  7963. HRRM SP,GCBTP1
  7964. HRLM B,C3GC ;bottom of bit tables --- for bit table zeroing
  7965. HRRM B,GCP2
  7966. HRRM B,GCP
  7967. MOVNI SP,-1(TT)
  7968. HRLM SP,C3GCS
  7969. HRRM B,C3GCS ;iowd for FS bit table sweep
  7970. AOS B
  7971. MOVE SP,FSO
  7972. ANDI SP,37
  7973. HRRM SP,GCBTL2 ;magic number to position bit table word
  7974. SUBI SP,^D32
  7975. HRRM SP,GCBTL1
  7976. HRRM B,C3GC ;bottom of bit table
  7977. ADDI B,-1(TT)
  7978. HRRM B,C2GCS ;bottom of fws bit table
  7979. AOS B
  7980. HRRM B,C2GC
  7981. ADDI B,-1(T)
  7982. HRRM B,GCP5 ;top of bit tables
  7983. AOS B ;bottom of reg pdl
  7984. HRRZ A,RHX2 ;oblist pointer
  7985. MOVEM A,(B)
  7986. HRRM B,GCP3 ;room for acs
  7987. AOS B
  7988. HRRM B,C2 ;reg pdl bottom
  7989. MOVNI A,-10(C)
  7990. HRLM A,C2 ;reg pdl size
  7991. HRRZ A,.JBREL
  7992. HRRZM A,JRELO ;new top of core
  7993. MOVE A,GCP1
  7994. HRRM A,.+4 ;To...
  7995. MOVE A,FWSO
  7996. HRRM A,.+1 ;From...
  7997. MOVE A,.(F) ;old bottom of fws *
  7998. MOVEM A,.(F) ;new bottom of fws *
  7999. SOJGE F,.-2 ;f has length (old) of fws
  8000. HRRZ AR4,GCP1
  8001. SUB AR4,FWSO ;displacement for fws
  8002. MOVE AR5,FSO ;bottom of fs
  8003. RREL1: CARA A,(AR5) ;Adjust pntrs in new FS to new FWS...
  8004. CAMG A,EFWSO
  8005. CAMGE A,FWSO
  8006. JRST RREL2
  8007. ADD A,AR4
  8008. RPLCA A,(AR5) ;fix car pointer
  8009. RREL2: CDRA A,(AR5)
  8010. CAMG A,EFWSO
  8011. CAMGE A,FWSO
  8012. JRST RREL3
  8013. ADD A,AR4
  8014. RPLCD A,(AR5) ;fix cdr pointer
  8015. RREL3: CAMGE AR5,FWSO
  8016. AOJA AR5,RREL1
  8017. MOVE A,GCP1 ;bottom of fws
  8018. HRRZM A,FWSO
  8019. MOVE A,C3GC ;bottom of bit table + 1
  8020. HRRZM A,EFWSO
  8021. RREL4:
  8022. FOO SETZB FF,DDTIFG ;Flag for AGC.
  8023. JSR IOBRST
  8024. JRST START
  8025. ;--------------------------------------------------------------------
  8026. RLOCA: MOVE B,AR4 ;= FS+BPS LENGTHS.
  8027. HRLI AR4,BFWS
  8028. HRRI AR4,FS(B)
  8029. MOVEI AR5,EFWS-BFWS(AR4)
  8030. BLT AR4,(AR5)
  8031. MOVEI AR4,FS-BFWS(B)
  8032. MOVEI AR5,BFWS-1
  8033. REL1: CARA A,(AR5)
  8034. CAILE A,EFWS
  8035. JRST REL2
  8036. CAIGE A,BFWS
  8037. JSP R,REL4
  8038. ADD A,AR4
  8039. REL2: RPLCA A,(F)
  8040. CDRA A,(AR5)
  8041. CAILE A,EFWS
  8042. JRST REL3
  8043. CAIGE A,BFWS
  8044. JSP R,REL4
  8045. ADD A,AR4
  8046. REL3: RPLCD A,(F)
  8047. SOS F
  8048. CAILE AR5,FS
  8049. SOJA AR5,REL1
  8050. JRST RREL4 ;Now do the IOBRST and START.
  8051. REL4: CAIL A,FS
  8052. ADD A,FF
  8053. JRST 1(R)
  8054. PAGE
  8055. REHASH: ;ONCE ONLY, per HASHFG.
  8056. FOO MOVEI A,BFWS
  8057. PSAVE A
  8058. HRRM A,RHX2
  8059. HRRM A,RHX5
  8060. RH4: MOVSI B,X ;*
  8061. FOO MOVEI A,BFWS+1(B)
  8062. FOO MOVEM A,BFWS(B)
  8063. AOBJN B,.-2
  8064. FOO SETZM BFWS(B)
  8065. MOVSI AR5,-BCKETS
  8066. RH1:
  8067. FOO HLRZ C,OBTBL(AR5)
  8068. RH3: JUMPE C,RH2
  8069. CARA A,(C)
  8070. PSAVE C
  8071. PSAVE AR5
  8072. PCALL INTERN
  8073. PREST AR5
  8074. PREST C
  8075. CDRA C,(C)
  8076. JRST RH3
  8077. RH2: AOBJN AR5,RH1
  8078. SETZM HASHFG
  8079. PREST A
  8080. HRRM A,@GCP3
  8081. FOO MOVEM A,OBLIST
  8082. JRST START
  8083. SUBTTL LISP ATOMS AND OBLIST --- PAGE 28
  8084. RVAL: 0
  8085. HVAL: 0
  8086. VAR
  8087. LIT
  8088. PAGE
  8089. FS:
  8090. DEFINE MAKBUC (A,%B)
  8091. <DEFINE OBT'A <%B=.>
  8092. IFN <BCKETS-1-A>,<XWD %B,.+1>
  8093. IFE <BCKETS-1-A>,<XWD %B,NIL>
  8094. IF1 <%B=0>>
  8095. DEFINE ADDOB (A,C,%B)
  8096. <OBT'A
  8097. DEFINE OBT'A<%B=.>
  8098. IF1 <%B=0>
  8099. XWD C,%B>
  8100. DEFINE PUTOB (A,B)
  8101. <ZZ==<ASCII /A/>_<-1>
  8102. ZZ==-ZZ/BCKETS*BCKETS+ZZ
  8103. ADDOB \ZZ,B>
  8104. DEFINE PSTRCT (A)
  8105. <ZZ==[ASCII /A/]
  8106. LENGTH ZY,A
  8107. REPEAT <ZY-1>/5,<XWD ZZ,.+1
  8108. ZZ==ZZ+1>
  8109. XWD ZZ,0>
  8110. DEFINE MKAT (A,B,C,D)
  8111. <XLIST
  8112. IRP A< PUTOB A,.+1
  8113. D XWD ID,.+1
  8114. XX==<B-EXPR>*<B-FEXPR>
  8115. IFN XX,<XWD .+1,.+2
  8116. XWD B,C'A>
  8117. IFE XX,<XWD .+1,.+4
  8118. XWD FUNCELL,.+1
  8119. XWD B,.+1
  8120. XWD CODE,C'A>
  8121. XWD .+1,NIL
  8122. XWD PNAME,.+1
  8123. PSTRCT A>
  8124. LIST>
  8125. PAGE
  8126. DEFINE MKAT1 (A,B,C,D)
  8127. <XLIST
  8128. IRP C <PUTOB C,.+1
  8129. XWD ID,.+1
  8130. XX==<B-EXPR>*<B-FEXPR>
  8131. IFN XX,<XWD .+1,.+2
  8132. XWD B,D'A>
  8133. IFE XX,<XWD .+1,.+4
  8134. XWD FUNCELL,.+1
  8135. XWD B,.+1
  8136. XWD CODE,D'A>
  8137. XWD .+1,NIL
  8138. XWD PNAME,.+1
  8139. PSTRCT C>
  8140. LIST>
  8141. DEFINE LENGTH (A,B)
  8142. <A==0
  8143. IRPC B,<A==A+1>>
  8144. DEFINE ML1 (A)<XLIST
  8145. IRP A,<XLIST
  8146. INTERNAL A
  8147. V'A= INUM0+A
  8148. MKAT A,SYM,V>
  8149. LIST> ;These SYMs are for direct access from LAP code (e.g. LISP.TNX)
  8150. DEFINE ML (A)<
  8151. XLIST
  8152. IRP A,<PUTOB A,.+1
  8153. A: XWD ID,.+1
  8154. XWD .+1,NIL
  8155. XWD PNAME,.+1
  8156. PSTRCT A>
  8157. LIST>
  8158. OBTBL:
  8159. OBLIST: ZZ==0 ;Base of array or linear-list of hash buckets.
  8160. XLIST ;REPEAT BCKETS,<MAKBUC \ZZ
  8161. REPEAT BCKETS,<MAKBUC \ZZ
  8162. ZZ==ZZ+1>
  8163. LIST ; ZZ==ZZ+1>
  8164. PAGE
  8165. ML <LAMBDA,EXPR,FEXPR,SYM,FUNCELL,VALUE,PNAME,TRACE>
  8166. ML <LABEL,MACRO,INPUT,OUTPUT,INBIN,OUTBIN>
  8167. ML <SUBR,FSUBR>
  8168. MKAT <RPLACA,RPLACD,MINUS,TERPRI,READ,CAR,CDR,CAAR>,EXPR
  8169. MKAT <CADR,CDAR,CDDR,CAAAR,CAADR,CADAR,CADDR,CDAAR,CDADR,CDDAR,CDDDR>,EXPR
  8170. MKAT <CAAAAR,CAAADR,CAADAR,CAADDR,CADAAR,CADADR,CADDAR,CADDDR,CDAAAR>,EXPR
  8171. MKAT <CDAADR,CDADAR,CDADDR,CDDAAR,CDDADR,CDDDAR,CDDDDR,CONS>,EXPR
  8172. MKAT <PROG2,ATOM,EQ,PRIN1,PRINT,RETURN,EXPLODE,ATSOC,PATOM>,EXPR
  8173. MKAT <POSN,LINELENGTH,NUMBERP,EQUAL,SUBST,GET,INTERN,MEMBER>,EXPR
  8174. MKAT <COMPRESS,READCH,NOT,NULL,GENSYM,ZEROP,DIVIDE,GCD>,EXPR
  8175. IFN AED,<MKAT <ED,GRINDEF>,EXPR>
  8176. MKAT <TIME,FIX,SET,LENGTH,ADD1,SUB1,LAST,WARNING>,EXPR
  8177. MKAT <GCTIME,REVERSE,SPEAK,MAPLIST,MEMQ>,EXPR
  8178. MKAT <PUT,PRIN2,ERR,MAPCAR,EXAMINE,DEPOSIT,LSH,MAPCAN,MAPCON>,EXPR
  8179. MKAT <NCONS,XCONS,REMPROP,MINUSP,MAP,MAPC>,EXPR
  8180. MKAT <WRS,RDS,OPEN,CLOSE,EXCISE,REMAINDER,ABS,BKTRA>,EXPR
  8181. MKAT <PGLINE>,EXPR
  8182. MKAT <%FSLID,%FPAGE,%NEXTTYI,SETPCHAR,DLVECT>,EXPR
  8183. IFN SOSSW,MKAT %SOSSWAP,EXPR
  8184. IFN RWB,<MKAT <RBLK,WBLK>,EXPR>
  8185. MKAT <FILEP,FREEZE>,EXPR
  8186. IFN SZBPS,MKAT <EXCORE>,EXPR
  8187. MKAT <CORE>,EXPR,T
  8188. MKAT <BINI,BINO,TYID,TYOD>,EXPR
  8189. MKAT1 VINC,VALUE,INC*
  8190. VINC:NIL
  8191. MKAT1 VOUTC,VALUE,OUTC*
  8192. VOUTC:NIL
  8193. IFN OPSYS,MKAT LSSAVE,EXPR
  8194. IFN JSYXEQ,<MKAT <%XEQ,GETAB$,ERRSTR>,EXPR
  8195. MKAT1 VJSYSAR4,VALUE,JSYSAR4
  8196. VJSYSAR4: INUM0
  8197. ML BUF
  8198. MKAT JSYS,EXPR,%>
  8199. IFN SYDEV,<MKAT SETSYS,EXPR>
  8200. MKAT EXPLODEC,EXPR,%
  8201. MKAT TYO,EXPR,I
  8202. MKAT TYI,EXPR,I
  8203. MKAT EVAL,EXPR,,CEVAL:
  8204. MKAT <LIST,COND,PROG,SETQ>,FEXPR
  8205. MKAT1 LIST,EXPR,EVLIS
  8206. MKAT <OR,AND,GO,PROGN>,FEXPR
  8207. IFN ASARY,<MKAT <ARRAY,STORE>,FEXPR
  8208. ML1 NSTR
  8209. IFN ALOD,<MKAT EXARRAY,FEXPR> >
  8210. MKAT1 QUOTE,FEXPR,FUNCTION
  8211. IFN FNRG,<
  8212. ML FUNARG
  8213. MKAT1 FUNCT,FEXPR,*FUNCTION
  8214. MKAT <%EVAL,%APPLY>,EXPR >
  8215. MKAT <APPEND,NCONC,APPLY,REMOB,ERRORSET,FIXP,FLOATP,INUMP,BIGP>,EXPR
  8216. MKAT <PUTD,GETD,REMD,PRINC,FLAG,FLAGP,REMFLAG,MKCODE,FLOAT,DIGIT>,EXPR
  8217. MKAT <BOOLE,LITER,IDP,PAIRP,CONSTANTP,STRINGP,VECTORP,CODEP>,EXPR
  8218. MKAT <MKVECT,UPBV,GETV,PUTV>,EXPR
  8219. MKAT INTERNP,EXPR,.
  8220. MKAT ASCII,EXPR,A
  8221. MKAT QUOTE,FEXPR,,CQUOTE:
  8222. MKAT1 FIX1A,EXPR,*BOX
  8223. ML1 <EXARG,ATMTYP,NATMTYP,INTER0,FWCONS,ACHLOC,CHRTAB>
  8224. MKAT INUM0,SYM,S
  8225. INTERN INUM0
  8226. SINUM0: XWD FIXNU,VINUM0
  8227. IFN OPSYS,ML1 <READP1,PNAMUK,%ACSAV,LMKSTR>
  8228. IFN OPSYS*SOSSW,ML1 %SWAP
  8229. PUTOB T,.+1
  8230. TRUTH: XWD ID,.+1
  8231. XWD .+1,.+2
  8232. XWD VALUE,VTRUTH
  8233. XWD .+1,NIL
  8234. XWD PNAME,.+1
  8235. PSTRCT T
  8236. VTRUTH: TRUTH
  8237. PUTOB NIL,0
  8238. CNIL2: XWD .+1,.+2
  8239. XWD VALUE,VNIL
  8240. XWD .+1,NIL
  8241. XWD PNAME,.+1
  8242. PSTRCT NIL
  8243. VNIL: NIL
  8244. IFE STL,<
  8245. MKAT <SASSOC,SETARG,GETL,ARG,READLIST,FLATSIZE>,EXPR
  8246. MKAT <CSYM,DEFPROP>,FEXPR
  8247. MKAT1 EXPN1,EXPR,*EXPAND1
  8248. MKAT1 EXPAND,EXPR,*EXPAND
  8249. MKAT1 LCALL,SYM,*LCALL,INUM0+%
  8250. MKAT1 UDT,SYM,*UDT,INUM0+% >
  8251. MKAT1 AMAKE,SYM,*AMAKE,INUM0+%
  8252. MKAT1 %NOPOINT,VALUE,*NOPOINT
  8253. %NOPOINT: NIL
  8254. MKAT1 BACTRF,VALUE,*BAKGAG
  8255. BACTRF:NIL
  8256. MKAT1 ERRSW,VALUE,*ERRMSG
  8257. ERRSW:TRUTH
  8258. MKAT1 V$EOF$,VALUE,$EOF$
  8259. V$EOF$: $EOF$
  8260. $EOF$: XWD ID,.+1
  8261. XWD .+1,NIL
  8262. XWD PNAME,.+1
  8263. PSTRCT $EOF$
  8264. MKAT1 GCGAGV,VALUE,*GCGAG
  8265. GCGAGV:NIL
  8266. MKAT1 VFECHO,VALUE,*ECHO
  8267. VFECHO:NIL
  8268. MKAT1 VRAISE,VALUE,*RAISE
  8269. VRAISE:NIL
  8270. MKAT1 DDTIFG,VALUE,*DDTIN
  8271. DDTIFG:TRUTH
  8272. MKAT1 NOUUOF,VALUE,*NOUUO
  8273. NOUUOF:NIL
  8274. MKAT1 %MSG,VALUE,*MSG
  8275. %MSG: TRUTH
  8276. MKAT1 GC,EXPR,RECLAIM
  8277. MKAT1 INITF,VALUE,INITFN*
  8278. INITF:NIL
  8279. MKAT1 %SYSTM,VALUE,SYSTEM*
  8280. %SYSTM: OPSYS+INUM0
  8281. MKAT <SCANINIT,SCANSET,SCAN,UNREADCH>,EXPR
  8282. MKAT <LETTER,DELIMITER,IGNORE,RDSLSH>,EXPR
  8283. MKAT1 SCNV,VALUE,SCNVAL
  8284. SCNV: NIL
  8285. MKAT SKIPTO,EXPR
  8286. MKAT <LPOSN,PAGELENGTH,EJECT,NUMVAL>,EXPR
  8287. MKAT ERROR,EXPR,.
  8288. MKAT1 VERMSG,VALUE,EMSG*
  8289. VERMSG: NIL
  8290. IFN OFLD!NFLD,<
  8291. MKAT1 VPURIFY,VALUE,*PURIFY
  8292. VPURIFY: NIL
  8293. MKAT1 VPREDEF,VALUE,*PREDEF
  8294. VPREDEF: NIL
  8295. MKAT1 VF.LIST,VALUE,F.LIST
  8296. VF.LIST: NIL
  8297. MKAT1 VP.URCLOBRL,VALUE,P.URCLOBRL
  8298. VP.URCLOBRL: NIL >
  8299. IFN OFLD,<
  8300. MKAT <FASLOD,LDFERR>,EXPR
  8301. MKAT1 VFARRY,VALUE,FARRY
  8302. VFARRY: NIL >
  8303. IFN NFLD,MKAT FASLOAD,EXPR
  8304. ;UNBOUND is a non-interned identifier
  8305. UNBOUND:XWD ID,.+1
  8306. XWD .+1,NIL
  8307. XWD PNAME,.+1
  8308. PSTRCT UNBOUND
  8309. IFN MOD,<
  8310. MKAT <SETMOD,CMOD,CPLUS,CDIF,CTIMES,CRECIP>,EXPR
  8311. MKAT1 VBIGP,VALUE,MOD*
  8312. VBIGP: NIL >
  8313. MKAT1 LAMBIND,EXPR,*LAMBIND*
  8314. MKAT1 PROGBIND,EXPR,*PROGBIND*
  8315. MKAT1 SPECSTR,EXPR,*SPECRSTR*
  8316. MKAT1 PLUS,EXPR,PLUS2,.
  8317. MKAT1 DIF,EXPR,DIFFERENCE,.
  8318. MKAT1 QUO,EXPR,QUOTIENT,.
  8319. MKAT1 TIMES,EXPR,TIMES2,.
  8320. MKAT1 RSTSW,VALUE,*RSET
  8321. RSTSW:NIL
  8322. MKAT1 GREAT,EXPR,GREATERP,.
  8323. MKAT1 LESS,EXPR,LESSP,.
  8324. IFN ALOD,<MKAT LOAD,EXPR
  8325. MKAT1 PUTSYM,EXPR,*PUTSYM
  8326. MKAT1 GETSYM,EXPR,*GETSYM>
  8327. MKAT <OBLIST,BASE,IBASE,BPEND,BPORG>,VALUE,V
  8328. VOBLIST: OBLIST
  8329. VBASE: 8+INUM0
  8330. VIBASE: 8+INUM0
  8331. VBPORG: XWD 0,.+1
  8332. XWD FIXNU,VBPORX
  8333. VBPEND: XWD 0,.+1
  8334. XWD FIXNU,VBPENX
  8335. PUTOB ?,.+1
  8336. QST: XWD ID,.+1
  8337. XWD .+1,NIL
  8338. XWD PNAME,.+1
  8339. PSTRCT ?
  8340. BFWS: ;All the FWS LITerals from above atoms, etc.
  8341. XLIST ; includes VBPORX,VBPENX datums.
  8342. LIT
  8343. VINUM0: INUM0
  8344. VBPORX: 400000
  8345. VBPENX: 700000-1000-2 ;676776 --> 1 for SYSINP and 1000 for slop.
  8346. LIST
  8347. EFWS: 0
  8348. SUBTTL LISP STORAGE ALLOCATOR (ONCE ONLY) --- PAGE 29
  8349. ALLOC:! CALLI RESET ;Later IOBRST & another RESET.
  8350. MOVEI P,ALLPDL-1
  8351. IFN OPSYS, < ;LISP.EXE SIZE LT DESIRED STARTING SIZE.
  8352. MOVEI A,INITCORE
  8353. PCALL ALCORH >
  8354. IFL OPSYS,<GETPPN A,
  8355. HLRM A,SYSNU>
  8356. IFN SYDEV, <
  8357. IFG OPSYS, <
  8358. MOVEI 1,1 ;MATCH EXACTLY
  8359. HRROI 2,[ASCIZ /REDUCE/]
  8360. STDIR
  8361. JFCL
  8362. GJINF ;IN DESPERATION, USE HIS LOGIN DIR #.
  8363. HRRZM 1,SYSNUM >
  8364. IFLE OPSYS,<
  8365. MOVEI A,(SIXBIT /SYS/)
  8366. HRLZM A,SYSNUM >
  8367. > ;End of IFN SYDEV
  8368. OUTSTR [ASCIZ /
  8369. Allocate? /]
  8370. INCHRW C
  8371. CAIE C,"n"
  8372. CAIGE C,"O"
  8373. JRST ALLC00
  8374. IFN OPSYS,<
  8375. OUTSTR [ASCIZ /
  8376. Core (K): /]
  8377. PCALL ALLNUM
  8378. JUMPLE A,ALLTNX
  8379. CAIG A,MAXCORE ;Asking for too much core ?
  8380. JRST .+3 ;No
  8381. OUTSTR [ASCIZ /
  8382. Will give you maximum allowed/]
  8383. MOVEI A,MAXCORE
  8384. LSH A,^D10
  8385. SUBI A,1
  8386. PCALL ALCORE
  8387. ALLTNX:! MOVEI A,^D8
  8388. HRRM A,ALLRDX ;Remaining inputs are octal.
  8389. >
  8390. IFN SYDEV, <
  8391. IFG OPSYS, <
  8392. OUTSTR [ASCIZ /
  8393. SYS: dir# /]
  8394. PCALL ALLNUM
  8395. SKIPN A
  8396. GJINF ;If user said "0", use his dir.
  8397. SKIPL A
  8398. HRRM A,SYSNUM >
  8399. IFLE OPSYS,<
  8400. OUTSTR [ASCIZ /
  8401. SYS: /]
  8402. SETZ A,
  8403. SYLO:! INCHRW C
  8404. CAILE C,"z"
  8405. JRST SYLE
  8406. CAIL C,"a"
  8407. TRZ C,40 ;Convert lower case to upper
  8408. CAIL C,"A"
  8409. CAILE C,"Z"
  8410. JRST SYLE
  8411. LSH A,6
  8412. ADDI A,-40(C)
  8413. JRST SYLO
  8414. INCHRW C
  8415. SYLE:! CAIN C,RUBOUT
  8416. JRST [OUTSTR [ASCIZ /XXX /]
  8417. JRST SYLO-1]
  8418. CAILE C," "
  8419. JRST SYLE-1
  8420. CAIN C,15
  8421. INCHRW C ;<lf> assumed.
  8422. JUMPE A,.+2
  8423. HRLZM A,SYSNUM >
  8424. > ;End of IFN SYDEV
  8425. OUTSTR [ASCIZ /
  8426. FWDS= /]
  8427. PCALL ALLNUM
  8428. JUMPL A,.+2
  8429. HRRM A,ALLC02
  8430. IFN SZBPS,<
  8431. OUTSTR [ASCIZ /
  8432. BPS.= /]
  8433. PCALL ALLNUM
  8434. JUMPL A,.+5 ;USE DEFAULT ?
  8435. CAIGE A,MINFBPS
  8436. MOVEI A,MINFBPS
  8437. ADDI A,BOTBPS
  8438. HRRZM A,SBPS >
  8439. OUTSTR [ASCIZ /
  8440. SPDL= /]
  8441. PCALL ALLNUM
  8442. JUMPL A,.+4
  8443. HRRM A,ALLC20
  8444. MOVNS A
  8445. HRRM A,ALLC21
  8446. IFN EPDL,<
  8447. OUTSTR [ASCIZ /
  8448. EPDL= /]
  8449. PCALL ALLNUM
  8450. JUMPL A,.+4
  8451. HRRM A,ALLC40
  8452. MOVNS A
  8453. HRRM A,ALLC41 >
  8454. OUTSTR [ASCIZ /
  8455. RPDL= /]
  8456. PCALL ALLNUM
  8457. JUMPL A,.+2
  8458. HRRM A,ALLC30
  8459. OUTSTR [ASCIZ /
  8460. HASH= /]
  8461. PCALL ALLNUM
  8462. CAIG A,BCKETS
  8463. JRST ALLC00
  8464. HRRM A,INT1
  8465. MOVNS A
  8466. HRRM A,RH4
  8467. SETOM HASHFG ;ONCE ONLY.
  8468. ALLC00:!
  8469. MOVE A,.JBREL
  8470. HRRZM A,JRELO
  8471. HRLM A,.JBSA
  8472. MOVEI A,DEBUGO
  8473. HRRM A,.JBREN
  8474. MOVEI A,LISPGO
  8475. HRRM A,.JBSA
  8476. IFN OPSYS,<
  8477. MOVEI 1,400000
  8478. MOVE 2,[2,,ENTVEC]
  8479. SEVEC
  8480. >
  8481. OUTSTR [ASCIZ /
  8482. /]
  8483. IFE HCBPS,<
  8484. MOVEI A,FS
  8485. PCALL FIX1A
  8486. MOVEM A,VBPORG
  8487. MOVEI A,FS
  8488. ADD A,SBPS
  8489. HRRZM A,FSO ;SET ONCE AND FOR EVER!!!
  8490. SOS A
  8491. PCALL FIX1A
  8492. MOVEM A,VBPEND
  8493. >
  8494. IFN HCBPS,<
  8495. MOVEI A,FS
  8496. MOVEM A,FSO
  8497. IFN OPSYS,MOVEI A,400000 ;First loc of high-segment.
  8498. IFE OPSYS,<
  8499. HRRZ B,.JBREL ;highest address in low core
  8500. TRNN B,400000 ;is low core higher than 128k
  8501. MOVEI B,377777 ;no, assume high core start at 400000
  8502. MOVE A,[XWD -2,.GTUPM] ;get high core orig. from monitor
  8503. GETTAB A, ;.GTUPM indexed by current high core number
  8504. HRLI A,1(B) ;table or call not present, use assumed value
  8505. LSH A,-^D18 ;convert to address of high segment
  8506. ANDI A,777000 ;clear any low bits
  8507. ADDI A,.JBHDA> ;Add space for vestigial job data area
  8508. MOVEM A,VBPORX
  8509. IFE SZBPS,MOVEI A,700000-1000-2 ;PA1050 - 1 page.
  8510. IFN SZBPS,ADD A,SBPS
  8511. MOVEM A,VBPENX
  8512. MOVSS A
  8513. PCALL ALCORH
  8514. SETZ A,
  8515. CALLI A,SETUWP
  8516. HALT
  8517. >
  8518. MOVE A,JRELO
  8519. ALLC20:! SUBI A,1000+X
  8520. ALLC21:! HRLI A,-1000+X
  8521. MOVEM A,SC2
  8522. IFN EPDL,<
  8523. ALLC40:! SUBI A,100+X
  8524. ALLC41:! HRLI A,-100+X
  8525. MOVEM A,EC2 >
  8526. SUB A,FSO
  8527. HRRZS B,A
  8528. ASH A,-4
  8529. ALLC02:! ADDI A,400+X
  8530. MOVE C,B
  8531. ASH C,-6
  8532. ALLC30:! ADDI C,1000+X
  8533. ;Stg order= prgm bps fs fws bt btf pdl epdl sp
  8534. MOVEI T,44
  8535. IDIVM A,T
  8536. AOS T ;size of btf
  8537. SUB B,T
  8538. SUB B,A
  8539. SUB B,C ;remaining storage
  8540. MOVEI TT,^D32+1
  8541. IDIVM B,TT ;bt size -1
  8542. SUBI B,1(TT) ;free storage size
  8543. IFE HCBPS,<ADD B,SBPS>
  8544. HRRZ AR4,B
  8545. ADDI B,FS
  8546. HRRZM B,FWSO
  8547. HRRM B,GCP1 ;b hac top of fs
  8548. MOVN SP,B
  8549. HRRM SP,GCMFWS
  8550. HRLZM A,C1GCS ;length of fws
  8551. MOVNS C1GCS
  8552. HRRM B,C1GCS
  8553. ADDI B,-1(A) ;bottom of bt-1
  8554. AOS B
  8555. MOVE SP,FSO
  8556. LSH SP,-5
  8557. SUBM B,SP
  8558. HRRM SP,GCBTP2
  8559. HRRM SP,GCBTP1
  8560. HRLM B,C3GC
  8561. HRRM B,GCP2
  8562. HRRM B,GCP
  8563. HRRZM B,EFWSO
  8564. MOVNI SP,-1(TT)
  8565. HRLM SP,C3GCS
  8566. HRRM B,C3GCS
  8567. AOS B
  8568. MOVE SP,FSO
  8569. ANDI SP,37
  8570. HRRM SP,GCBTL2
  8571. SUBI SP,^D32
  8572. HRRM SP,GCBTL1
  8573. HRRM B,C3GC
  8574. ADDI B,-1(TT)
  8575. HRRM B,C2GCS
  8576. AOS B
  8577. HRRM B,C2GC
  8578. ADDI B,-1(T)
  8579. HRRM B,GCP5
  8580. AOS B
  8581. MOVEI A,OBTBL
  8582. IFE HCBPS,<ADD A,SBPS>
  8583. MOVEM A,(B)
  8584. HRRM B,GCP3
  8585. AOS B
  8586. HRRM B,C2
  8587. MOVNI A,-10(C)
  8588. HRLM A,C2
  8589. IFE HCBPS,<MOVE FF,SBPS>
  8590. IFN HCBPS,<SETZ FF, >
  8591. MOVEI F,BFWS-1(FF)
  8592. JUMPE FF,RLOCA
  8593. MOVEI C,FOOLST
  8594. REL5:! MOVE B,(C) ;Relocate all FS refs w/i system code,
  8595. CDRA A,(B) ; by length of alloc'd BPS, iff HCBPS=0.
  8596. ADD A,FF
  8597. RPLCD A,(B)
  8598. HLR B,B
  8599. CDRA A,(B)
  8600. ADD A,FF
  8601. RPLCD A,(B)
  8602. CAIGE C,EFOLST-1
  8603. AOJA C,REL5
  8604. MOVEI A,TRUTH
  8605. ADD A,FF
  8606. HRLM A,IDCHTAB+"T"-100
  8607. JRST RLOCA ;Uses values in AR4,F,FF.
  8608. PAGE
  8609. ALLNUM:! MOVSI A,400000 ;high bit on for no-digits-seen.
  8610. INCHRW C
  8611. CAIN C,15
  8612. INCHRW C ;<lf> assumed.
  8613. CAIN C,RUBOUT
  8614. JRST [OUTSTR [ASCIZ /XXX /]
  8615. JRST ALLNUM]
  8616. CAIL C,"0"
  8617. CAILE C,"9"
  8618. PRET
  8619. TLZ A,400000 ;turn off hi bit on digit
  8620. ALLRDX:!
  8621. IFN OPSYS,IMULI A,^D10+X ;first a decimal number
  8622. IFE OPSYS,IMULI A,^D8 ;only octal
  8623. ADDI A,-"0"(C)
  8624. JRST ALLNUM+1
  8625. ALCORE:! CAMG A,.JBREL
  8626. PRET ;Already bigger.
  8627. ALCORH:! CALLI A,CORE
  8628. HALT
  8629. PRET
  8630. ALLPDL:! BLOCK 10
  8631. IFN SZBPS,<SBPS:! INITBPS+BOTBPS>
  8632. PAGE
  8633. I=0
  8634. DEFINE GARP (A,B)
  8635. <XWD FOO'A,FOO'B>
  8636. FOO 0
  8637. FOOLST:!
  8638. XLIST
  8639. REPEAT <FOOCNT/2>,<
  8640. GARP (\I,\<I+1>)
  8641. I=I+2>
  8642. LIST
  8643. EFOLST:!
  8644. DEFINE MKENT (A)<
  8645. INTERNAL A>
  8646. ;These are for BIGNUMs (in ARITH)...
  8647. MKENT <NUMV2,FLOOV,FS>
  8648. MKENT <LAST,FIX1A,NUMVAL,REVERSE,LENGTH,XCONS,CONS,CTY,MINUSP>
  8649. MKENT <NUM1,NUM3,FWCONS,FALSE,TRUE,NCONS,IDCONS>
  8650. ;These are for GFPAK
  8651. MKENT <.PLUS,REMAINDER,.COPY,.Q1,MAKBIG,POPAJ>
  8652. ;These are for SCAN...
  8653. MKENT <CHRTAB,RATOM,OLDCH,NOINFG,TYI>
  8654. ;Most of the rest are for ALVINE...
  8655. MKENT <READ,READP1,MAKNUM,PRIN1,PRINT,EXPLODE,EQUAL,SUBST>
  8656. MKENT <LNCT,PAGL,CHCT,LINL,POSN,TYOD,TYID>
  8657. MKENT <GET,INTERN,REMOB,COMPRESS,GENSYM,FIX,LENGTH,PATOM>
  8658. MKENT <MAPLIST,GC,PUT,FIXP,FLOATP,ATMTYP,NATMTYP,IPUTD,IMKCODE>
  8659. MKENT <ERR,MAPCAR,REMPROP,LIST,SETQ,ERRORSET,%APPLY>
  8660. MKENT <SPECSTR,LAMBIND,PROGBIND,INTER0,ATOM,READCH,SET,PRIN2>
  8661. MKENT <FP7A1,TERPRI,LSPRET,BKTRC>
  8662. MKENT <TYO,ITYO,EVAL,APPLY,%EVAL,INPUT,OUTPUT>
  8663. IFE STL,MKENT <READLIST,GETL,SASSOC,SAS1,FLATSIZE>
  8664. IFN AED,MKENT PSAV1
  8665. ;SOME MORE FOR FRICK'S "SHEEP" SYSTEM...
  8666. IFN ASARY,MKENT <ARRAY,ARRAYS,ARREND>
  8667. MKENT <GCMKL,PRINT1,EJECT,OPEN,RDS,WRS,CLOSE,PRINC,GETD,PUTD,DCONSA>
  8668. MKENT <PCHAR,FIXOV,ZERODIV,ILLNUM,STKLOC,ATSOC,EXARG,MKVECT>
  8669. SUPPRESS FOOCNT,I
  8670. END ALLOC