10
20 C%=0:ONERRORGOTO310
30 A%=&82:IF((USR&FFF4)AND&FFFF00)<>&FFFF00:IF?&FFF7<>&6C:PRINT"Must run on 6502 processor":GOTO290
40 A$=$&600+" ":A$=MID$(A$,INSTR(A$," ")):REPEATA$=MID$(A$,2):UNTILASCA$<>32:REPEATA$=LEFT$(A$,LENA$-1):UNTILRIGHT$(A$,1)<>" ":IFA$="":INPUT"MCode file: "A$
50 IFA$=""ORA$="-?":PRINT"Syntax: MCODE <afsp> (<load>)":GOTO290
60 A%=INSTR(A$+" "," "):F$=LEFT$(A$,A%-1):A$=MID$(A$,A%):REPEATA$=MID$(A$,2):UNTILASCA$<>32
70 X%=&700:Y%=7:L%=0:IFA$<>"":L%=EVAL("&"+A$):A$=":PA.=&"+STR$~L%
80 $&720=F$:!X%=&720:A%=5:A%=(USR&FFDD)AND&FF:IFA%<>1:PRINT"File '"F$"' not found":GOTO290
90 IFX%?4=&FF:IFX%?5=&FF:IFX%?8=&FF:IFX%?9=&FF:IFX%!2<X%!6:IFX%?7<&80:X%!10=X%!6-X%!2
100 T%=X%!14:IFL%=0:L%=&7B00-X%!10
110 C%=OPENUP(F$):PTR#C%=X%!10:E%=L%+X%!10:FORZ%=4TO7STEP2:P%=E%:O%=X%:[OPTZ%
120 LDA&FFDA:EOR#&90:CMP#&F0:BCCgo:LDA#7:.go:STA&A9:STARd+2:LDY#0:STY&A8
130 .lp0:LDA(&F2),Y:STA&100,Y:INY:CMP#13:BNElp0:LDY#0
140 .lp1:LDAch,Y:STA(&A8),Y:INY:CMP#42:BNElp1:LDX#0
150 .lp2:LDA&100,X:STA(&A8),Y:CMP#34:BNEnxt:INY:STA(&A8),Y
160 .nxt:INX:INY:CMP#13:BNElp2:STA(&A8),Y:DEY:LDA#34:STA(&A8),Y
170 JSRsw:LDX#b%AND255:LDY#b%DIV256:JMP&FFF7:.ch
180 EQUS"Q%=PA."+A$+":CH.""*":.b%:EQUS"BASIC":EQUB13:.vc:EQUWWr:EQUWRd:EQUWFi
190 .sw:LDY#5:.sw1:LDA&20E,Y:TAX:LDAvc,Y:STA&20E,Y:TXA:STAvc,Y:DEY:BPLsw1:RTS
200 .Rd:LDA&700:INCRd+1:CLC:.Wr:RTS:\JMP&FFCB
210 .Fi:CMP#&FF:BEQP%+5:LDA#0:RTS:STX&A8:STY&A9:JSRsw:BIT&27A:BMItu
220 LDY#2:LDA(&A8),Y:STA&AA:INY:LDA(&A8),Y:STA&AB:LDY#0
230 .lp3:LDAL%,Y:STA(&AA),Y:INY:BNElp3:INC&AB:INClp3+2:BPLlp3:BMIex
240 .tu:LDA#&CF:JSR&406:BCCtu:LDA#2:CLC:ADC&A8:TAX:LDA#0:ADC&A9:TAY
250 LDA#1:JSR&406:.lp4:JSRde:JSRde:LDAL%:STA&FEE5:INClp4+7:BNElp4:INClp4+8
260 BPLlp4:LDA#&8F:JSR&406:.ex:LDA#1:.de:RTS
270 ]NEXT:FORZ%=X%TOO%:BPUT#C%,?Z%:NEXT:CLOSE#C%:C%=0
280 $&720=F$:!X%=&720:X%!2=L%:X%!4=-1:X%!6=E%:X%!8=-1:X%!14=T%:A%=1:CALL&FFDD
290 IF(Q%AND255)<>0ORQ%<&E00ORQ%>&7FFF:Q%=PAGE
300 F$=CHR$13:Q%?1=0:PAGE=Q%:END
310 REPORT:IFC%:D%=C%:C%=0:CLOSE#D%
320 PRINT:GOTO290