Добавил:
salavat
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
{ ‘।Ё "бў®Ў®¤ле" Є« бвҐа®ў ©вЁ Є« бвҐал, ᮤҐа¦ йЁҐ ⥪бв®ўго
Ёд®а¬ жЁо (⥪бв-« вЁЁж ) Ё ўлўҐбвЁ Ёе б гЄ § ЁҐ¬ ®¬Ґа®ў. }
Uses dos,crt;
Type bpb_type=record
sectsiz:word;
clustsiz:byte;
ressecs:word;
fatcnt:byte;
rootsiz:word;
totsecs:word;
media:byte;
fatsize:word;
end;
add_bpb_type=record
trksecs:word;
headcnt:word;
hidnseclo:word;
hidnsechi:word;
totsecs:longint;
end;
boot_sec_type=record
a:array[1..11]of byte;
bpb:bpb_type;
add_bpb:add_bpb_type;
b:array[1..476]of byte;
end;
Function readsec(disk:byte;claster,colsec,colhead:word;colsect:byte;var buf):boolean;
var r:registers;
seccyl,sec,head,cyl,per1:word;
begin
colsec:=18;
colhead:=2;
per1:=claster div colsec;
sec:=(claster mod colsec)+1;
cyl:=per1 div colhead;
head:=per1 mod colhead;
asm
mov ax,sec
mov bx,cyl
mov dh,bl
and al,00111111b
mov cl,6
shl bh,cl
or al,bh
mov dl,al
mov seccyl,dx
end;
with r do
begin
ah:=2;
al:=colsect;
dl:=disk;
dh:=head;
cx:=seccyl;
es:=seg(buf);
bx:=ofs(buf);
intr($13,r);
readsec:=(flags and fcarry)=0;
end;
end;
Function readbootsec(disk:byte;var buf):boolean;
var r:registers;
begin
with r do
begin
ah:=2;
al:=1;
dl:=disk;
dh:=0;
cx:=1;
es:=seg(buf);
bx:=ofs(buf);
intr($13,r);
readbootsec:=(flags and fcarry)=0;
end;
end;
Var boot:boot_sec_type;
disk,head,colsec,buf,buf1,buf2:byte;
cylsec,claster,buf3,buf4:word;
fat12:array[0..4607]of byte;
fat:array[0..2879]of word;
mas:array[1..512]of char;
i,j:word;
flag:boolean;
k:char;
Begin
clrscr;
writeln('Џ®ЁбЄ Є« бвҐа®ў ᮤҐа¦ йЁе ⥪бв®ўго Ёд®а¬ жЁо(« в.):');
disk:=$0;
if not readbootsec(disk,boot) then begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
if not readsec(disk,boot.bpb.ressecs,boot.add_bpb.trksecs,boot.add_bpb.headcnt,boot.bpb.fatsize,fat12) then begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
buf:=fat12[0];
fat[0]:=buf;
buf:=fat12[1];
buf1:=fat12[2];
asm
mov al,buf
mov ah,buf1
mov buf3,ax
end;
fat[1]:=buf3;
i:=2;j:=3;
while not(i=2880) do begin
buf:=fat12[j];
inc(j);
buf1:=fat12[j];
inc(j);
buf2:=fat12[j];
inc(j);
asm
mov al,buf1
mov dl,buf
mov ah,buf2
mov dh,00001111b
and dh,al
mov buf3,dx
mov cl,4
shr ax,cl
mov buf4,ax
end;
fat[i]:=buf3;
inc(i);
if i=2880 then break;
fat[i]:=buf4;
inc(i);
end;
for i:= 33 to 2879 do
begin
if fat[i-31]=0 then
begin
if not readsec(disk,i,boot.add_bpb.trksecs,boot.add_bpb.headcnt,1,mas) then
begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
flag:=false;
for j:=1 to 512 do
begin
if {(mas[j]<>chr(0)and}(mas[j]<#10)or(mas[j]>'}') then
begin
flag:=true;
break;
end;
end;
if not flag then
begin
writeln('Ќ ¦¬ЁвҐ «оЎго Є« ўЁиг.');
k:=readkey;
if k=#27 then halt;
writeln('Љ« бвҐа:',i);
for j:=1 to 512 do write(mas[j]);
writeln;
end;
end;
end;
writeln('—⥨Ґ § ўҐа襮.');
repeat until keypressed;
end.
Ёд®а¬ жЁо (⥪бв-« вЁЁж ) Ё ўлўҐбвЁ Ёе б гЄ § ЁҐ¬ ®¬Ґа®ў. }
Uses dos,crt;
Type bpb_type=record
sectsiz:word;
clustsiz:byte;
ressecs:word;
fatcnt:byte;
rootsiz:word;
totsecs:word;
media:byte;
fatsize:word;
end;
add_bpb_type=record
trksecs:word;
headcnt:word;
hidnseclo:word;
hidnsechi:word;
totsecs:longint;
end;
boot_sec_type=record
a:array[1..11]of byte;
bpb:bpb_type;
add_bpb:add_bpb_type;
b:array[1..476]of byte;
end;
Function readsec(disk:byte;claster,colsec,colhead:word;colsect:byte;var buf):boolean;
var r:registers;
seccyl,sec,head,cyl,per1:word;
begin
colsec:=18;
colhead:=2;
per1:=claster div colsec;
sec:=(claster mod colsec)+1;
cyl:=per1 div colhead;
head:=per1 mod colhead;
asm
mov ax,sec
mov bx,cyl
mov dh,bl
and al,00111111b
mov cl,6
shl bh,cl
or al,bh
mov dl,al
mov seccyl,dx
end;
with r do
begin
ah:=2;
al:=colsect;
dl:=disk;
dh:=head;
cx:=seccyl;
es:=seg(buf);
bx:=ofs(buf);
intr($13,r);
readsec:=(flags and fcarry)=0;
end;
end;
Function readbootsec(disk:byte;var buf):boolean;
var r:registers;
begin
with r do
begin
ah:=2;
al:=1;
dl:=disk;
dh:=0;
cx:=1;
es:=seg(buf);
bx:=ofs(buf);
intr($13,r);
readbootsec:=(flags and fcarry)=0;
end;
end;
Var boot:boot_sec_type;
disk,head,colsec,buf,buf1,buf2:byte;
cylsec,claster,buf3,buf4:word;
fat12:array[0..4607]of byte;
fat:array[0..2879]of word;
mas:array[1..512]of char;
i,j:word;
flag:boolean;
k:char;
Begin
clrscr;
writeln('Џ®ЁбЄ Є« бвҐа®ў ᮤҐа¦ йЁе ⥪бв®ўго Ёд®а¬ жЁо(« в.):');
disk:=$0;
if not readbootsec(disk,boot) then begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
if not readsec(disk,boot.bpb.ressecs,boot.add_bpb.trksecs,boot.add_bpb.headcnt,boot.bpb.fatsize,fat12) then begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
buf:=fat12[0];
fat[0]:=buf;
buf:=fat12[1];
buf1:=fat12[2];
asm
mov al,buf
mov ah,buf1
mov buf3,ax
end;
fat[1]:=buf3;
i:=2;j:=3;
while not(i=2880) do begin
buf:=fat12[j];
inc(j);
buf1:=fat12[j];
inc(j);
buf2:=fat12[j];
inc(j);
asm
mov al,buf1
mov dl,buf
mov ah,buf2
mov dh,00001111b
and dh,al
mov buf3,dx
mov cl,4
shr ax,cl
mov buf4,ax
end;
fat[i]:=buf3;
inc(i);
if i=2880 then break;
fat[i]:=buf4;
inc(i);
end;
for i:= 33 to 2879 do
begin
if fat[i-31]=0 then
begin
if not readsec(disk,i,boot.add_bpb.trksecs,boot.add_bpb.headcnt,1,mas) then
begin
writeln('ЋиЁЎЄ звҐЁп ¤ЁбЄ !',disk);
halt;
end;
flag:=false;
for j:=1 to 512 do
begin
if {(mas[j]<>chr(0)and}(mas[j]<#10)or(mas[j]>'}') then
begin
flag:=true;
break;
end;
end;
if not flag then
begin
writeln('Ќ ¦¬ЁвҐ «оЎго Є« ўЁиг.');
k:=readkey;
if k=#27 then halt;
writeln('Љ« бвҐа:',i);
for j:=1 to 512 do write(mas[j]);
writeln;
end;
end;
end;
writeln('—⥨Ґ § ўҐа襮.');
repeat until keypressed;
end.
