þþþ6dX;SAVE#D:DMPT3.M65nX;--------------------xX;‚X;Memory disassemblerŒX;–X; by: Bryan Schappel X;ªX;--------------------´X;¾‡DISAMEM%>;;zero YÈ'„HXDC;;in hexÒ '…BYTESÜ †GETBYT;;get opcodeæIƒD.1;;error?ð!†D_OVER;;yes!úX;ƒD.1P‚OP;;save op%>;;zero Y…FNDOPR†OPCODE8;;is op in"F…HAVOP;;the opcode, 3;;table?6)>—;;151 yet?@H…FNDOP;;no.JX;T…HAVOP'‚Y2;;save Y^ „ZBUF;;clear bufferhQ„ADDR;;copy addrrPƒFR0;;to FP| Q„ADDR† PƒFR0$>;;pos. 23š ‡COPYNUM;;copy it¤ ƒZFR;;clear FP®Q‚OP;;get op¸PƒFR0;;in FPÂ$>;;pos 28Ì ‡COPYNUM;;copy itÖQ> ;à P„IBUFê%‚Y2;;get Yô)>—;;legal instr?þH„N151;;yes.X;%>;;copy 8 chars„CP.BQ†POINTB8;;get char&P„IBUF8;;put in buffer01;;decrease index:I„CP.B;;and loopD ƒZFR;;zap FR0N%‚OP;;get the byteX'ƒFR0;;put in FR0b ‡BIN2HEX;;make it hexlQ>;;force 1 bytev P…NBYTE€$>;;posit 8Š „SOME;;copy number”!…AEOL1;;and add EOL.žX;¨„N151$†OFFSET8;;MNE offset²%>;;copy out the¼…ADMNEQƒMNE9;;Mnemonic andÆP„IBUF8;;put inÐ 2;;buffer.Ú3ä)>;;3 chars?îH…ADMNE;;no.ø P…NBYTE%‚Y2;;restore Y Q…ITYPE8;;get Itype?;;transfer to Y Q…NBTAB8;;get # bytes for*P…NBYTE;;this instr.4C;;restore Acc.>T?;;times 2H ?;;in YRQ…DCOMT8;;look up the\P„DJSR;;routine addrfQ…DCOMT8;;an put inpP„DJSR;;JSRz$…NBYTE;;get # bytes„ 0;;sub 1.ŽF„DJSR;;if 0, skip!˜ †GETBYT;;get next one¢G†D_OVER;;oops, error.¬P…DTEMP;;save byte¶$…NBYTE;;get count againÀ 0;;sub 2.Ê0ÔF„DJSR;;if 0, skipÞ †GETBYT;;get 3rd byteèG†D_OVER;;oops, error.òP…DTEMP;;save this byteüX;„DJSR ÿÿ;;go command!…AEOL1%>';;now insert…AEOL3Q„IBUF8;;the EOL$R> ;;character. H…AEOL281B I…AEOL3L…AEOL2Q>ƒEOLV P„IBUF8`Q>j P„IBUF8tQ„ADDR;;now add the~,;;number ofˆO…NBYTE;;byte to the’P„ADDR;;adr pointerœDƒAE1;;to get next¦#„ADDR;;instr addr.°ƒAE1:;;bye.ºX;ÄX;Disassembly OverÎX;Ø!†D_OVER ˆANY_LEFT;;send extra.â#…SFLAG;;set swap flagì ˆSEND_OUT;;write bufferö$>;;slam IOCB #1 …CLOSE $> ;;slam IOCB #2 …CLOSE †PRINT ˆALL.DONE;;done mess.( ‡GET_RET;;get a return2!…INTRO;;goto intro.<X;FX;Immediate ModePX;Z…IMMED †LOBYTE;;insert LSBdQ> #;;a '#'nP„IBUF;;in bufferx ƒZFR;;zap FR0‚Q…DTEMP;;get byteŒPƒFR0;;into FR0–$>;;and add to the !‡COPYNUM;;output.ªX;´…NUMBRQ>;;zero MSB¾ P…DTEMPȆNUMBR2Q…DTEMP;;put in FR0ÒPƒFR0Ü Q…DTEMPæ PƒFR0ð†NUMBR3$>;;# in pos. 6úQ>4ƒLAB;;point to theP„INDR;;label table Q>5ƒLAB P„INDR"Q‡LABELS?;;want labels?,H†GO_OUT;;nope.6X;@X;This is the Location LabelJ!X;search algorithm. The labelT X;data are stored as follows:^X;h X;hi nybble-byte 1 loc lengthr"X;lo nybble-byte 1 label length|!X;location hi,location lo, and†X;the label name.X;šˆLAB_SRCH%>;;zero index¤Q@„INDR7;;get a byte.®H„N_FF;;<>0 then cont.¸ †GO_OUT!‡COPYNUM;;just numberÂX;Ì„N_FF5;;save byteÖM>;;get label lenàP„TMP1;;save it.ê7;;get byte backôV?;;shift it downþV?V?V?P†ADD_ON;;save it&#†ADD_ON;;add one.03;;move up 2: 3;;bytes.DQ@„INDR7;;get addr loNP…LOC_S;;save it.X,;;add on locationbO†ADD_ON;;length & save.l P…LOC_Ev1;;down index€Q@„INDR7;;get addr hiŠP…LOC_S;;save”O>;;add carryžP…LOC_E;;and store.¨X;²Q…DTEMP;;instr hi¼R…LOC_S;;equal to lochi?ÆH…N.TST;;no.ÐQ…DTEMP;;test loÚ R…LOC_SäF„D_CP;;exact match!îX;ø"…N.TSTQ…DTEMP;;now we see ifR…LOC_E;;the instr addr F…TST.L;;is in the rangeE…GO_UP;;of the location …TST.LQ…DTEMP* R…LOC_E4 E…GO_UP>X;HQ…DTEMP;;test hiR R…LOC_S\D†GO_OUT;;not in rangefQ…DTEMP;;test lop R…LOC_SzD†GO_OUT;;not in range„„D_CP;;;calc actualŽS…LOC_S;;offset for the˜P†ADD_ON;;+x add on.¢X;¬ 0;;posit 5¶%>;;start at pos 2À„C_CP3;;up YÊ 2;;up XÔQ@„INDR7;;get label nameÞP„IBUF9;;from the tableèI„C_CP;;and insert intoòM>;;disa line.ü P„IBUF9 Q†ADD_ON;;exact match? H„PLUS;;no. :;;so long.$ X;. „PLUSQ> +;;put in a '+'8 P„IBUF9B 2L 2V  ƒZFR;;zap FR0` Q†ADD_ON;;make offset toj PƒFR0;;a decimal #t #„HXDC~  ‡COPYNUM;;insert numberˆ "„HXDC;;force hex’ :;;and leave.œ X;¦ …GO_UPQ„INDR;;get the label° ,;;pointer andº O„TMP1;;add on the lenÄ P„INDR;;of the label soÎ Q„INDR;;we can searchØ O>;;more.â P„INDRì !ˆLAB_SRCH;;loop!ö X; X;Zero page X; „ZPAG †LOBYTE;;do LSB !…NUMBR;;add arg( X;2 X;Zero page,X< X;F …ZPAGX †LOBYTE;;LSBP  …NUMBR;;add argZ …ADDX2%>;;just ,Xd „ADDX2;;up Xn …ADDX3Q†COMMAX8;;copy thex P„IBUF9;;,X into‚ 0;;the bufferŒ 1– I…ADDX3  :;;done.ª X;´ X;Absolute¾ X;È …ABSOL †LOBYTE;;LSBÒ  †HIBYTE;;MSBÜ !†NUMBR2;;add argæ X;ð X;Absolute ,Xú X; †ABSOLX …ABSOL;;set up absol !…ADDX2;;copy in ,X X;" X;Absolute ,Y, X;6 †ABSOLY …ABSOL;;do absol@ ƒACYQ>,;;a commaJ P„IBUF9;;in bufT Q> Y;;a Y^ P„IBUF9;;in bufh :;;doner X;| X;Indirect X† X; „INDXQ>;;no MSBš P…DTEMP¤  †LOBYTE;;do LSB®  …OPENP;;add open '('¸ 2;;up X %>;;3 bytesÌ H„ADDX;;copy ',X)'Ö X;à X;Indirect Yê X;ô „INDYQ>;;no MSBþ P…DTEMP  †LOBYTE;;do LSB  …OPENP;;left ( %>;;copy in the& „ADDYQ†COMMAY8;;'),Y'0 P„IBUF9: 2D 1N I„ADDYX :;;doneb X;l X;Accumulator Modev X;€ …ACCUMQ> A;;an 'A'Š P„IBUF;;in buffer” :;;donež X;¨ X;Branch instructions² X;¼ „RELA †LOBYTE;;put LSBÆ #…NBYTE;;make 3 byteÐ  ƒZFR;;zero FR0Ú Q…DTEMP;;get operandä I†NOBACK;;not inverseî M>;;mask inverseø N>;;flip it ,;;add a 1 O> P„DINS;;save it !„TOFP;;done* †NOBACKP„DINS4 „TOFPQ…DTEMP;;operand> I‡FORWARD;;bran forwardH Q„ADDR;;now subtractR ;;;from addr\ S„DINS;;to find outf PƒFR0;;where thisp Q„ADDR;;branch goes.z S>„ PƒFR0Ž !„BACK;;done.˜ ‡FORWARD,;;add # to¢ O„ADDR;;addr to calc¬ PƒFR0;;forward branch¶ Q„ADDRÀ O>Ê PƒFR0Ô „BACKQ>;;now add a 2Þ ,;;to skip theè OƒFR0;;instructionò P…DTEMP;;addressü PƒFR0 QƒFR0O> P…DTEMP$ PƒFR0. †NUMBR3;;add number8"…NBYTE;;make 2 bytesBX;LX;Implied ModeVX;`ƒIMP:;;do nothingjX;tX;Indirect instructions~X;ˆ„INDI †LOBYTE;;copy in LSB’ †HIBYTE;;and MSBœ …OPENP;;do open (¦Q> );;and add°P„IBUF9;;closing oneº :;;leave.ÄX;ÎX;Zero page ,YØX;â…ZPAGY †LOBYTE;;do LSBì …NUMBR;;add argö!ƒACY;;copy ,YX; X;Insert LSBX;†LOBYTE ƒZFR;;zero FR0(Q…DTEMP;;do lobyte2PƒFR0<$>;;at pos. 10F!‡COPYNUM;;do it!PX;ZX;Insert MSBdX;n†HIBYTE ƒZFR;;no FR0xQ…DTEMP;;hibyte‚PƒFR0;;in FPŒ$>";;at pos. 14–!‡COPYNUM;;copy it. X;ªX;Add Open (´X;¾…OPENPQ> (;;open (ÈP„IBUF;;in bufferÒ!†NUMBR2;;add numberÜX;æX;Copy number to stringðX;ú ‡COPYNUM0&…CNTLO;;save XQ„HXDC;;hex/dec?F…INHEX;;have Hex." ƒIFP;;to FP, „FASC;;to ASC6$…CNTLO;;get index@%>ÿ;;and copyJ†CNLOOP3;;the numberT2^ Q@†INBUFF7h P„IBUF9r I†CNLOOP|M>;;mask bit 7† P„IBUF9 :;;leavešX;¤…INHEX ‡BIN2HEX;;make hex®$…CNTLO;;get pos¸ 2;;up it.Â(>ÌFƒALL;;if 25 do allÖ(>;;is X => 30?àDƒARG;;yes.ê!„SOMEQ…LBUFF;;no. just copyôP„IBUF9;;the LSB partþ2;;of the HexQ…LBUFF;;number. P„IBUF9 :;;bye.&ƒARGQ> $;;install a '$'0 P„IBUF9: 2;;up XDQ…NBYTE;;Get # of bytesNR>;;is it 2?XF„SOME;;no.bƒALL%>;;no. copy itl…ALOOPQ…LBUFF8;;all to bufv P„IBUF9€2Š3”)>;;done yet?žH…ALOOP;;nope.¨ 0;;dec X²:;;so long.¼X;ÆX;Binary to hexadecimalÐX;Ú‡BIN2HEX%>;;buf indx=0ä$>;;do 2 numsî†NXTBYT&‚X1;;save itøQ>ð;;get HI bits MƒFR09 V?;;divide by 16V? V?*V?4>;;to index>Q…HXTAB9;;get charHP…LBUFF8;;and saveR3;;up buf index\$‚X1;;get X backfQ>;;now LO bitsp MƒFR09z>„Q…HXTAB9;;get char andŽP…LBUFF8;;put in buffer˜3;;up buf indx¢$‚X1;;get X¬0;;down by one¶I†NXTBYT;;done?À:;;yes. bye.ÊX;ÔX;Fill buffer with blanksÞX;è„ZBUFQ> ;;spaceò$>';;do 40 spacesü…ZLOOPP„IBUF9;;in buf0;;down countI…ZLOOP;;go again :;;bye.$X;. X;Zero FR08X;B ƒZFRQ>LPƒFR0V PƒFR0`:jX;tX;Open Input File~X;ˆ†OPENIN$>;;slam IOCB #1’ …CLOSEœQ„TYPE;;get disa type¦F†O_FILE;;if 0, then file° ‡UP.READ;;read 1st sectorº6;;save statusÄQ>€;;default sizeÎ PˆSECBYTESØQ†S.SIZE;;get actualâR>€;;is 128 bytes?ìF„O.SO;;yes.öQ…DSBUF;;get data bytePˆSECBYTES;;count. „O.SO8;;pull statusG…INERR;;oops, error.:;;so long.(†O_FILE$>;;IOCB #12Q>;;open command< P…ICCOM9FQ>4‡SRCFILE;;point to thePP…ICBAL9;;source file-ZQ>5‡SRCFILE;;name.d P…ICBAH9nQ>;;read only.x P„AUX19‚Q>Œ P„AUX29–P†BYTCNT;;zero byte cnt P†BYTCNTª „CIOV;;open it!´G…INERR;;oops.¾ ‡GET.TWO;;get file headerÈG…INERR;;empty file!Ò …CHKFF;;is it binary?ÜH…CIO.B;;no!æ%>;;signal goodð:ú…CIO.B%>˜;;not binary fileX;X;Input errorX;"…INERR)>ˆ;;EOF?,H‚PI;;no, show error6Q>;;kill instr@ P…BYTESJ!†D_OVER;;and exit.T ‚PI …F_ERR^†PRINT „IN_P;;print INPUTh†PRINT „IBUFr†PRINT ˆALL.DONE | ‡GET_RET† !†D_OVERX;šX;Open Output file¤X;®‡OPENOUT$> ;;close #2¸ …CLOSEÂ$> ÌQ>;;open commandÖ P…ICCOM9àQ>4‡DSTFILE;;point toêP…ICBAL9;;the dest'nôQ>5‡DSTFILE;;filename.þ P…ICBAH9Q>;;write only P„AUX19Q>;;no lines.& P…LINES0 P„AUX29:Q>4†BIGBUF;;point to theDP†BUFPNT;;start of theNQ>5†BIGBUF;;buffer.XP†BUFPNTbQ‡DSTFILE;;is destn tolR> E;;the screen?vH…C.CIO;;no, call cio€%>;;show good.Š:”…C.CIO!„CIOV;;open it!žX;¨X;Close IOCB²X;¼…CLOSEQ> ;;close commandÆ P…ICCOM9Ð!„CIOV;;slam!ÚX;äX;CIO get byte routineîX;ø†CIOGET$>;;on ch #1Q>;;get bytes  P…ICCOM9Q>;;no length says P…ICBLL9;;put byte in the*P…ICBLH9;;accumulator.4!„CIOV;;get it!>X;HX;Get byte routineRX;\†GETBYTQ„TYPE;;get type.fF†G_FILE;;if 0, from filep$†GETPTR;;get indexz(ˆSECBYTES;;at end?„F†NX.SEC;;yes.ŽQ…DSBUF9;;get byte.˜#†GETPTR;;bump pointer.¢%>;;signal good.¬ :;;bye.¶X;À†NX.SECQ>;;start on byte 1Ê P†GETPTRÔQ†S.SIZE;;trace links?ÞR>}èH…F.SEC;;no.òQ…DSBUF};;get the linkü M>;;hiP„SECH;;get the linkQ…DSBUF~;;loP„SECL;;at EOF?$ L„SECH.H†C.READ;;no.8…S.EOF%>ˆ;;signal error.B:L †C.READ ‡UP.READ;;grab sectorV6;;save status`Q…DSBUF;;get # datajPˆSECBYTES;;bytes.tQ…DSBUF;;get data byte~8;;pull statusˆ:;;and leave.’X;œ…F.SEC#„SECL;;sec=sec+1¦ H„FS.1° #„SECHº„FS.1 ‡UP.READ;;grab sectorÄ6;;save statusÎQ…DSBUF;;get dataØ8;;pull statusâ:;;and leave.ìX;ö ‡UP.READQ†SECCNT;;any sectorsL†SECCNT;;left? F…S.EOF;;no! Done.Q†SECCNT;;subtract 1;;;from the sector(S>;;count.2 P†SECCNT<Q†SECCNTFS>PP†SECCNTZ!†READIT;;read sector.dX;n†G_FILEQ†BYTCNT;;any bytesxL†BYTCNT;;left?‚F‡HEADERS;;no, get moreŒQ†BYTCNT;;subtract 1–;;;from the count S>ª P†BYTCNT´Q†BYTCNT¾S>ÈP†BYTCNTÒ#…BYTES;;up byte countÜ!†CIOGET;;get the byteæX;ðX;Send remaining instr bytesúX;ˆANY_LEFTQ…BYTES;;any extra?F„N.LF;;no.%>—;;bad opcode." …HAVOP;;format .BYTE, ˆPRINT.IT;;send it out.6Q…DTEMP;;prepare next@P‚OPJ"…BYTES;;down countTHˆANY_LEFT;;and loop^„N.LF:;;bye.h…H_ERR!…INERR;;input errorrX;|X;Pull file headers†X;!‡HEADERS ˆANY_LEFT;;send extraš ‡GET.TWO;;grab 2 more¤G…H_ERR;;oops.®%>;;copy message¸„C.STQ„STEN8;;to buffer P„IBUF8Ì1Ö I„C.STà …CHKFF;;are they $FF's?êH†NOT.FF;;no.ô ‡GET.TWO;;get 2 moreþG…H_ERR;;oops.†NOT.FFQƒHXL;;save the loadP„ADDR;;address andPƒFR0;;convert it to&QƒHXH;;hex for the0P„ADDR;;output file.: PƒFR0D ‡BIN2HEX;;make hex.N$>;;copy it inX ƒALLb ‡GET.TWO;;grab 2 morelG…H_ERR;;oops.vQƒHXL;;make this #€PƒFR0;;into hex forŠ;;;output also.”S„ADDR;;We also calcžP†BYTCNT;;the length of¨QƒHXH;;the segment.² PƒFR0¼ S„ADDRÆP†BYTCNTÐ#†BYTCNT;;add 1 to theÚH„N.OV;;segment len.ä#†BYTCNTî„N.OV ‡BIN2HEX;;make hexø$>;;pos 16 ƒALL;;copy it  …PUTCR;;line feed7;;pull return 7* ˆPRINT.IT;;print it4!‡DISAMEM;;go again.>X;HX;Grab two file bytesRX;\‡GET.TWO †CIOGETf G…G2ERRpPƒHXLz †CIOGET„PƒHXHŽ …G2ERR:˜X;¢X;Print The output¬X;¶ ˆPRINT.IT†PRINT „IBUF;;to E:À%>;;wait 5 jiffiesÊ '†RTCLOKÔ…WT_LPQ†RTCLOKÞR>è D…WT_LPòQ‡DSTFILE;;to E: only?üR> EH…PR.LP;;no. :;;yes.…PR.LPQ„IBUF8;;move iobuf to$P@†BUFPNT7;;big buffer. R>ƒEOL8 F…PR.DNB3L H…PR.LPV…PR.DN3;;now we add Y+1`C;;to the pointerj,;;so we are readytO†BUFPNT;;next time~ P†BUFPNTˆQ†BUFPNT’O>œP†BUFPNT¦ #…LINES°Q…LINES;;get line countºR>È;;200 lines?ÄH†SND.LV;;no.ÎX;ØX;Send the buffer outâX;ìˆSEND_OUTQ…LINES;;any lines?öH†SND.IT;;yes.†SND.LV:;;so long. †SND.ITQ> ;;put bytes$>  P…ICCOM9(Q>4†BIGBUF;;from bigbuf2 P…ICBAL9< Q>5†BIGBUFF P…ICBAH9PQ†BUFPNT;;calc the lenZ;;;of the bufferd S>4†BIGBUFn P…ICBLL9xQ†BUFPNT‚ S>5†BIGBUFŒ P…ICBLH9–Q>4†BIGBUF;;reset the P†BUFPNT;;pointers.ª P…LINES´ Q>5†BIGBUF¾P†BUFPNTÈ ˆTEST_DRV;;test drivesÒH‡SND.OUT;;not equal܆PRINT ‡INS_DST;;ask foræ ‡GET_RET;;disk swap.ð$> ú‡SND.OUT „CIOV;;write outG‡OUT_ERR;;oops. ˆTEST_DRV;;swap again?H†SND.OV;;no."Q…SFLAG;;test flag,H†SND.OV;;no swap!6†PRINT ‡INS_SRC;;prompt it@ ‡GET_RETJ†SND.OV%>;;signal good.T:^X;hX;Test srcdrv vs. dstdrvrX;|ˆTEST_DRVQ†DESDRV;;get dest†R†SRCDRV;;is = source? :;;bye.šX;¤X;Output error handler®X;¸‡OUT_ERR …F_ERR;;format err#†PRINT „OUTP;;print OUTPUTÌ$> ;;close #2Ö …CLOSEà†PRINT „IBUF;;print err#ê†PRINT ˆALL.DONE ô ‡GET_RET;;get returnþ!…INTRO;;so long. X; X;Get a RETURN X;& ‡GET_RET †GETKEY;;get key0 R>ƒEOL;;is it EOL?: H‡GET_RET;;no.D $> N :X X;b X;Check if HXL/HXH=$FFl X;v …CHKFFQƒHXL;;get byte 1€ R>ÿ;;is it $FF?Š H…CHKLV;;no.” RƒHXH;;is #2=#1?ž …CHKLV: