program CititorEPROM; const WhichPort : word = $378; {portul de imprimanta} var staddr,eaddr : LongInt; b, counter : byte; m, i : word; c : char; F : file; data : array[0..32768] of byte; {buffer pentru date} function ReadPort:byte; {Intoarce datele din EPROM} var b:byte; begin port[WhichPort]:=255; port[WhichPort+2]:=3+32; {PORT setat pentru intrare} b:=port[WhichPort]; port[WhichPort+2]:=11; ReadPort:=b; end; procedure SetAddress(Addr: word); {seteaza adresa pentru EPROM} var lo,hi:byte; begin asm mov ax,ADDR mov lo,al mov hi,ah end; port[WhichPort+2]:=13; {Init - pentru LATCH LO} port[WhichPort]:=lo; port[WhichPort+2]:=9; port[WhichPort+2]:=8; {Strobe - pentru LATCH HI()} port[WhichPort]:=hi; port[WhichPort+2]:=9; {AUTOFD - e A14 la alte EPROMuri} end; procedure TestError(a:byte); begin case a of 0: writeln('La revedere....'); 1: writeln('Ochelari? Adresa de start e mai mare decat adresa de sfarsit?'); 2: writeln('Adresa de sfarsit iese din capacitatea EPROM.'); 3: WriteLn('Sa pornesc de la adresa negativa? Oare...'); 4: writeln('Nu pot scrie fisierul.'); 5: writeln(''); else writeln('UNKNOWN ERROR CODE ',a); end; halt(a); end; function FileExists(FileName: String): Boolean; begin {$I-} Assign(F, FileName); FileMode := 0; { Set file access to read only } Reset(F,1); {$I+} FileExists := (IOResult = 0) and (FileName <> ''); end; { FileExists } begin writeln('Cititor EPROM. (C) 1999 Proiect la MICROPROCESOARE II'); writeln('Dumitrean Radu Mihai grupa 2241/1 UNIVERSITATEA TECHNICA CLUJ'); writeln; port[WhichPort+2]:=9; {Initializare programator. Numai -PGM e Hi} write('Adresa de inceput:'); readln(staddr); write('Adresa de sfarsit:'); readln(eaddr); if (eaddr(128 div 8)) then TestError(2); if (staddr<0) then TestError(3); assign(f,'temp.bin'); rewrite(f,1); for i:=staddr to eaddr do begin SetAddress(i); data[i-staddr]:=ReadPort; end; blockwrite(F,data,eaddr-staddr); close(F); TestError(0); end.