Write FAT12 Assembly for Floppy

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
ledoux
Posts: 4
Joined: Sun Mar 10, 2019 11:55 pm
Libera.chat IRC: ledoux_k

Write FAT12 Assembly for Floppy

Post by ledoux »

:D :D :D

Hello every One
I am about to progress with the boot and loading of the kernel.

But something bothers me, I would like to know, as we can not create an MBR on a floppy disk, how to implement a FAT for floppy disk?

And another question is, how do I make my system compatible with other systems if I sit on a floppy disk?

In addition I would like you to look at this site: http://starman.vertcomp.com/asm/mbr/DOS50FDB.htm#BPB
How can she help me?
nullplan
Member
Member
Posts: 1798
Joined: Wed Aug 30, 2017 8:24 am

Re: Write FAT12 Assembly for Floppy

Post by nullplan »

I am not entirely certain what you are talking about. You can create a boot loader for a floppy disk. That boot loader will have to take the BPB into account. When you write the boot loader to the disk, you have to skip the BPB that's already there, or else you'll destroy the file system.

Your bootloader will then have to somehow load the next stage (typically done by iterating over the root directory and looking for a constant file name) and load that somewhere, and then jump there.

As for compatibility, you have to know the different hardware platforms you want to support. I personally am creating a pure 64-bit OS, so I am not particularly bothered about IBM 5150 compatibility. If you wish to at least recognize if someone is using a too old CPU, here's what I do:
  1. Push SP. An 8086 CPU will push the decremented value of SP, all others will push the old value. So if you pop that value into another register, and now the other register and SP are not equal, you are executing on an 8086. For me, that is the cue to bail out.
  2. All CPUs since the 80186 have implemented the undefined opcode exception, so now I just register a handler for interrupt 6 that also prints the "CPU too old" error message if triggered.
  3. Now I can just execute CPUID. If the CPU is anything before the later 80486s, this will just trigger #UD. Otherwise I can now identify features. Including long mode.
Last edited by nullplan on Wed Apr 10, 2019 10:03 pm, edited 1 time in total.
Carpe diem!
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Write FAT12 Assembly for Floppy

Post by alexfru »

ledoux wrote:I would like to know, as we can not create an MBR on a floppy disk, how to implement a FAT for floppy disk?
There's no MBR on a floppy, usually (I mean, you can probably have one, but it'll likely make incompatible with existing OSes that understand FAT). And there's no need for it since floppies don't have that much capacity to carve into partitions.
ledoux wrote:And another question is, how do I make my system compatible with other systems if I sit on a floppy disk?
See https://github.com/alexfru/BootProg.
Specifically, you really want to have these things: This is enough for the floppy to be recognized by DOS and Windows. Between the BPB and the signature you can have anything.
ledoux
Posts: 4
Joined: Sun Mar 10, 2019 11:55 pm
Libera.chat IRC: ledoux_k

Re: Write FAT12 Assembly for Floppy

Post by ledoux »

alexfru wrote:
ledoux wrote:I would like to know, as we can not create an MBR on a floppy disk, how to implement a FAT for floppy disk?
There's no MBR on a floppy, usually (I mean, you can probably have one, but it'll likely make incompatible with existing OSes that understand FAT). And there's no need for it since floppies don't have that much capacity to carve into partitions.
ledoux wrote:And another question is, how do I make my system compatible with other systems if I sit on a floppy disk?
See https://github.com/alexfru/BootProg.
Specifically, you really want to have these things: This is enough for the floppy to be recognized by DOS and Windows. Between the BPB and the signature you can have anything.

Why did you do that , at this level :
https://github.com/alexfru/BootProg/blo ... 2.asm#L184

I don't know how you put shr ax , 4
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Write FAT12 Assembly for Floppy

Post by alexfru »

ledoux wrote:Why did you do that , at this level :
https://github.com/alexfru/BootProg/blo ... 2.asm#L184

I don't know how you put shr ax , 4
Why not? What should be there instead?
Did you read all relevant lines, 179 through 191, including the comments?
Do you know the basics of how segmentation works? And what "paragraph" stands for in this context?

IOW, do you have a specific question?
ledoux
Posts: 4
Joined: Sun Mar 10, 2019 11:55 pm
Libera.chat IRC: ledoux_k

Re: Write FAT12 Assembly for Floppy

Post by ledoux »

alexfru wrote:
ledoux wrote:Why did you do that , at this level :
https://github.com/alexfru/BootProg/blo ... 2.asm#L184

I don't know how you put shr ax , 4
Why not? What should be there instead?
Did you read all relevant lines, 179 through 191, including the comments?
Do you know the basics of how segmentation works? And what "paragraph" stands for in this context?

IOW, do you have a specific question?


In fact, I do not really understand why we make decals at this level.
You're right, I'd like you to help me understand some of the concepts of paragraph and segmentation
User avatar
Thunderbirds747
Member
Member
Posts: 83
Joined: Sat Sep 17, 2016 2:14 am
Location: Moscow, Russia

Re: Write FAT12 Assembly for Floppy

Post by Thunderbirds747 »

IMO it's a pretty childish question, asking a programmer to do this, do that which requires his/her own skills. Learn from various pages, books, documentation, this will help you out. Myself I would just learn X language or look up X tutorials.
-Timothy Ryazanov
Coffee is not airplane fuel.
Post Reply