!****************************************************************
!*                                                              *
!*      FASTREAD    Program reads the copy manager's core dump  *
!*                  flat out (no flow control) to a file        *
!*                                                              *
!*                  Version 1.1    1 May 1988                   *
!*                                                              *
!****************************************************************

!Program waits for a character then starts a timer.  Everything up to the timer
!goes into a file.
%begin
%include "inc:util.imp"
%include "inc:atdecs.imp"
%string (255) param
%integer timeout, ad, c, i, p, exempt

%constinteger acia addr = 16_4000C0
%recordformat acia fm(%byte d0,status,d2,data)
@aciaaddr %record(acia fm) acia

%routine quiet acia
   acia_status = 16_15 ;!Interrupts off
%end

%routine normal acia
   acia_status = 16_95 ;!Interrupts back on again
%end

%routine read timed(%integername c)
   %cycle
      c=acia_status
   %repeatuntil c&1#0 %or cputime>=timeout
   %if c&1#0 %then c=acia_data %else c=-1
%end

ad = heapget(65536)
quiet acia
%cycle; c=acia_status; %repeatuntil c&1#0
printsymbol(7)
timeout = cputime+10000
p=0
byteinteger(ad+p)=acia_data; p=p+1
%cycle
   read timed(c); %exit %if c<0; byteinteger(ad+p)=c; p=p+1
   timeout = cputime+10000
%repeat

normal acia
printsymbol(7)
param = cli param; param="canon.log" %if param=""
openoutput(1, param); selectoutput(1)
%for i=0, 1, p-1 %cycle
   printsymbol(byteinteger(ad+i))
%repeat
close output; selectoutput(0)
printsymbol(7)

%endofprogram
