/*FLOPPY BOOT SECTOR */
/* BY /*
/* A K A S H*/
#include<stdio.h>
#include<dos.h>
#include<conio.h>
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef struct boot
{
BYTE jump [3];
char bsOemName [8];
WORD bytesperSector;
BYTE sectorspercluster;
WORD sectorsreservedarea;
BYTE copiesFAT;
WORD maxrootdirentries;
WORD totalSectors;
BYTE mediaDescriptor;
WORD sectorsperFAT;
WORD sectorsperTrack;
WORD sides;
WORD hiddenSectors;
char reserve [480];
};
void main()
{
clrscr();
boot rd;
asm{
mov dl,0x00
mov ah,0x00
int 0x13
mov dl,0x00
mov ah,0x01
int 0x13
jc next1
mov dl,0x00
mov ah,0x02
mov al,0x01
mov ch,0x00
mov cl,0x01
mov dh,0x00
lea bx,rd
int 0x13
jc next2
};
printf("\n\t\t-------------Floppy Boot Sector-------------");
printf("\n\t\t--------------------B-Y---------------------");
printf("\n\t\t----------------*A-K-A-S-H*-----------------");
printf("\n\t\t____________________________________________\n\n\n\n");
printf("\n\t\t\tJMP instruction:%X%X%X",rd.jump[0],rd.jump[1],rd.jump[2]);
printf("\n\t\t\t----------------------");
printf("\n\t\t\tOEM: %s",rd.bsOemName);
printf("\n\t\t\t-------------");
printf("\n\t\t\tBytes/Sector:%4d",rd.bytesperSector);
printf("\n\t\t\t----------------");
printf("\n\t\t\tSec/Cluster:%X",rd.sectorspercluster);
printf("\n\t\t\t---------------");
printf("\n\t\t\tNum Fat:%X",rd.copiesFAT);
printf("\n\t\t\t----------");
printf("\n\t\t\tRoot Entry:%4d",rd.maxrootdirentries);
printf("\n\t\t\t----------------");
printf("\n\t\t\tTotal Secotrs:%4d",rd.totalSectors);
printf("\n\t\t\t-------------------");
printf("\n\t\t\tMedia Desc:%X",rd.mediaDescriptor);
printf("\n\t\t\t-------------");
printf("\n\t\t\tSectors/FAT:%4d",rd.sectorsperFAT);
printf("\n\t\t\t-----------------");
printf("\n\t\t\tSectors/TRACK:%4d",rd.sectorsperTrack);
printf("\n\t\t\t-------------------");
printf("\n\t\t\tSides:%4d",rd.sides);
printf("\n\t\t\t-----------");
printf("\n\t\t\tHidden Sector:%4d",rd.hiddenSectors);
printf("\n\t\t\t-------------------");
goto end;
next1: printf("\nError: Drive not ready");
goto end;
next2:
printf("\nError: Drive cant read");
end:
getch();
}
本文深入解析了一段用于读取软盘引导扇区的C语言代码,详细介绍了其内部结构和工作流程。
1772

被折叠的 条评论
为什么被折叠?



