[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some Code to Look At



On Sat, 27 Jan 2001 11:46:27 -0600, Tom Droege 
<tdroege@veriomail.com> wrote:

>Below is the code that writes the contents of the Mark IV Memory card to a 
>disk file.
> ...
[ referring to writing MK IV data ]

I dug out my old 486/33MHz and got the following results:
Free Pascal or Borland Pascal 7.0:
Transription of (most of) the BASIC code 109 sec
Buffering to 16384 Byte buffers 73 sec
and for BP7.0:
Turning off all checking 49 sec (Free Pascal 53 sec)
Inner loop in Assembler 45 sec
There is not much more to be had by Assembler coding!

Here is the Pascal, for what it is worth.

Program BASWrite ;
{ More or less the functionality of (most of) SaveIt1 }
{ DOS call as BASWrite filenamea filenameb }
{ Does not update FileNumber }
{          make file names   }
{          write to LogFile  }
{          do ReadReset      }
{       or Print sample data }

{ Using BlockWrite: 73 seconds 486/33 16K Buffers }
{                   49 s, all checking turned off }
Const
  NAxis2 = 2037 ;
  NAxis1 = 2043 ;
  PortNo = $301 ;
  LBufB = 16384 ; { A multiple of a power of 2 }
  LBufW = LBufB Div 2 ;
Type
  BufT = Array[0..LBufW-1] Of Word ;
Var
  NameA, NameB : String ;
  FileA, FileB : File ;
  BufA, BufB : BufT ;
  L, I, N : Longint ;
  B1, B2 : Byte ;
  Time1, Time2 : Double ; { Used only for benchmarking }
Begin
{ There must be 2 parameters }
  If (ParamCount <> 2) Then Begin
    Writeln('Usage:') ;
    Writeln('BASWrite filenamea filenameb') ;
    Halt(155) ;
  End ;
  NameA := ParamStr(1) ;
  NameB := ParamStr(2) ;
  Assign(FileA, NameA) ;
  Rewrite(FileA, 2) ;
  Assign(FileB, NameB) ;
  Rewrite(FileB, 2) ;
  L := Longint(NAxis1)*NAxis2 ;
  Writeln('L ', L) ;
  B1 := $FF ; B2 := $FF ;
  N := LBufW ;
  I := 0 ;
  Repeat
    b1 := Port[PortNo] ;
    b2 := Port[PortNo] ;
    BufA[I] := 256*Word(B1) + B2 ;
    b1 := Port[PortNo] ;
    b2 := Port[PortNo] ;
    BufB[I] := 256*Word(B1) + B2 ;
    Inc(I) ;
    If (I >= N) Then Begin
      BlockWrite(FileA, BufA, N) ;
      BlockWrite(FileB, BufB, N) ;
      Dec(L, N) ;
      N := L ; If (N > LBufW) Then N := LBufW ;
      I := 0 ;
    End ;
  Until (L <= 0) ;
  Close(FileA) ;
  Close(FileB) ;
End.

Andrew Bennett, Avondale Vineyard