program msrw1(input,output,outfile); {Treiber fuer die ISA-16-Bit-Zufallszahlengeneratorkarte der ersten Generation. Geschrieben in Turbo-Pascal fuer MS-OSs (DOS (d. h. auch Windows95, Windows98 usw.), WindowsNT, usw.). Dieses Programm liest die einfache ISA-Zufallswort-Karte staendig aus und erstellt standarmaessig aus diesen random short die byteanz grosse Datei rw1.out, die zyklisch mit den neuesten Zufallsworten ueberschrieben wird. Die Nummer des aktuellen Zyklus seit dem Programmstart (und nicht mehr) enthaelt die Datei randw.log in Form eines unsigned long int. Hinweis: ========= -Auf den meisten PCs (mit PII, K6-2 oder schnelleren) ist ein Patch fuer den 'CRT Delay() delay division by zero'-Bug erforderlich. 2000 Rolf Freitag This Program is free software; you can redistribute it and/od modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at yout option) any later version. This Program is distributed in the hope that it will be useful, but WITHOUT ANY WARRENTY; without even the implied warrenty of MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this Program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. } uses crt,strings,dos; CONST pa=$1A0; { erste ISA-Karten-Adresse, default J1=0, J2=1 : $1A0=416 } { J1=0, J2=0 : $120=288 } { J1=1, J2=0 : $160=352 } pb=$1A8; { zweite ISA-Karten-Adresse, default J1=0, J2=1 : $1A8=422 } { J1=0, J2=0 : $128=296 } { J1=1, J2=0 : $168=360 } b0=Ord('0'); VAR byteanz : longint; {Groesse der Zufallsbit-Datei} wortanz: longint; {Groesse der Zufallsbit-Datei} intanz : longint; {Groesse der Zufallsbit-Datei} ll: longint; { Zahl von ofl2 } lc: integer; us: word; { u. a. z. Zwischenspeichern der eingelesenen 16-Bit-Werte (Words) } i : longint; {Zaehler} k : longint; {Zaehler} ssm : boolean; {true, wenn single shot modus} b1 : char; line : string[11]; outname1: string; {fuer Dateinamen} outname2 : string; {fuer Dateinamen} ofl1 : text; {output-file1} ofl2 : text; {output-file2} ofp1 : ^File; {output-file-pointer} ofp2 : ^File; {output-file-pointer} PROCEDURE err_handler; {geordneter Programmabbruch mit einfachem Error-Handler} begin if (ofp1<>nil) then close(ofl1); {Aufraemen} if (ofp2<>nil) then close(ofl2); halt(1); end; PROCEDURE direct; { direktes Auslesen der Karte } begin while true<>false do begin rewrite(ofl1); {Schreibzustand, Datei-Beginn} if (ssm=false) then begin rewrite(ofl2); {Schreibzustand, Datei-Beginn} write(ofl2,ll); Flush(ofl2); end; for i:=1 to intanz do begin us := portw[pb]; { direktes Einlesen: letzte 16 Bit zuerst } write (ofl1,us); { direktes Schreiben ohne die Reihenfolge zu aendern } us := portw[pb]; write (ofl1,us); { direktes Schreiben ohne die Reihenfolge zu aendern } Flush(ofl1); { Puffer leeren. Ohne die obige Einlese-Reihenfolge oder Flush } end; { koennten einige Bits aus der Karte zweimal ausgelesen werden. } ll:=ll+1; if (ssm=true) then break; end; end; {direct} begin {main} byteanz := 1457152; { 5 1/4 " - Disc-Groesse : 1457152 Byte } wortanz := 728576; intanz := 364288; ll := 0; i := 0; k := 0; outname1 := ''; outname2 := ''; ssm:=false; ofp1:=nil; ofp2:=nil; if (ParamCount > 2) then begin writeln ('Usage: rw1 Output-file-name(optional) Output-file-size(optional, in 4*n%%4 Byte)'); exit; end; if (ParamCount >= 1) then begin outname1 := ParamStr(1); ssm := true; end; if (ParamCount = 2) then begin line:=ParamStr(2); i:=0; k:=1; for lc:=1 to Strlen('line') do begin b1:=line[1]; i:=i+(Ord(b1)-b0)*k; k:=k*10; end; ssm := true; end; if (i>0) then begin byteanz := i; ssm := true; end; wortanz := byteanz div 2; intanz := byteanz div 4; {Ausgabe-Datei oeffnen} assign(ofl1,outname1); {SetFAttr(ofl1,$01); Read only} ofp1:=@ofl1; if (ofp1=nil) then begin writeln('Can`t open ',outname1,'.'); err_handler; end; if (not ssm) then begin assign(ofl2,outname2); {SetFAttr(ofl1,$01); Read only} ofp2:=@ofl2; if ofp1=nil then begin writeln('Can`t open ',outname2,'.'); err_handler; {Ende} end; end; direct; if (ofp1<>nil) then close(ofl1); if (ofp2<>nil) then close(ofl2); end. {main}