/*********************************************************/ /* */ /* PISTOL-Portably Implemented Stack Oriented Language */ /* Version 1.3 */ /* (C) 1982 by Ernest E. Bergmann */ /* Physics, Building #16 */ /* Lehigh Univerisity */ /* Bethlehem, Pa. 18015 */ /* */ /* Permission is hereby granted for all reproduction and */ /* distribution of this material provided this notice is */ /* is included. */ /* */ /*********************************************************/ /* second pistol module, February, 1982 */ #include "bdscio.h" #include "pistol.h" init() {int psemcol(),wstore(),times(),plus(),subtract(), divmod(),pif(),wat(),abort(),sp(), load(),pelse(),wrd(),rp(),drop(), puser(),exec(),exitop(),lit(),rpop(), swap(),tyi(),tyo(),rpsh(),semicf(), rat(),compme(),comphere(),dollarc(),colon(), semcol(),ifop(),elseop(),thenop(),doop(), loopop(),beginop(),endop(),repet(),geoln(),pdollar(), pcolon(),casat(),pdo(),pploop(),plloop(), cat(),cstore(),ploop(),gt(),semidol(), kernq(),strange(),sat(),findop(),listfil(), lat(),ofcas(),ccolon(),semicc(),ndcas(), pofcas(),pccol(),psemicc(),getline(),intoken(), openr(),openw(),readl(),writl(),cordmp(), restor(); farray[PSEMICOL]=psemcol; farray[WSTORE]=wstore; farray[TIMES]=times; farray[PLUS]=plus; farray[SUBTRACT]=subtract; farray[DIVMOD]=divmod; farray[PIF]=pif; farray[WAT]=wat; farray[ABRT]=abort; farray[SP]=sp; farray[LOAD]=load; farray[PELSE]=pelse; farray[WRD]=wrd; farray[RP]=rp; farray[DROPOP]=drop; farray[PUSER]=puser; farray[EXEC]=exec; farray[EXITOP]=exitop; farray[STRLIT]=farray[LIT]=lit; farray[RPOP]=rpop; farray[SWP]=swap; farray[TYI]=tyi; farray[TYO]=tyo; farray[RPSH]=rpsh; farray[SEMICF]=semicf; farray[RAT]=rat; farray[COMPME]=compme; farray[COMPHERE]=comphere; farray[DOLLARC]=dollarc; farray[COLON]=colon; farray[SEMICOLON]=semcol; farray[IFOP]=ifop; farray[ELSEOP]=elseop; farray[THENOP]=thenop; farray[DOOP]=doop; farray[LOOPOP]=loopop; farray[BEGINOP]=beginop; farray[ENDOP]=endop; farray[REPET]=repet; farray[PERCENT]=geoln; farray[PDOLLAR]=pdollar; farray[PCOLON]=pcolon; farray[CASAT]=casat; farray[PDOOP]=pdo; farray[PPLOOP]=pploop; farray[PLLOOP]=plloop; farray[CAT]=cat; farray[CSTORE]=cstore; farray[PLOOP]=ploop; farray[GT]=gt; farray[SEMIDOL]=semidol; farray[KRNQ]=kernq; farray[53]=farray[54]=strange; farray[SAT]=sat; farray[FINDOP]=findop; farray[LISTFIL]=listfil; farray[58]=strange; farray[LAT]=lat; farray[OFCAS]=ofcas; farray[CCOLON]=ccolon; farray[SEMICC]=semicc; farray[NDCAS]=ndcas; farray[POFCAS]=pofcas; farray[PCCOL]=pccol; farray[PSEMICC]=psemicc; farray[GTLIN]=getline; farray[WORD]=intoken(); farray[OPENR]=openr; farray[OPENW]=openw; farray[READL]=readl; farray[WRITL]=writl; farray[CORDMP]=cordmp; farray[RESTOR]=restor; penter(2,"W!",WSTORE); penter(1,"*",TIMES); penter(1,"+",PLUS); penter(1,"-",SUBTRACT); penter(4,"/MOD",DIVMOD); penter(2,"W@",WAT); penter(5,"ABORT",ABRT); penter(2,"SP",SP); penter(4,"LOAD",LOAD); penter(1,"W",WRD); penter(2,"RP",RP); penter(4,"DROP",DROPOP); penter(4,"USER",PUSER); penter(4,"EXEC",EXEC); penter(4,"EXIT",EXITOP); penter(2,"R>",RPOP); penter(4,"SWAP",SWP); penter(3,"TYI",TYI); penter(3,"TYO",TYO); penter(2,"MAXLINNO) {movmem(ram[-11].pc+1,infil1, *ram[-11].pc); infil1[*ram[-11].pc]='\0'; if(fopen(infil1,ldfil1) == ERROR) {printf("can't open %s\n", infil1); abort(); } ram[-29].in=0; } } pelse() { Pw=ip; ip += *Pw;} wrd() { push(W); } rp() { push(rptr); } puser() { push(ram); } exec() { instr=stack[stkptr]; drop(); if(instr<(RESTOR+1)) (*farray[instr])(); else {rpush(ip);ip=instr;} } exitop() { if(lptr<3) abort(); else lstack[lptr]=lstack[lptr-1]; } lit() { Pw=ip; push(*Pw); ip +=W; } rpop() { push(rstack[rptr]);rptr--; } tyo() { drop(); chout(stack[stkptr+1]); } rpsh() { rpush(stack[stkptr]);drop(); } semicf() { if(ram[-24].in) carret(); if((ram[-11].in0)) {ram[-11].in--; printf("\n THROUGH LINE %d(DECIMAL) LOADED\n", ram[-11].in); if(ram[-12].in) fprintf(list, "\n THROUGH LINE %d(DECIMAL) LOADED\n", ram[-11].in); } if(ram[-11].in>=MAXLINNO) {printf("%s LOADED\n",infil1); if(ram[-12].in) fprintf(list,"%s LOADED\n",infil1); } ram[-11].in=0; } rat() { drop(); if(rptr