开发者

Custom bootloader issues

Im trying to w开发者_开发技巧rite a bootloader for a Hobby OS and have it working great. Nothing Special, just prints a line of text:

BITS 16
ORG 0

start: jmp main


OEM         db "Test OS "           
BytesPerSector:     DW 512
SectorsPerCluster:  DB 1
ReservedSectors:    DW 1
NumberOfFATs:   DB 2
RootEntries:    DW 224
TotalSectors:   DW 2880
Media:      DB 0xf8  
SectorsPerFAT:  DW 9
SectorsPerTrack:    DW 18
HeadsPerCylinder:   DW 2
HiddenSectors:  DD 0
TotalSectorsBig:    DD 0
DriveNumber:        DB 0
Unused:         DB 0
ExtBootSignature:   DB 0x29
SerialNumber:   DD 0xa0a1a2a3
VolumeLabel:    DB "HOBBY  OS  "
FileSystem:         DB "FAT12   "



main:
    ;Adjust code Seg.
    cli
    mov ax, 0x07c0
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    ;Set up Stack
    mov ax, 0x0000
    mov ss, ax
    mov sp, 0xFFFF
    sti

    mov si, msg
    call print

print:

    .charLoop:

        lodsb
        or al,al
        jz .done
        mov ah, 0x0E
        int 0x10
    .done
        ret

msg db "Hello World",13,10,0

Im compiling with

nasm -f bin loader.asm -o loader.bin
dd if=loader.bin of=floppy.img bs=512 count=1 seek=0

I've read that the first 446 bytes are the boot code and bytes 447 - 509 is the partition table. I tried then using:

dd if=loader.bin of=floppy.img bs=446 count=1 seek=0

to try to prevent the partition table from being overwritten but still no cigar.

Im using a Mac with OSX and Testing the OS with VirtualBox

I can run the floppy.img in VBox and the code works fine, but when I try to install the bootloader onto a FAT 16 Formatted disk, OSX can't seem read the disk image any more as if it became unformatted.

The exact message out of disk utility is Unable to attach image "floppy.img."(No Mountable File Systems) Even though I just formatted the disk with a FAT 16 file system.

Unfortunatly since this is my first post, I can't give you a picture.

I would really appreciate any help. Disk structure really isn't my forte.


When you're using dd, try adding the conv=notrunc option. This forces it to not try to truncate the file, but rather, just overwrite the parts you specified.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