Bootable Floppy Disk

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ninja Rider

Bootable Floppy Disk

Post by Ninja Rider »

i have been able to make a bootable floppy disk that will run. but once i go back into windows to edit the program i have to reformat the floppy. is there anything that i need to do to the floppy to allow me to re-write to it without formating ever time.

im using 16-bit assembly for programing. and to write the bootsecter of the floppy im using windows debug with command w 100 0 0 1.
AR

Re:Bootable Floppy Disk

Post by AR »

The bootsector on a FAT floppy contains the drive parameters, by replacing it with your own you are removing the FAT Driver's ability to read the disk.

Anyway, if you only need the bootsector then why are you reformatting anyway? It's not as though you need FAT if you aren't using it.
JoeKayzA

Re:Bootable Floppy Disk

Post by JoeKayzA »

This sounds like that the bootsector you write to the floppy contains no, or a broken FAT-header. FAT puts information into the very first sector of the media, so you will have to resemble this in your bootsector.

Here you might find helpful information. ;)

cheers Joe

EDIT: post collision with the previous one
Ninja Rider

Re:Bootable Floppy Disk

Post by Ninja Rider »

my reasons for wanting to maintain the fat is so that when i restart windows. i can edit the .asm file assemble it and write it to the disk. i dont have to wait for the floppy to be formatted. my win 98se laptop wont allow a drive to be written to if its not formatted
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Bootable Floppy Disk

Post by Brendan »

