ALP in line code for displaying boot sector of floppy and boot record of hard disk.
ALP in line code for displaying boot sector of floppy and boot record of hard disk.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
char buffer[512],*ptr;
clrscr();
asm{
mov ah,0x1c ;function for absolute read disk
mov al,0 ;drive number
mov cx,0x001 ;number of sectors to read
mov dx,0 ;starting sector
lea bx,buffer ;address of buffer
int 0x0025
jnc succ ;if successful then no carry
}
printf("\n Error reading floppy drive ");
getch();
succ : ptr = buffer; ;ptr contains address of buffer
ptr = ptr + 3;
printf("\n OEM Name & Version is : ");
for(i=0;i<8;i++,ptr++)
{
printf("%c",*ptr);
}
ptr = buffer + 0x0b;
printf("\n Byte/Sector is : %d ",*(int *)ptr);
ptr = buffer + 0x0d;
printf("\n Sectors/Allocation unit is : %d ",*(int *)ptr);
ptr = buffer + 0x10;
printf("\n Number of FATs are : %d ",*ptr);
ptr = buffer + 0x11;
printf("\n Number of root directory entries are : %d ",*(int *)ptr);
ptr = buffer + 0x13;
printf("\n Total number of sectors in logical volume are : %d ",*(int *)ptr);
ptr = buffer + 0x15;
printf("\n Media descriptor address byte is : %2x ",(unsigned char)*ptr);
ptr = buffer + 0x16;
printf("\n Number of sectors/FAT are : %d ",*(int *)ptr);
ptr = buffer + 0x18;
printf("\n Sectors/track is : %d ",*(int *)ptr);
ptr = buffer + 0x1A;
printf("\n Number of heads are : %d ",*(int *)ptr);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
char buffer[512],*ptr;
clrscr();
asm{
mov ah,0x1c ;function for absolute read disk
mov al,0 ;drive number
mov cx,0x001 ;number of sectors to read
mov dx,0 ;starting sector
lea bx,buffer ;address of buffer
int 0x0025
jnc succ ;if successful then no carry
}
printf("\n Error reading floppy drive ");
getch();
succ : ptr = buffer; ;ptr contains address of buffer
ptr = ptr + 3;
printf("\n OEM Name & Version is : ");
for(i=0;i<8;i++,ptr++)
{
printf("%c",*ptr);
}
ptr = buffer + 0x0b;
printf("\n Byte/Sector is : %d ",*(int *)ptr);
ptr = buffer + 0x0d;
printf("\n Sectors/Allocation unit is : %d ",*(int *)ptr);
ptr = buffer + 0x10;
printf("\n Number of FATs are : %d ",*ptr);
ptr = buffer + 0x11;
printf("\n Number of root directory entries are : %d ",*(int *)ptr);
ptr = buffer + 0x13;
printf("\n Total number of sectors in logical volume are : %d ",*(int *)ptr);
ptr = buffer + 0x15;
printf("\n Media descriptor address byte is : %2x ",(unsigned char)*ptr);
ptr = buffer + 0x16;
printf("\n Number of sectors/FAT are : %d ",*(int *)ptr);
ptr = buffer + 0x18;
printf("\n Sectors/track is : %d ",*(int *)ptr);
ptr = buffer + 0x1A;
printf("\n Number of heads are : %d ",*(int *)ptr);
getch();
}
0 comments:
Post a Comment