ô > Assem117/s ver$="1.17" >ô v1.15 29-May-1999 Removed bug code on exit, some tidying (Cô v1.16 31-May-1999 Will Assem from text files, PrDec tidied up 2Qô v1.17 15-Feb-2018 Optimised, replaced PrDec, fits without running into &B00 <: F7OSRDCH=&FFE0:OSNEWL=&FFE7:OSWRCH=&FFEE:OSWORD=&FFF1 P7OSARGS=&FFDA:OSFIND=&FFCE:OSBGET=&FFD7:OSWRCR=&FFEC Z'OSASCI=&FFE3:BRKV=&0202:WORDV=&020C d: nblk=&A8:lptr=&AA:arg=&AC x/PRPAD=&80:PRTEMP=&81:LineNumber=&82:len=&85 ‚.Handle=&86:HandleFirst=&87:InsideAssem=&88 ŒErrFlag=&89:FileType=&8A –:  !Þ mcode% &300:load%=&FFFF08C0 ª: ´ ãP=0¸1 ¾O%=mcode%:P%=load% È[OPT P*3+4 Ò.FileNotFound Ü*BRK:EQUB 214:EQUS "File not found":BRK æ: ð.go% ú9LDY #&00:STY ErrFlag:STY InsideAssem :\ Clear flags !LDA #&01:LDX #lptr:JSR OSARGS -LDX lptr+0:LDY lptr+1:LDA #&40:JSR OSFIND TAY:BEQ FileNotFound "JSTY Handle:STY HandleFirst:JSR CheckFileType :\ Check if Basic or Text ,@JSR SwapVectors :\ Set up the vectors 6: @D.PrintPass :\ Print the current pass JLDX #MsgPass-MsgBase T.PrMessage ^LDA MsgBase,X:BEQ PrMsgDone h JSR OSASCI:INX:BNE PrMessage r: | .NewWORD †%CMP #&00:BEQ Word0:JMP (OldWORDV)  .Word0 š?STA len :\ Clear line length ¤!LDA MsgOPT,Y:STA (lptr),Y:INY HFCMP #—":":BNE InsertOPT :\ Put OPT at start of line R?PLA:CMP #—"]":BNE ReadLine :\ End of assembler? \IINX :\ X=&00, end assembler code f.StartLine pSTX InsideAssem z .ReadLine „STA (lptr),Y:INY:STY len ŽCMP #&0D:BEQ EndOfLine ˜CMP #&0A:BEQ EndOfLine ¢BIT &FF:BMI EscapePressed ¬(LDY Handle:JSR OSBGET:BCS EndReached ¶LDY len:BNE ReadLine À.EndOfLine ÊLDY #&00:LDA (lptr),Y ÔCMP #—">":BEQ NextFile ÞLDY len:CLC:RTS è: ò.EndReached üHLDA PassChar:CMP #—"5":BCS EndOfAssem :\ Very end reached in pass 2 GINC MsgPass+5:LDA #—"7":STA PassChar :\ Set the number for pass 2 %JSR PrintPass:JSR CloseIfNotFirst -LDY HandleFirst:STY Handle:JSR RewindFile $.StartAFile .(JSR CheckFileType:JMP ReadLineHeader 8: B.CheckFileType L7LDA #0:STA FileType:STA LineNumber:STA LineNumber+1 V@JSR OSBGET:CMP #13:BEQ SwapVectorsEnd :\ Look at first byte `FDEC FileType :\ Flag as Text, and rewind j: t.RewindFile ~LDX #3:LDA #0 ˆ .Rewind ’STA arg,X:DEX:BPL Rewind œELDX #arg:LDA #&01:JMP OSARGS :\ Rewind to start of file ¦: ° .NextFile ºJSR CloseIfNotFirst ÄLDX lptr+0:LDY lptr+1 ÎIINX:BNE P%+3:INY :\ Point to filename in buffer Ø"LDA #&40:JSR OSFIND:STA Handle âLTAY:BNE StartAFile :\ If not present, will fall thru ì: ö.CloseIfNotFirst 1LDY Handle:CPY HandleFirst:BEQ SwapVectorsEnd  :  .CloseY LDA #&00:JMP OSFIND (: 2.EndOfAssem <2JSR CloseIfNotFirst:LDY HandleFirst:JSR CloseY FFLDY #0:LDA #&0D:STA (lptr),Y :\ Length=0, CR in position P.SwapVectors ZPHP:SEI:LDY #2 d.SwapVecLp nALDA BRKV-1,Y:LDX OldBRKV-1,Y:STA OldBRKV-1,Y:TXA:STA BRKV-1,Y xELDA WORDV-1,Y:LDX OldWORDV-1,Y:STA OldWORDV-1,Y:TXA:STA WORDV-1,Y ‚:DEY:BNE SwapVecLp :\ End with Y=0 Œ PLP:CLC –.SwapVectorsEnd  RTS ª: ´.OldBRKV :EQUW NewBRK ¾.OldWORDV:EQUW NewWORD È: Ò .PrHex Ü4PHA:LSR A:LSR A:LSR A:LSR A:JSR PrNyb:PLA:€ #&0F æ .PrNyb ð,SED:CLC:ADC #&90:ADC #&40:CLD:JMP OSWRCH ú:  .NewBRK LDY #&00:LDA (&FD),Y CMP #&20:BEQ ErrorExit " CMP #&DE:BNE NotChannelError ,NJSR SwapVectors :\ *BUG* after this, jmp (oldbrkv) will come back here 6.NotChannelError @JLDX #MsgError-MsgBase:STX ErrFlag :\ Flag for next entry to Osw0 JFJSR PrMessage:JSR PRDEC16 :\ Print error line number TLDA #—":":JSR OSWRCH ^.ErrorExit hJMP (OldBRKV) r: | .PRDEC16 †'LDA #255:PHA \ Terminator .PRDECDIGIT š*LDX #15 \ 16-bit divide ¤(LDA #0 \ Remainder=0 ®8CLV \ V=0 means divide result = 0 ¸.PRDECDIV10 Â/CMP #10/2:BCC PRDEC10 \ Calculate OSNUM/10 ÌJSBC #10/2+&80 \ Remove digit & set V=1 to show div result > 0 Ö4SEC \ Shift 1 into div result à .PRDEC10 ê-ROL LineNumber+0 \ Shift /10 result ôROL LineNumber+1 þHROL A \ Shift bits of input into acc (input mod 10) 3DEX:BNE PRDECDIV10 \ Continue 16-bit divide HPHA:BVS PRDECDIGIT \ If V=1, result of /10 was >0, do next digit PLA & .PRDECLP2 0B„A #—"0":JSR OSWRCH \ Pop character left to right and print it :PLA:BPL PRDECLP2:RTS N: X .MsgBase b.MsgIgnore lEQUS ½7+"Ignore? (Y/N)":BRK v .MsgOPT €#EQUS "[OPT":.PassChar:EQUS "4:" Š .MsgPass ”EQUS "Pass 1":EQUB 13:BRK ž .MsgError ¨EQUS "Error at line ":BRK ²: ¼ EQUS ver$ Æ \ =&AF9 Ð]:í ÚAñ"*Save Assem ";~mcode%;" ";~O%;" ";~go%„&FFFF0000;" ";~load% ÿ