) > MkSrcZ80 - Make a Z80 source file &A%=0:X%=1:os%=((&FFF4)&FF00)256 1ctrl% 79,name% 127:X%=ctrl%:Y%=X%256:cpu%=0 (-eol$=(10-3*(os%<6)):os%32:eol$=13+10 2:Close_All:: <$"Input object file: "in$ F0file(in$,5)<>1:"File '"in$"' not found": P9len%=X%!10:-P-2000"":out%=(out$) nA%=load%&FFFFFF00 x)A%=&FFF70000:load%=&0000:exec%=&0000 UA%=&FFFBBC00:load%=&8000:exec%=&8000:mem%!0=0:mem%!4=0:load%=&C000:exec%=&C000 )A%=&FFFFF800:load%=&8000:exec%=&8000 )A%=&FFFFFA00:load%=&0000:exec%=&0000 )A%=&FFFFFC00:load%=&0000:exec%=&0000 W"Disassembly address: (&";~load%;:") &"A$:A$<>"":load%=("&"+A$):exec%=load% ?:X%!0=0:A$=Dis_Name(cpu%):A$="":"CPU number:"11;""cpu% AA$<>"":dat%=X%?312:wth%=(X%?33)*2+4:msk%=("&"+wth%,"F")) 0dat%=0:dat%=wth%+12dat%=12:dat%=21dat%=9 G"(B)asic or (T)ext output? "A$:txt%=(A$,1)="T"A$,1)="t") G"Output byte dump in comments? "A$:cmt%=(A$,1)="Y"A$,1)="y") G"Output byte dump in disassembly? "A$:dmp%=(A$,1)="Y"A$,1)="y") cmt%=cmt%dmp% B%=01:addr%=load%:lbmax%=0 MB%:"Creating labels";7+wth%,".");"Scanning for labels";3+wth%,"."); 6:wth%,8);h0(addr%,wth%);:L$=line:A%=L$,"&") zA%:L$,A%+1,1)>="0":L%=L$,A%):L%>&FF:L%>=(load%msk%)L%<(load%msk%)+len%:lbmax%=lbmax%+4:B%:!lb%=L%:lb%=lb%+4 "Faddr%=addr%+num%:addr%>load%+len%:B%=0:label% lbmax%:lb%=label% , :B% 6."Outputting source.....";h0(load%,wth%); @out("REM",&F4+" > "+out$) J'out("REM",&F4+" Source for "+in$) Tout(""," ") ^Bout("","OS_CLI=&FFF7:OSBYTE=&FFF4:OSWORD=&FFF1:OSWRCH=&FFEE") hBout("","OSWRCR=&FFEC:OSNEWL=&FFE7:OSASCI=&FFE3:OSRDCH=&FFE0") rBout("","OSFILE=&FFDD:OSARGS=&FFDA:OSBGET=&FFD7:OSBPUT=&FFD4") |(out("","OSGBPB=&FFD1:OSFIND=&FFCE") out(""," ") out("","load%=&"+~load%) ,out("DIM",&DE+" mcode% &"+~(len%+20)) Atxt%:out("","FOR P=0 TO 1")out("",&E3+" P=0 "+&B8+" 1") !out("","P%=load%:O%=mcode%") out("","[OPT P*3+4") Uaddr%=load%::wth%,8);h0(addr%,wth%);:L$=line:addr%=exec%:out("",".exec%") vlb%=label%-4:lb%=lb%+4:lb%>label%+lbmax%!lb%=(addr%msk%):!lb%=(addr%msk%):out("",".L"+h0(addr%msk%,wth%)) yA$="":A%=L$,"&"):A%:L$,A%+1,1)>="0":L%=L$,A%):L%>=(load%msk%)L%<(load%msk%)+len%:L$=L$,A%-1)+"L"+L$,A%+1) cmt%:A$=h0(addr%,wth%):B$="":A%=0num%-1:B%=?(addr%-load%+mem%+A%):A$=A$+" "+h0(B%,2):B$=B$+ch(B%)::A$=A$+(dat%-A$)(A$load%+len% &,txt%:out("","]NEXT")out("","]"+&ED) 0Wout("PRINT",&F1+" ""*SAVE "";~mcode%;"" "";~O%;"" "";~exec%;"" "";~load%") :%out%:txt%:#out%,13:#out%,255 DAout%:#out%:out%=0:X%!2=&FFFFFB00-1024*txt%:A%=file(out$,2) N: XAݤline:num%=Dis_Code(cpu%,addr%,addr%-load%+mem%):L$=$(X%+4) b/num%=X%?3:flg%=X%?2:A%=L$,"&FF"):A%=0:=L$ l)L%=(L$,A%,5))-&FFCE:L%<0L%>43:=L$ vE((L%3-(L%>27))3-3*(L%=24)+(L%>24L%<28)-3*(L%=27)-(L%=28)):=L$ g=L$,A%-1)+"OS"+"FINDGBPBBPUTBGETARGSFILERDCHASCINEWLWRCRWRCHWORDBYTE_CLI",(L%3)*4+1,4)+L$,A%+5) out(T$,A$):out%=0: Itxt%:A$=T$+A$,(T$="")+2)+eol$:$name%=A$:gbpb(2,out%,name%,A$,0): ;line%=line%+1:?name%=13:name%?1=line%256:name%?2=line% =name%?3=A$+4:$(name%+4)=A$:gbpb(2,out%,name%,A$+4,0): 3Close_All:out%=out%:out%:A%=out%:out%=0:#A%  .ݤch(A%):A%=A%127:A%<32A%=127:="."=A% #ݤh0(A%,N%)="0000000"+~A%,N%) #gbpb(A%,chn%,addr%,num%,ptr%) @?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:(os%32)=0:&FFD1: A%=1A%=3:#?X%=X%!9 3:A%=1A%=2:#?X%,?X%!1A%=3A%=4:?X%!1=#?X% 2X%!1=X%!1+1:X%!5=X%!5-1:(#?X%A%>2)X%!5<1:  Nݤfile(A$,A%):(os%32)=0:$name%=A$:?X%=name%:X%?1=name%256:=(&FFDD)&FF MA%=5:X%!14=(A$):X%!14:X%!10=#X%!14:#X%!14:X%!2=0:X%!6=0:X%!14=&33:=1  =0 * ݤDis_Name(A%):X%?3=0:="Z80" 4BݤDis_Code(A%,Ptr%,Data%):s%,d%,c%,xy%:!X%=0:num%=1:c%=?Data% >8d%=c%7:s%=(c%&38)8:$(X%+4)=("FNz80_"+~(c%&C0)) HX%?3=num%:=num% R3ݤalu(A%)="ADDADCSUBSBCANDXOROR CP ",A%*3+1,3) \3ݤrot(A%)="RLCRRCRL RR SLASRASLSSRL",A%*3+1,3) fݤr(A%)="BCDEHLFA",A%+1,1) p>ݤdrg(A%)="BCDEHLSPIXAFIY",(A%1)+((xy%*4)((A%6)=4)),2) z"ݤreg(A%):xy%=0A%<>6:=r(A%) A%=6xy%=0:="(HL)" 7A%=6:num%=num%+1:="(I"+(87+xy%)+rel(Data%?2)+")" #(A%6)=4:="I"+(87+xy%)+r(A%)  =r(A%) )ݤrel(A%):A%<128:="+"+A%=(A%-256) /ݤjr(A%):="&"+h0(Ptr%+A%+2+256*(A%>127),4) Eݤcc(A%)="NZZ NCC POPEP M ",A%*2+1,2-((A%1)(A%<4))-(1(A%>5))) ݤz80_0:c%=0:="NOP" @(c%&F7)=&10:num%=2:="DJNZJR ",s%*4-7,4)+" "+jr(Data%?1) 'd%=7s%<4:=rot(s%),3+(s%>1))+"A" %d%=7:="DAACPLSCFCCF",s%*3-11,3) Cd%=6:num%=num%+1:="LD "+reg(s%)+",&"+h0(?(Data%+num%-1),2) 4(d%6)=4:="INCDEC",(d%1)*3+1,3)+" "+reg(s%) 0d%=3:="INCDEC",(s%1)*3+1,3)+" "+drg(s%) Fc%=&22:num%=num%+2:="LD (&"+h0(!(Data%+num%-2),4)+"),"+drg(4) Ic%=&2A:num%=num%+2:="LD "+drg(4)+",(&"+h0(!(Data%+num%-2),4)+")" $7c%=&32:num%=num%+2:="LD (&"+h0(Data%!1,4)+"),A" .7c%=&3A:num%=num%+2:="LD A,(&"+h0(Data%!1,4)+")" 8+d%=2(s%5)=0:="LD ("+drg(s%)+"),A" B"d%=2:="LD A,("+drg(s%)+")" L0d%=1(s%1)=1:="ADD "+drg(4)+","+drg(s%) VCd%=1:num%=num%+2:="LD "+drg(s%)+",&"+h0(!(Data%+num%-2),4) `>d%=0s%>3:num%=num%+1:="JR "+cc(s%3)+","+jr(Data%?1) j="EX AF,AF'" tݤz80_40:c%=&76:="HALT" ~&s%=6:="LD "+reg(s%)+","+r(d%) &d%=6:="LD "+r(s%)+","+reg(d%) "="LD "+reg(s%)+","+reg(d%) 5ݤz80_80:=alu(s%)+" "+"A,",s%<2s%=3)+reg(d%) -ݤz80_C0:d%=5(s%1)=1:=("FNz80_"+~c%) c%=&CB:=z80_CB !d%=7:="RST &"+h0(c%&38,2) 6d%=6s%<4:num%=2:=alu(s%)+" A,&"+h0(Data%?1,2) /d%=6:num%=2:=alu(s%)+" &"+h0(Data%?1,2) G(d%3)=1(s%1)=0:="POP PUSH",(d%4)*4+1,4)+" "+drg(s%-4*(s%>5)) :d%=4:num%=num%+2:="CALL "+cc(s%)+",&"+h0(Data%!1,4) :d%=2:num%=num%+2:="JP "+cc(s%)+",&"+h0(Data%!1,4) d%=0:="RET "+cc(s%) +c%=&C3:num%=3:="JP &"+h0(Data%!1,4)  c%=&C9:="RET" 2c%=&D3:num%=2:="OUT (&"+h0(Data%?1,2)+"),A" 2c%=&DB:num%=2:="IN A,(&"+h0(Data%?1,2)+")" (c%=&D9:="EXX" 2!c%=&E3:="EX (SP),"+drg(4) c%=Data%?1:d%=c%7:s%=(c%&38)8:A$=("FNz80_"+~(c%&C0)) DA$,4),"X")+A$,"Y")=0:num%=1:="DEFB &"+h0(xy%*&20+&BD,2)=A$ 5ݤz80_ED:xy%:num%=1:="DEFB &"+h0(xy%*&20+&CD,2) 0num%=num%+1:c%=Data%?1:d%=c%7:s%=(c%&38)8 c%<&10:="DEFW &"+h0(c%*256+&ED,4)+":\ MOS_"+"QUITCLI BYTEWORDWRCHRDCHFILEARGSBGETBPUTGBPBFINDFF0CFF0DFF0EFF0F",c%*4+1,4) %c%<&40c%>&C0:num%=1:="DEFB &ED" 4(c%&C7)=&42:=alu(3-(s%1)*2)+" HL,"+drg(s%) H(c%&CF)=&4B:num%=num%+2:="LD "+drg(s%)+",(&"+h0(Data%!2,4)+")" E(c%&CF)=&43:num%=num%+2:="LD (&"+h0(Data%!2,4)+"),"+drg(s%) ((c%&C7)=&40:="IN "+r(s%)+",(C)" %(c%&C7)=&41:="OUT (C),"+r(s%) "/(c%&E7)=&46s%<>1:="IM "+(s%-1-(s%=0)) ,'(c%&F7)=&67:="RRDRLD",s%*3-11,3) 6((c%&F7)=&45:="RETNRETI",s%*4+1,4) @c%=&44:="NEG" JP(c%&E7)=&47:="LD "+(65-8*(s%=0)-17*(s%=1))+","+(65-8*(s%=2)-17*(s%=3)) TG(c%&E4)=&A0:="LDCPINOT",d%*2+1,2)+(73-5*(s%1))+(32+25*(s%2)) ^num%=1:="DEFB &ED"