1

I have been following the Operating System development tutorial on http://www.brokenthorn.com. Right now I'm trying to setup the BIOS parameter block with this code:

jmp loader
bpbName db "NubOS",0,0,0
bpbBytesPerSector:      DW 512
bpbSectorsPerCluster:   DB 1
bpbReservedSectors:     DW 1
bpbNumberOfFATs:        DB 2
bpbRootEntries:         DW 224
bpbTotalSectors:        DW 2880
bpbMedia:               DB 0xF0
bpbSectorsPerFAT:       DW 9
bpbSectorsPerTrack:     DW 18
bpbHeadsPerCylinder:    DW 2
bpbHiddenSectors:       DD 0
bpbTotalSectorsBig:     DD 0
bsDriveNumber:          DB 0
bsUnused:               DB 0
bsExtBootSignature:     DB 0x29
bsSerialNumber:         DD 0xa0a1a2a3
bsVolumeLabel:          DB "MOS FLOPPY "
bsFileSystem:           DB "FAT12   "

However, when I try to open the disk using the ImDisk driver for virtual floppies, it says that the drive needs to be formatted. Is the code I'm using correct?

4

3 回答 3

2

您缺少 BPB 之前的 3 字节跳转指令。bytes-per-sector word 应该在相对于磁盘开头的偏移量 0x0b 处,而不是在 0x08 处。跳转将转到 BPB 之后的引导加载程序代码(如果跳转足够短以至于只需要两个字节,则后面跟着一个 nop)。

如果一台机器永远不会从磁盘启动,您可以在前三个字节中放置任意值,但传统的做法是无论如何都要跳转,这会转到一段代码,打印类似This disk is not bootable的内容然后停止机器。

于 2012-05-04T23:16:20.443 回答
2

尝试短跳转:扇区以开头jmp short loader,然后是nop,然后是,然后是所有代码,然后是 512 字节扇区的最后 2 个字节和。这两个必须分别位于偏移量和。bpbNamebsFileSystemloader:0x550xAA510511

于 2012-05-05T19:22:16.950 回答
1

您可以在这里找到完整的 FAt12 驱动程序实现: Simple Operating System with Fat 12 Driver

于 2013-01-04T14:59:39.427 回答