10
20
30 :
40 max%=((HIMEM-LOMEM)DIV1024)*256
50 DIM ctrl% 31,memout% max%-1,memin% max%*2-1:X%=ctrl%:Y%=X%DIV256
60 INPUT"Source file: "in$:in%=OPENIN(in$):IFin%=0:PRINT"File '"in$"' not found":END
70 INPUT"Dest. file: "out$:out%=OPENOUT(out$):IFout%=0:PROCCloseAll:PRINT"Can't open '"out$"'":END
80 ON ERROR REPORT:PROCCloseAll:END
90 REPEAT:PRINTCHR$13;100*PTR#in%DIVEXT#in%;"%: ";PTR#in%DIV1024;"K of ";EXT#in%DIV1024;"K";
100 PROCgbpb(3,in%,memin%,max%*2,PTR#in%)
110 FOR A%=0 TO max%-1:memout%?A%=memin%?(A%*2):NEXT
120 PROCgbpb(1,out%,memout%,max%,PTR#out%)
130 UNTILEOF#in%
140 CLOSE#out%:out%=0
150 CLOSE#in%:in%=0
160 PRINT
170 END
180 DEFPROCCloseAll
190 in%=in%:IFin%:A%=in%:in%=0:CLOSE#A%
200 out%=out%:IFout%:A%=out%:out%=0:CLOSE#A%
210 ENDPROC
220 DEFPROCgbpb(A%,chn%,addr%,num%,ptr%):?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:CALL&FFD1:ENDPROC