Program Saveboot; Uses DOS, CRT; type sectortype = array[0. .511] of byte; var sectorbuffer:sectortype; filename:string; bootfile:file of byte; regs:registers; x, option, drivenum:integer; continue:boolean; Function Sector_Read (D, T, H, S : integer):byte; begin with regs do begin es:= seg(sectorbuffer); bx:= ofs(sectorbuffer); ch:= t; cl:= s; dh:= h; dl:= d; ah:= 2; al:= 1; intr (19, regs); end; SECTOR_READ:= regs.ah; end; Function Sector_Write (D, T, H, S : integer):byte; begin with regs do begin es:= seg(sectorbuffer); bx:= ofs(sectorbuffer); ch:= t; cl:= s; dh:= h; dl:= d; ah:= 3; al:= 1; intr (19, regs); end; SECTOR_WRITE:= regs.ah; end; begin fillchar (regs, sizeof(regs), 0); repeat repeat clrscr; writeln; writeln ('Boot Saver 1.0'); writeln; writeln ('1) Read and save boot sector'); writeln ('2) Load file and overwrite boot sector'); writeln ('3) Quit'); writeln; write ('Enter Option: '); readln (option); until ((option > 0) and (option < 4)); if option = 1 then begin writeln ('Enter drive to load Boot sector from (0=a, 1=b...)'); write (' : '); readln (drivenum); write ('Enter filename to save to: '); readln (filename); assign (bootfile, filename); rewrite (bootfile); if Sector_Read (drivenum, 0, 0, 1) = 0 then for x:= 0 to 511 do write (bootfile, sectorbuffer[x]); close (bootfile); end; if option = 2 then begin write ('Enter file name to load from to: '); readln (filename); writeln ('Enter drive to overwrite Boot sector on (0=a,1=b)'); write (' : '); readln (drivenum); assign (bootfile, filename); reset (bootfile); for x:= 0 to 511 do read (bootfile, sectorbuffer[x]); close (bootfile); if Sector_Write (drivenum, 0, 0, 1) = 0 then writeln ('OK, all done.'); end; until option = 3 end.