Hi,
Ninja Rider wrote:my reasons for wanting to maintain the fat is so that when i restart windows. i can edit the .asm file assemble it and write it to the disk. i dont have to wait for the floppy to be formatted. my win 98se laptop wont allow a drive to be written to if its not formatted
There's 2 different types of "formatting". The first involves creating the tracks, sectors, etc and is called "low level formatting'. The second is putting a file system on it (I'll call this "high level formatting" for the sake of it).

Your disk must be low level formatted before anything can store any data on it, but disks come pre-formatted now, so this isn't necessary unless you change the disk's format (for example, the exact same disk could be formatted as "low density" with 9 sectors per track for 720 KB per disk, or it's possible to format it with 1024 KB sectors or other unusual things).

For DOS/Windows to access the disk, it needs to be "high level formatted" because Microsoft isn't very good at working with disks that have other people's file systems on them (unlike Linux, where it'd be no problem at all). This is the problem you're having.

I'm not sure, but RawWrite might solve your problem: http://uranus.it.swin.edu.au/%7Ejn/linux/rawwrite.htm

It's easier than DOS's "debug.exe" and should work with a few mouse clicks without "high level formatting" first (and it's probably easier than installing Linux! :) ).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Dex4u

Re:Bootable Floppy Disk

Post by Dex4u »

First you need to put this at the start of your OS.

Code: Select all

[BITS 16]
[SECTION .text]
[ORG 0]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        jmp     short   start
        nop
bsOemName               DB      "BootProg"      ; 0x03

;;;;;;;;;;;;;;;;;;;;;
;; BPB starts here ;;
;;;;;;;;;;;;;;;;;;;;;

bpbBytesPerSector       DW      ?               ; 0x0B
bpbSectorsPerCluster    DB      ?               ; 0x0D
bpbReservedSectors      DW      ?               ; 0x0E
bpbNumberOfFATs         DB      ?               ; 0x10
bpbRootEntries          DW      ?               ; 0x11
bpbTotalSectors         DW      ?               ; 0x13
bpbMedia                DB      ?               ; 0x15
bpbSectorsPerFAT        DW      ?               ; 0x16
bpbSectorsPerTrack      DW      ?               ; 0x18
bpbHeadsPerCylinder     DW      ?               ; 0x1A
bpbHiddenSectors        DD      ?               ; 0x1C
bpbTotalSectorsBig      DD      ?               ; 0x20

;;;;;;;;;;;;;;;;;;;
;; BPB ends here ;;
;;;;;;;;;;;;;;;;;;;

bsDriveNumber           DB      ?               ; 0x24
bsUnused                DB      ?               ; 0x25
bsExtBootSignature      DB      ?               ; 0x26
bsSerialNumber          DD      ?               ; 0x27
bsVolumeLabel           DB      "NO NAME    "   ; 0x2B
bsFileSystem            DB      "FAT12   "      ; 0x36

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector code starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

start:
you than assemble the code as a bin file, making shore it no bigger than 512bytes and use a program called "bootable.exe" which is included in bootprog.zip available here:
http://alexfru.chat.ru/epm.html#bootprog
Ninja Rider

Re:Bootable Floppy Disk

Post by Ninja Rider »

dex4u,
are the offsets for the bpb **** mandatory
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Bootable Floppy Disk

Post by Brendan »

Hi.
Ninja Rider wrote:are the offsets for the bpb **** mandatory
No (sort of)! The BPB isn't used by the BIOS or hardware in any way.

However, the hardware/BIOS has no way to determine how a floppy disk has been low level formatted. The hardware itself is so poor that you can't even figure out what kind of floppy drive is present (e.g. 3.5-inch or 5.25-inch) and have to hope someone told the BIOS correct details for it (which is a problem if there's more than 2 floppy drives).

To solve this problem Microsoft invented the BPB, so that if the first sector and the BPB can be read it's easy to figure out how the disk was low level formatted.

It is possible to find out how a floppy disk has been low level formatted with manual detection by trying to read from the disk at each different data rates until you know the "density", and then trying to read from specially selected sectors until you know how many sectors per track.

Of course now 1440 KB 3.5-inch disks are common, so it'd be possible for an OS to only support 1440 KB floppies and assume there's 18 sectors per track, 512 bytes per sector, 2 heads, etc. This means if someone has a 2880 KB floppy (and floppy drive), or a 1680 KB floppy or something even more unusual, you'd be out of luck.

Anyway, supporting the BPB (or only supporting the parts that aren't FAT specific - e.g. sectors per track but not number of FATs or root entries), may be a convenient way to figure out how a floppy was low level formatted.

For Linux, the BPB is ignored and you need to tell it which format to use. This isn't a problem if you only use 1440 KB floppies (and IMHO it works better because the BPB may not be sane), but does mean that for non-standard disk formats you need to type something like "setfdprm /dev/fd0 1680/1440" before reading or writing to the disk.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Dex4u

Re:Bootable Floppy Disk

Post by Dex4u »

If i understand your origanal ?.
Ninja Rider wrote: i have been able to make a bootable floppy disk that will run. but once i go back into windows to edit the program i have to reformat the floppy. is there anything that i need to do to the floppy to allow me to re-write to it without formating ever time.
Then yes you need this stuff to be able to read/write it in windows, without reformating.
My understanding of you ? , is you want to read/write to floppy with your OS on, from windows, as if it was any other file eg: txt, com, exe.
Ninja Rider

Re:Bootable Floppy Disk

Post by Ninja Rider »

well i understand that the fat information has to be there like does the offset of bpbBytesPerCluster have to be 0X0b and is all the bs.... required.

im just wanting to be able to fit as much as possible on the bootsector if i develope this completely. im really wierd. i like all my code to be as compact and neat as possible.

also
doing a commandline
i've thought of a couple ways to do a command line but i would like some feedback on what would be the best possible way.

get the keyboard char (using int 16 function 00 -- i think??)
echo char

test for return key (dont know how to do this. i would think of test al, 10 but it doesn't work)

increament variable containing the len of the commandline
add char to the end of the string
Dex4u

Re:Bootable Floppy Disk

Post by Dex4u »

Yes you need them, thats where most people make a mastake, they leave them out, and windows will not read the disk wiith out formating, without them (take them out and try it).
As for simple command line here is some code that may help.
Ninja Rider

Re:Bootable Floppy Disk

Post by Ninja Rider »

thnx the code helps alot.
Post Reply