Floppy boot sector disassembly

This is a discussion on Floppy boot sector disassembly within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I know this isn't really a C question, but I need to know if there are any freely available utilities ...

  1. #1
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605

    Floppy boot sector disassembly

    I know this isn't really a C question, but I need to know if there are any freely available utilities to allow me to disassemble a floppy boot sector - I can view it in debug by copying the first sector to memory, and then running unassemble, but I really need some way of printing the unassembled code out. All the disassemblers I can find seem "file" oriented instead of "sector" oriented.

    I can see theres a lot of guys here who write their own boot loaders, so I am hoping someone can help.

    Cheers,

    Rob.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    The boot sector is 510 bytes long, but just read in 512 bytes. The bootsector resides at cylinder 0, head 0, sector 1. To interpret the information you will need to know the FAT12 structure that is used on floppies. Also the bootstrap code lies just beyond the bootsector structure and is approx 446 bytes long. At offset 01EFh lies the boot signature which has to be 0AA55h.

    To read in you can first check if your BIOS supports the INT 13 extensions by issuing a call to Check Installation.

    AH=41h
    BX=55AAh
    DL=drive (80h-FFh)

    Return:
    CF set on error (extensions not supported)
    AH=01h (invalid function)
    BX=AA55h (if installed)
    AH=major version of extensions
    01h=1.x
    20h=2.0/EDD 1.0
    21h=2.1/EDD 1.1
    30h=EDD 3.0

    AL=internal usage
    CX=API subset support bitmap
    DH=extension version


    Then to read in you would issue Read Extended via int 13h.

    For more information on this go to http://home.teleport.com/~brainy/fat16.htm.

    That's the link to the 16-bit FAT info, but you can link off of that page to the other pages which discuss this and a disk util which will allow you to do what you want to do.


    Make sure you understand this before attempting to code it. You can wipe out your boot sector, bootstrap, partitions, files, FATs, and anything else on the drive using the INT 13 API.

  3. #3
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Thnx for the info. I'll give it a try later & let you know how I get on!

    Cheers,

    Rob.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    A very simple way to read the bootsector is by using biosdisk, which by the way, uses INT 13h.

    The boot sector is 512 bytes long and starts at sector 1.

    unsigned char buffer[512];


    //Command 2 -> read sectors
    //Drive 0 or A:
    //Head 0
    //Cylinder 0
    //Sector 1
    //Length of 1 sector
    //Read into buffer
    int error=biosdisk(2,0,0,1,1,&buffer);

    if (error)
    {
    printf("Error encountered\n");
    exit(1);
    }

    To make sense of this look up the BootSector struct for the MS-DOS operating system. The bootstrap lies int the 449 bytes directly after the struct. The last two bytes of the bootstrap are 55 AA or 0AA55h (remember little endian). If this is not present, the BIOS will not boot the disk. 55AA is the required boot signature which tells the BIOS this disk is bootable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. freebsd and redhat dual boot.
    By xddxogm3 in forum Linux Programming
    Replies: 1
    Last Post: 05-09-2004, 07:06 PM
  2. Boot Disks
    By Jperensky in forum C++ Programming
    Replies: 2
    Last Post: 06-19-2003, 05:37 AM
  3. floppy disk boot sector
    By krishnancbalak in forum C Programming
    Replies: 2
    Last Post: 06-13-2003, 10:53 AM
  4. Boot issue; no floppy drive
    By CodeMonkey in forum Tech Board
    Replies: 6
    Last Post: 11-19-2002, 05:37 PM
  5. CD Boot - Need Help
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-19-2001, 01:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21