我正在尝试将引导加载程序写入 VirtualBox VM 中插入的虚拟软盘驱动器。这是我拥有的以下代码:
org 0x7c00 ; We are loaded by BIOS at 0x7C00
bits 16 ; We are still in 16 bit Real Mode
Start: jmp loader
loader:
.Reset:
mov ah, 0x0 ; reset floppy disk function
mov dl, 0x0 ; drive 0 is floppy drive
int 0x13 ; call BIOS
jc .Reset ; If Carry Flag (CF) is set, there was an error. Try resetting again
.Load:
mov ax, 0x07e0 ; we are going to read sector to into address 0x07e0:0
mov es, ax
xor bx, bx
mov ah, 0x2 ; read floppy sector function
mov al, 0x1 ; read 1 sector
mov ch, 0x1 ; we are reading the second sector past us, so its still on track 1
mov cl, 0x2 ; sector to read (The second sector)
mov dh, 0x0 ; head number
mov dl, 0x0 ; drive number. Remember Drive 0 is floppy drive.
int 0x13 ; call BIOS - Read the sector
jc .Load
jmp 0x07e0:0x0000 ; jump to execute the sector!
times 510 - ($-$$) db 0 ; We have to be 512 bytes. Clear the rest of the bytes with 0
dw 0xAA55 ; Boot Signiture
它应该将一个小程序加载到内存中,该程序使用 BIOS 中断在屏幕上打印字母“A”。该程序位于软盘的第二个扇区:
org 0x07e0
xor bx, bx
mov ah, 0x0e
mov al, 'A'
int 0x10
cli
hlt
谁能告诉我为什么这没有加载?我已经尝试加载到内存 0x1000 中的另一个地址,但是,这也不起作用。虚拟内存中是否有某些区域被 VirtualBox 保留?
谢谢!!
H
*编辑:
我使用 nasm for Windows (nasm -f bin -o bootS1.bin bootS1.asm) 构建我的代码,然后使用名为 HxD 的程序将二进制文件中的十六进制复制并粘贴到 VFD 映像上,该程序将原始十六进制数据写入磁盘。然后将磁盘插入 VM 并运行以模拟启动过程。