10
20 A$=FNOS_GetEnv:Ver$="1.22":PROCWin_TextIO:ftype%=&FFD:load%=-1:exec%=-1:PROCAssemInit
30 fmax%=10:DIMword% 7,cache% 259,file$(fmax%),ptr%(fmax%):eol$=CHR$10:IFos%>31:eol$=CHR$13+CHR$10
40 d$=".":s$="/":IF(os%AND-24):d$="/":s$=".":IF(os%AND-32):d$="\"
50 ONERRORREPORT:PROCCloseAll:PRINT:PROCexit(ERR):END
60 IFRIGHT$(A$,3)=" -v":A$="-v "+LEFT$(A$,LENA$-3)
70 in%=0:out%=0:lst%=0:debug%=FNcl("-d",0):vb%=FNcl("-v",0):ab%=FNcl("-a",0):cp%=VALFNcl("-c",1):quit$=FNcl(" -quit",1)
80 IFFNcl("-?",0):PRINT"Usage: "asm$" [-v] [-Dlabel] [<infile> [<outfile> [<listfile>]]]":PROCexit(0):END
90 A$=" "+A$:A%=INSTR(A$," -D"):REPEAT
100 IFA%:B%=INSTR(A$," ",A%+2):C%=INSTR(A$,"-",A%+2):IFB%=0ORC%=0ORC%>B%:PROCPreLabel:A%=A%-1
110 A%=INSTR(A$," -D",A%+1):UNTILA%=0:A$=MID$(A$,2)
120 in$=FNcl("",0):out$=FNcl("",0):lst$=FNcl("",0):if%=FALSE
130 IFin$=""ORvb%:PRINTcpu$" Assembler v"Ver$;LEFT$("/"+ver$,Ver$<>ver$)
140 IFin$="":INPUTLINE"Input file: "in$:INPUTLINE"Output file: "out$
150 IFin$="":PROCexit(0):END
160 IFdebug%:PRINT" in$='"in$"'"'"out$='"out$"'"'"lst$='"lst$"'"
170 in%=FNopenin("",in$):IFin%=0:PRINT"File '"in$"' not found":PROCexit(214):END
180 IFout$<>"":out$=FNf_name(out$):out%=FNopenout(out$)
190 IFlst$<>"":lst$=FNf_name(lst$):lst%=FNopenout(lst$)
200 ONERRORREPORT:PRINT" ";error$;LEFT$(part$,error$<>"");LEFT$(" ",error$<>"");"in "in$:PROCCloseAll:PROCexit(ERR):END
210 FORpass%=1TO2:PTR#in%=0:Line$="":P%=0:O%=0:L%=0:errs%=0:fnum%=0
220 REPEAT:if%=FALSE:REPEAT:PROCAssemLine:IFpass%=2:PROCPass2
230 P%=P%+num%:O%=O%+num%:UNTILEOF#in%
240 IFif%:IFpass%=2:PROCerr("Missing #ENDIF in "+in$)
250 fnum%=fnum%-1:IFfnum%>-1:in$=file$(fnum%):CLOSE#in%:in%=FNopenin("",in$):PTR#in%=ptr%(fnum%)
260 UNTILfnum%<0:NEXTpass%:PROClst("Errors: "+STR$errs%):PROClst("")
270 PROCCloseAll:ONERRORPROCexit(errs%)
280 IFout$<>"":PROCf_settype(out$,ftype%):PROCf_stamp(out$)
290 IFout$<>"":IFload%<>-1:PROCf_setaddr(out$,load%,exec%)
300 IFlst$<>"":PROCf_settype(lst$,&FFF):PROCf_stamp(lst$)
310 PROCexit(errs%)
320 END
330 DEFPROCPass2:IFnum%>0:IFnum%<256:cache%?num%=0
340 IFop%<>-1:cache%?1=op%DIV256:?cache%=op%
350 IFnum%:IFout%:IFL%=0ORP%<L%:FORA%=0TOnum%-1:BPUT#out%,cache%?A%:NEXT
360 IFlst%ORvb%:PROCAssemList
370 IFerror$<>"":PROCerr(error$+part$)
380 ENDPROC
390 DEFPROCerr(A$):PROClst("****** "+A$):PROClst(""):errs%=errs%-(errs%<127):ENDPROC
400 DEFPROCWin_TextIO:IFos%<32ORPAGE<&FFFF:ENDPROC
410 SYS"GetStdHandle",-10TO@hfile%(1):*INPUT 1
420 SYS"GetStdHandle",-11TO@hfile%(2):*OUTPUT 2
430 ENDPROC
440 DEFPROCCloseAll
450 in% =in%:IFin%:A%=in%:in%=0:CLOSE#A%
460 in0%=in0%:IFin0%:A%=in0%:in0%=0:CLOSE#A%
470 out%=out%:IFout%:A%=out%:out%=0:CLOSE#A%
480 lst%=lst%:IFlst%:A%=lst%:lst%=0:CLOSE#A%
490 ENDPROC
500 DEFPROClst(A$):IFvb%:PRINTA$;:IFA$="":PRINT
510 IFlst%:BPUT#lst%,A$;:IFA$="":BPUT#lst%,eol$;
520 ENDPROC
530 DEFFNvalue(V$):LOCALA%,B%,V%
540 LOCALERROR:ONERRORLOCAL:IFERR=26:error$="Undefined label":=P%ELSEerror$=REPORT$:=P%
550 A%=INSTR(V$,"$+"):IFA%=0:A%=INSTR(V$,"$-")
560 IFA%=0:A%=INSTR(V$,"+$"):IFA%:A%=A%+1
570 IFA%=0:A%=INSTR(V$,"-$"):IFA%:A%=A%+1
580 IFA%:V$=LEFT$(V$,A%-1)+"P%"+MID$(V$,A%+1)
590 REPEAT
600 A%=INSTR(V$,"'"):IFA%:IFMID$(V$,A%+2,1)="'":IFINSTR(V$,"""")=0:V$=LEFT$(V$,A%-1)+STR$ASCMID$(V$,A%+1,1)+MID$(V$,A%+3)ELSEA%=0
610 UNTILA%=0
620 REPEAT
630 A%=0:IFINSTR(V$,"""")=0:A%=INSTR(V$,"@"):IFA%:V$=LEFT$(V$,A%-1)+"&o"+MID$(V$,A%+1)
640 UNTILA%=0
650 A%=INSTR(V$,"&o"):IFA%=0:A%=INSTR(V$,"&O"):IFA%=0:=EVALV$
660 REPEAT:V%=0:B%=A%+2
670 REPEAT:V%=(V%<<3)+VALMID$(V$,B%,1):B%=B%+1
680 UNTILMID$(V$,B%,1)<"0"ORMID$(V$,B%,1)>"7"
690 V$=LEFT$(V$,A%)+STR$~V%+MID$(V$,B%)
700 A%=INSTR(V$,"&o"):IFA%=0:A%=INSTR(V$,"&O")
710 UNTILA%=0
720 =EVALV$
730 DEFPROCSetLabel
740 LOCALERROR:ONERRORLOCAL:IFERR=31:error$="Invalid label name":ENDPROCELSEerror$=REPORT$:Word$="":ENDPROC
750 IFWord$=".BYTE"ORWord$=".WORD":Word$="EQU"+MID$(Word$,2,1):ENDPROC
760 IFWord$=".BLKB":Word$="EQUM":ENDPROC
770 IFWord$=".ASCII"ORWord$=".ASCIIZ":Item$=""""+MID$(Item$,2,LENItem$-2)+""""+LEFT$(",0",RIGHT$(A$,1)="Z"):Word$="EQUB":ENDPROC
780 IFWord$=".ALIGN":PROCALIGN:Word$="":ENDPROC
790 IFWord$=".EVEN":op%=0:num%=(P%AND1):Word$="":ENDPROC
800 IFLEFT$(Label$,1)=".":Label$=MID$(Label$,2)ELSEIFRIGHT$(Label$,1)=":":Label$=LEFT$(Label$,LENLabel$-1)
810 part$=" setting '"+Label$+"'":IFLabel$="_BSS%":L%=P%
820 IFFNuc(LEFT$(Item$,4))<>"EQU ":PROCVar_Assign(Label$,STR$P%):PROCword:ENDPROC
830 IFRIGHT$(Label$,1)="$":PROCVar_Assign(Label$,""""+FNvalue(MID$(Item$,5))+"""")ELSEPROCVar_Assign(Label$,STR$FNvalue(MID$(Item$,5)))
840 Word$="":ENDPROC
850 DEFPROCPreLabel:LOCALL$,V$:IFB%=0:B%=LENA$+1
860 L$=MID$(A$,A%+3,B%-A%-3):A$=LEFT$(A$,A%-1)+MID$(A$,B%)
870 A%=INSTR(L$,"="):IFA%:V$=MID$(L$,A%+1):L$=LEFT$(L$,A%-1)ELSEV$="-1"
880 PROCVar_Assign(L$,V$):ENDPROC
890 DEFFNo0(A%,N%):LOCALA$,B%,L%:IFA%<0:B%=2:A%=A%AND&7FFFFFFF
900 REPEATA$=STR$(A%AND7)+A$:A%=A%DIV8:L%=L%+3:UNTILL%>27:=RIGHT$(STR$(A%+B%)+A$,N%)
910 DEFFNuc(A$):LOCALB$:IFA$="":=""
920 REPEATB$=B$+CHR$(ASCA$AND((A$<"@")OR&DF)):A$=MID$(A$,2):UNTILA$="":=B$
930 DEFPROCword:A%=INSTR(Item$+" "," "):Label$=LEFT$(Item$,A%-1):Word$=FNuc(Label$):Item$=FNs(MID$(Item$,A%+1)):ENDPROC
940 DEFPROCEQU:byte%=1:IFWord$="EQUM":num%=FNvalue(Item$):PROCFill:Word$="":ENDPROC
950 num%=0:size%=INSTR("SBW D",RIGHT$(Word$,1))-1:size%=size%-(size%=0):byte%=size%:IFbyte%>2:byte%=2
960 REPEAT:PROCEQUItem:Item$=FNs(MID$(Item$,INSTR(Item$+",",",")+1))
970 UNTILItem$=""ORnum%>252:IFnum%>252:error$="Equate item too long"
980 Word$="":ENDPROC
990 DEFPROCEQUItem:type%=TRUE
1000 LOCALERROR:ONERRORLOCALtype%=type%+1:IFtype%:RESTOREERROR:ERRORERR,REPORT$
1010 IFtype%:cache%!num%=FNvalue(Item$):num%=num%+size%:ENDPROC
1020 IFLEFT$(Item$,1)="""":A%=INSTR(Item$,"""",2):IFA%:IFMID$(A$,A%+1,1)<>"+":A$=MID$(Item$,2,A%-2):Item$=MID$(Item$,A%+1)ELSEA$=FNvalue(Item$)
1030 $(cache%+num%)=A$:num%=num%+LENA$:byte%=1
1040 ENDPROC
1050 DEFPROCALIGN:num%=(P%AND1):byte%=1:IFItem$<>"":num%=FNvalue(Item$):num%=((P%+num%)AND(-num%))-P%
1060 PROCFill:ENDPROC
1070 DEFPROCFill:IFnum%>0:IFnum%<257:FORA%=0TOnum%-1:cache%?A%=0:NEXT:op%=0
1080 IFnum%<0:error$="Code overrun"
1090 ENDPROC
1100 DEFPROCAssemLine:Item$="":Word$="":num%=0:op%=-1:error$="":part$="":byte%=1
1110 Line$=GET$#in%:IFLine$="":IFPTR#in%>1:PTR#in%=PTR#in%-2:IFBGET#in%<>BGET#in%:Line$=GET$#in%
1120 REPEATA%=INSTR(Line$,CHR$9):IFA%:Line$=LEFT$(Line$,A%-1)+STRING$(8-(A%-1)MOD8," ")+MID$(Line$,A%+1)
1130 UNTILA%=0:IFdebug%:PRINTLine$
1140 A%=INSTR(Line$+";",";"):Text$=LEFT$(Line$,A%-1):Line$=MID$(Line$,A%)
1150 Item$=FNs(Text$):IFItem$="":ENDPROC
1160 PROCword:IFLEFT$(Word$,1)="#":PROCControl:ENDPROC
1170 IFif%:ENDPROC
1180 IFLEFT$(Word$,1)="."ORRIGHT$(Word$,1)=":":PROCSetLabel:IFWord$="":ENDPROC
1190 IFLEFT$(Word$,3)="EQU":PROCEQU:ENDPROC
1200 IFWord$="ORG":P%=FNvalue(Item$):ENDPROC
1210 IFWord$="ALIGN":PROCALIGN:ENDPROC
1220 PROCAssem:ENDPROC
1230 DEFPROCControl
1240 IFWord$="#ENDIF":if%=if%DIV2:ENDPROC
1250 IFWord$="#ELSE":if%=if%EOR1:ENDPROC
1260 IFWord$="#IF":PROCIf(FNvalue(Item$)=0):ENDPROC
1270 IFWord$="#IFDEF":PROCIfDef:ENDPROC
1280 IFWord$="#IFNDEF":PROCIfDef:if%=if%EOR1:ENDPROC
1290 IFif%:ENDPROC
1300 IFWord$="#INCLUDE":PROCInclude:ENDPROC
1310 IFWord$="#ERROR":error$=Item$:ENDPROC
1320 IFWord$="#DEFINE":PROCword:Item$="EQU "+Item$+LEFT$("-1",Item$=""):PROCSetLabel:ENDPROC
1330 ENDPROC
1340 DEFPROCIf(A%):if%=if%*2+(A%AND1):ENDPROC
1350 DEFPROCIfDef:IFRIGHT$(Item$,1)="$":V%=FNvalue("LEN("+Item$+")")ELSEV%=FNvalue(Item$)
1360 PROCIf(error$<>""ANDERR=26):error$=LEFT$(error$,ERR<>26):ENDPROC
1370 DEFPROCInclude
1380 LOCALERROR:ONERRORLOCAL:error$="#include "+Item$+": "+REPORT$:ENDPROC
1390 IFLEFT$(Item$,1)="<":P$=FNfn_path(run$)+"lib"+d$ELSEP$=FNfn_path(in$)
1400 F$=Item$:IFINSTR("<""",LEFT$(F$,1)):F$=MID$(F$,2,LENF$-2)
1410 in0%=FNopenin(P$,F$)
1420 IFin0%=0:IFLEFT$(Item$,1)="<":P$=FNfn_path(in$):in0%=FNopenin(P$,F$)
1430 IFin0%=0:P$="":in0%=FNopenin(P$,F$)
1440 IFin0%=0:error$="#include "+Item$+" not found":ENDPROC
1450 file$(fnum%)=in$:ptr%(fnum%)=PTR#in%:fnum%=fnum%+1
1460 CLOSE#in%:in%=in0%:in0%=0:in$=P$+F$:ENDPROC
1470 DEFFNopenin(P$,A$):LOCALin0%
1480 LOCALERROR:ONERRORLOCAL:IF(ERRAND255)=&CC:A%=LENFNfn_path(A$):A$=LEFT$(A$,A%)+LEFT$(MID$(A$,A%+1),10)ELSE=0
1490 in0%=OPENIN(P$+FNf_name(A$)):IFin0%:=in0%
1500 A$=A$+s$+ext$:in0%=OPENIN(P$+A$):IFin0%:=in0%
1510 A$=LEFT$(A$,LENA$-LENext$-1)
1520 FORA%=1TOLENA$:IFMID$(A$,A%,1)="\":MID$(A$,A%,1)="/"
1530 IF(ASCMID$(A$,A%,1)AND&FE)=46:MID$(A$,A%,1)=CHR$(ASCMID$(A$,A%,1)EOR1)
1540 NEXTA%:=OPENIN(P$+FNf_name(A$))
1550 DEFFNopenout(A$):IFA$="":=0
1560 A%=OPENOUT(A$):IFA%:=A%
1570 PRINT"Can't open '"A$"'":PROCCloseAll:PROCexit(192):END
1580 =0
1590 DEFFNfn_path(A$):LOCALA%,B%:A%=INSTR(A$,":",2)
1600 REPEATB%=A%:A%=INSTR(A$,d$,A%+1):UNTILA%=0:=LEFT$(A$,B%)
1610 DEFFNf_name(A$):IFos%>31:LOCALA%,B%:REPEATB%=A%:A%=INSTR(A$,"\",A%+1):UNTILA%=0:IFINSTR(A$,".",B%)=0:A$=A$+"."
1620 =A$
1630 DEFPROCf_settype(A$,A%):IFos%>8:ENDPROC
1640 OSCLI"SetType "+A$+" "+STR$~A%:ENDPROC
1650 DEFPROCf_stamp(A$):IFos%>8:ENDPROC
1660 OSCLI"Stamp "+A$:ENDPROC
1670 DEFPROCf_setaddr(A$,L%,E%):ENDPROC
1680 DEFPROCAssemInit:cpu$="PDP11":asm$="AsmPDP":ftype%=&1C5:ext$="mac":ver$="1.20":ENDPROC
1690 DEFPROCAssemList:PROClst(FNo0(P%,6)):IFnum%:PROCAssemList1
1700 IFbyte%=2:PROClst(STRING$(1+7*(3-((num%-1)AND6)/2-4*(num%=0))," "))
1710 IFbyte%<>2:IFnum%:IF((num%-1)AND7)>6:PROClst(""):IF(num%AND7)=0:PROClst(STRING$(6," "))
1720 IFbyte%<>2:PROClst(STRING$(1+4*(7-(num%AND7))," "))
1730 IFText$<>"":PROClst(Text$)
1740 A%=(24-LENLEFT$(Text$,24))AND(Text$<>""):IFA%:IFLine$<>"":PROClst(STRING$(A%," "))
1750 IFLine$<>"":PROClst(Line$)
1760 PROClst(""):ENDPROC
1770 DEFPROCAssemList1:FORA%=0TOnum%-1STEP1-(byte%=2):IFA%:IF(A%AND7)=0:PROClst(""):PROClst(STRING$(6," "))
1780 IFbyte%=2:PROClst(" "+FNo0(cache%!A%AND&FFFF,6))ELSEPROClst(" "+FNo0(cache%?A%,3))
1790 NEXT:ENDPROC
1800 DEFPROCAssem
1810 byte%=2:num%=2:IFWord$="BSS":L%=P%:_BSS%=P%:num%=0:ENDPROC
1820 A%=INSTR("CLRCOMINCDECNEGADCSBCTSTRORROLASRASL",LEFT$(Word$,3))
1830 IFA%:IF(A%-1)MOD3=0:op%=5*8*8*8+(A%DIV3)*8*8+FNbyte+FNdd(Item$):ENDPROC
1840 A%=INSTR("MOVCMPBITBICBIS",LEFT$(Word$,3))
1850 IFA%:IF(A%-1)MOD3=0:op%=((A%+2)DIV3)*8*8*8*8+FNbyte+FNsd(Item$):ENDPROC
1860 A%=INSTR("BPLBMIBHIBLSBVCBVSBCCBCS",Word$)
1870 IFA%=0:A%=INSTR("BLO BHISBLOS",Word$):IF(A%-1)MOD4=0:A%=(7-A%DIV4)*3+1:IFA%=16:A%=10
1880 IFA%:IF(A%-1)MOD3=0:op%=(A%DIV3)*256+1*8*8*8*8*8+FNdisp(Item$):ENDPROC
1890 A%=INSTR(CHR$0+CHR$0+CHR$0+"BR BNEBEQBGEBLTBGTBLE",Word$)
1900 IFA%:IF(A%-1)MOD3=0:op%=(A%DIV3)*256+FNdisp(Item$):ENDPROC
1910 IFWord$="ADD":op%=6*8*8*8*8+FNsd(Item$):ENDPROC
1920 IFWord$="SUB":op%=14*8*8*8*8+FNsd(Item$):ENDPROC
1930 A%=INSTR("MUL DIV ASH ASHCXOR",Word$)
1940 IFA%:IF(A%-1)MOD4=0:op%=7*8*8*8*8+(A%DIV4)*8*8*8+FNrd(Item$,A%<16):ENDPROC
1950 IFWord$="JSR":op%=4*8*8*8+FNrd(Item$,0):ENDPROC
1960 IFWord$="JMP":op%=1*8*8+FNdd(Item$):ENDPROC
1970 IFWord$="SWAB":op%=3*8*8+FNdd(Item$):ENDPROC
1980 IFWord$="SXT":op%=6*8*8*8+7*8*8+FNdd(Item$):ENDPROC
1990 IFWord$="RTS":A%=FNr(Item$):op%=2*8*8+A%:error$=LEFT$("Missing register",A%<0):ENDPROC
2000 IFWord$="CSM":op%=7*8*8*8+FNdd(Item$):ENDPROC
2010 IFWord$="EMT":op%=68*8*8*8+FNvalue(Item$):ENDPROC
2020 IFWord$="TRAP":op%=68*8*8*8+4*8*8+FNvalue(Item$):ENDPROC
2030 IFWord$="MARK":op%=6*8*8*8+4*8*8+FNvalue(Item$):ENDPROC
2040 IFWord$="SPL":op%=2*8*8+3*8+FNvalue(Item$):ENDPROC
2050 A%=INSTR("MTPSMFPDMTPDMFPS",LEFT$(Word$,4))
2060 IFA%:IF(A%-1)MOD4=0:op%=1*8*8*8*8*8+6*8*8*8+(A%DIV4+4)*8*8+FNdd(Item$):ENDPROC
2070 A%=INSTR("MFPIMTPI",LEFT$(Word$,4))
2080 IFA%:IF(A%-1)MOD4=0:op%=6*8*8*8+(A%DIV4+5)*8*8+FNdd(Item$):ENDPROC
2090 IFWord$="SOB":A%=INSTR(Item$,","):op%=63*8*8*8+FNr(LEFT$(Item$,A%-1))*8*8+FNdisp6(MID$(Item$,A%+1)):ENDPROC
2100 IFLEFT$(Word$,2)="CL":op%=160+INSTR("CV N N",MID$(Word$,3,1)):ENDPROC
2110 IFLEFT$(Word$,2)="SE":op%=176+INSTR("CV N N",MID$(Word$,3,1)):ENDPROC
2120 A%=INSTR("HALT WAIT RTI BPT IOT RESETRTT MFPT ",Word$)
2130 IFA%:IF(A%-1)MOD5=0:op%=A%DIV5:ENDPROC
2140 IFWord$="CCC":op%=175:ENDPROC
2150 IFWord$="SCC":op%=191:ENDPROC
2160 IFWord$="NOP":op%=160:ENDPROC
2170 IFWord$="ADR"ORWord$="ADDR":PROCADR:ENDPROC
2180 num%=0:error$="Unknown opcode":ENDPROC
2190 DEFFNbyte:IFLENWord$=4:IF(MID$(Word$,4,1)="B"):=8*8*8*8*8
2200 IFLENWord$<>3:error$="Bad opcode suffix"
2210 =0
2220 DEFPROCADR:IFab%:Word$="MOV":Item$="#"+Item$:PROCAssem:ENDPROC
2230 Line0$=Line$:Text0$=Text$:Item0$=Item$
2240 A%=INSTR(Item0$,","):Word$="MOV":Item$="PC"+MID$(Item0$,A%):PROCAssem:op0%=op%
2250 A%=INSTR(Item0$,","):Word$="ADD":Item$="#"+LEFT$(Item0$,A%-1)+"-$-2"+MID$(Item0$,A%):PROCAssem
2260 num%=num%+2:cache%!4=cache%!2:cache%?3=op%DIV256:cache%?2=op%:op%=op0%
2270 Line$=Line0$:Text$=Text0$:Item$=Item0$:ENDPROC
2280 DEFFNmr(A$):LOCALA%,m%,r%,v%:A$=FNs(A$)
2290 IFLEFT$(A$,1)="(":IFRIGHT$(A$,1)=")":m%=1
2300 IFLEFT$(A$,1)="@":m%=1:A$=MID$(A$,2)
2310 IFLENA$=2:r%=FNr(A$):IFr%>-1:=m%*8+r%
2320 IFLEFT$(A$,1)="#":v%=FNvalue(MID$(A$,2))AND&FFFF:num%=num%+2:=(m%+2)*8+7+256*v%
2330 IFRIGHT$(A$,1)="+":m%=m%+2:A$=LEFT$(A$,LENA$-1)
2340 IFLEFT$(A$,2)="-(":m%=m%+4:A$=MID$(A$,2)
2350 A%=INSTR(A$,"("):IFA%:IFRIGHT$(A$,1)<>")":error$="Missing ')'":=-1
2360 IFA%:r%=FNr(MID$(A$,A%+1,2)):A$=LEFT$(A$,A%-1)ELSEr%=7
2370 IFA$<>"":v%=FNvalue(A$)AND&FFFF:m%=m%+6:num%=num%+2
2380 IFr%=7:IFm%>5:v%=(v%-P%-num%)AND&FFFF
2390 IFr%<0:error$="Missing register"
2400 =m%*8+r%+256*v%
2410 DEFFNr(A$):LOCALA%:A$=FNuc(A$):IFLENA$<>2:=-1
2420 IFA$="PC":=7
2430 IFA$="SP":=6
2440 IFLEFT$(A$,1)<>"R":=-1
2450 IFRIGHT$(A$,1)<"0"ORRIGHT$(A$,1)>"7":=-1
2460 =VALRIGHT$(A$,1)
2470 DEFFNsd(A$):LOCALA%,src%,dst%,n%:A%=INSTR(A$,","):IFA%=0:error$="Missing ,":=0
2480 part$=" in source":n%=num%:src%=FNmr(LEFT$(A$,A%-1)):IFsrc%<0:=0
2490 IFn%<>num%:cache%!n%=src%DIV256:src%=src%AND63
2500 IFerror$="":part$=" in destination"
2510 n%=num%:dst%=FNmr(MID$(A$,A%+1)):IFdst%<0:=0
2520 IFn%<>num%:cache%!n%=dst%DIV256:dst%=dst%AND63
2530 =64*src%+dst%
2540 DEFFNrd(A$,f%):LOCALA%,r%,dst%,n%:n%=num%:A%=INSTR(A$,","):IFA%=0:error$="Missing ,":=0
2550 IFf%:r%=FNr(FNs(MID$(A$,A%+1)))ELSEr%=FNr(FNs(LEFT$(A$,A%-1)))
2560 IFr%<0:error$="Missing register":=0
2570 IFf%:dst%=FNmr(LEFT$(A$,A%-1))ELSEdst%=FNmr(MID$(A$,A%+1))
2580 IFn%<>num%:cache%!n%=dst%DIV256:dst%=dst%AND63
2590 =64*r%+dst%
2600 DEFFNdd(A$):LOCALA%,dst%,n%:n%=num%:dst%=FNmr(A$):IFn%<>num%:cache%!n%=dst%DIV256:dst%=dst%AND63
2610 IFINSTR(A$,","):error$="Too many operands"
2620 =dst%
2630 DEFFNdisp(A$):A%=(FNvalue(A$)-P%-2)/2:IFA%<-128ORA%>127:IFerror$="":error$="Branch out of range"
2640 =A%AND&FF
2650 DEFFNdisp6(A$):A%=(FNvalue(A$)-P%-2)/2:IFA%<-32ORA%>31:IFerror$="":error$="Branch out of range"
2660 =A%AND&3F
2670 DEFFNOS_GetEnv:LOCALA$,A%,X%,Y%:X%=1:os%=((USR&FFF4)AND&FF00)DIV256
2680 IF!PAGE=&D7C1C7C5:run$=ARGV$(0):FORA%=1TOARGC:A$=A$+ARGV$(A%)+" ":NEXT:=A$
2690 IFos%>31:IFPAGE>&FFFFF:DIMX%LOCAL256:SYS"GetModuleFileName",0,X%,255:run$=$$X%:=@cmd$
2700 A%=&600-&7B00*(PAGE>&8000)-&3F00*(PAGE>&C000):IF!(PAGE-&100)=@%:A%=PAGE-&300
2710 IF?(TOP-3)=0:A%=&100:IFHIMEM<&FFFF:A%=PAGE-&300:IF!(HIMEM+512)=@%:A%=HIMEM
2720 A$=$A%:IFPAGE=&8F00:run$=A$:SYS16TOA$,,A%:SYS72,"",A%:A$=MID$(A$,1+INSTR(A$+" "," ",1+INSTR(A$," "))):IFLENA$=0:A$=run$
2730 FORY%=-1TO0:A$=" "+A$:REPEATA$=MID$(A$,2):UNTILASCA$<>32:IFASCA$=34:A%=INSTR(A$,"""",2)+1ELSEA%=INSTR(A$+" "," ")
2740 IFY%:run$=MID$(A$,1-(ASCA$=34),A%-1+2*(ASCA$=34)):A$=MID$(A$,A%+1)
2750 NEXT:=A$
2760 DEFPROCos(A$):IFASCA$=42:OSCLIA$ELSEIFLENA$:CHAINA$
2770 ENDPROC
2780 DEFPROCexit(A%):OSCLI"FX1,"+STR$(A%AND255):quit$=quit$:A$=quit$:quit$="":PROCos(A$)
2790 IFPAGE>&FFFFF:QUITA%ELSEEND
2800 ENDPROC
2810 DEFFNcl(l$,n%):IFl$="":A$=FNs(A$):IFASCA$=34:A%=INSTR(A$+" "" ",""" ",2):l$=MID$(A$,2,A%-2):A$=FNs(MID$(A$,A%+1)):=l$
2820 IFl$="":A%=INSTR(A$+" "," "):l$=LEFT$(A$,A%-1):A$=FNs(MID$(A$,A%+1)):=l$
2830 IFn%=0:IFl$<>"":A%=INSTR(A$,l$):IFA%:A$=FNs(LEFT$(A$,A%-1)+MID$(A$,INSTR(A$," ",A%)+1))+" ":=TRUE
2840 IFn%=0:IFl$<>"":=FALSE
2850 A%=INSTR(LEFT$(" ",ASCl$=32)+A$,l$):IFA%=0:=""
2860 A$=LEFT$(A$,A%-1)+FNs(MID$(A$,INSTR(A$," ",A%)+1))
2870 IFASCl$=32:l$=MID$(A$,A%):A$=LEFT$(A$,A%-1):=MID$(l$,1-(ASCl$=34),LENl$+2*(ASCl$=34))
2880 IFASCMID$(A$,A%,1)<>34:l$=MID$(A$,A%,INSTR(A$+" "," ",A%)-A%):A$=LEFT$(A$,A%-1)+MID$(A$,A%+LENl$+1):=l$
2890 l$=MID$(A$,A%+1,INSTR(A$+" ",""" ",A%+1)-A%-1):A$=LEFT$(A$,A%-1)+MID$(A$,A%+LENl$+3):=l$
2900 DEFFNs(A$):IFLEFT$(A$,1)=" ":REPEATA$=MID$(A$,2):UNTILLEFT$(A$,1)<>" "
2910 IFRIGHT$(A$,1)=" ":REPEATA$=LEFT$(A$,LENA$-1):UNTILRIGHT$(A$,1)<>" "
2920 =A$
2930 DEFPROCVar_Assign(N$,V$):Var_%=Var_%:A%=2*(?(TOP-3)>0)-1
2940 IFVar_%=0:LOCALB%:B%=TOP-4:REPEAT:B%=B%-1:UNTILB%?A%=13ANDB%?(?B%+A%)=13:Var_%=B%
2950 IFLENN$>?Var_%-12:error$="Expression too long":ENDPROC
2960 $(Var_%+4+A%)=N$+"="+CHR$&A0+"(V$):"+CHR$&E1:IF1
2970 ENDPROC:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!