引导加载程序在Bochs中正确加载是否需要BPB?

时间:2015-03-25 13:53:54

标签: assembly bootloader bochs

我正在为FAT12软盘编写引导程序并使用BFI创建IMG图像。如果我从引导加载程序程序集中删除BPB代码,则在Bochs中收到以下错误:

MOV_EwSw: using of nonexisting segment register 7

此引导加载程序只是打印一个字符串。

Bochs中BPB代码是否必要?为什么?

代码

bits    16

org     0x7c00

start:          jmp loader

bpbOEM          db "My OS   "

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   "

msg db 0xD, 0xA, "Welcome to My Operating System!", 0

Print:
            lodsb
            or          al, al
            jz          PrintDone
            mov         ah, 0eh
            int         10h
            jmp         Print
PrintDone:
            ret

loader:

    xor ax, ax
    mov ds, ax
    mov es, ax

    mov si, msg
    call Print

    xor ax, ax
    int 0x12

    cli
    hlt

times 510 - ($-$$) db 0

dw 0xAA55

0 个答案:

没有答案