我正在为 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