【问题标题】:Problem with my own bootloader, file convertion from .bin to .iso failed我自己的引导加载程序有问题,从 .bin 到 .iso 的文件转换失败
【发布时间】:2020-05-16 02:03:45
【问题描述】:

目前我尝试使用 nasm 编写自己的引导加载程序,但我并没有真正成功。

问题是,我想将我的 .bin 文件转换为 .iso 或其他映像文件,以便 VM 识别它。

但是我的转换程序说文件损坏了。

我的 .bin 文件是在 Linux 下使用 NASM 编译器编译的,大小正好是 512 字节。

nasm boot.asm -f bin -o boot.bin
[BITS 16]
[ORG 0x7C00]

start:
 mov    SI, msg

 call   eachstring
 jmp    $

eachstring:
 mov    AL, [SI]
 inc    SI

 OR     AL, AL
 je     end
 jne    printchar

printchar:
 mov    AL, [SI];Parameter festlegen

 mov    AH, 0x0E;Opcode ein Zeichen auszugeben
 mov    BH, 0x00;Keine Seite
 mov    BL, 0x07
 int    0x10
 ret

end:
 ret

msg     db 'Hallo Welt', 0
TIMES 510 - ($ - $$) db 0;Füllt den restlichen Speicher
dw 0xAA55;Magic key

我希望有人可以帮助我。 =(

提前谢谢你

最好的问候

【问题讨论】:

  • 你应该展示你是如何转换它的以及你得到了什么错误信息。
  • 感谢您的回答。我尝试了两种不同的工具,但都给了我一个错误。 linux下的包“iat”“图像损坏”和ccd2iso“扇区0错误。扇区不包含完整数据。扇区大小必须为2352,而实际读取的数据为512”

标签: assembly operating-system virtual-machine nasm bootloader


【解决方案1】:

.iso 是多余的,并且引导加载程序的填充使您的 .bin 与软盘扇区大小相同,因此请改用软盘映像:

#Prepare an empty image, this is the maximum size of a floppy disk
dd if=/dev/zero of=boot.img bs=1024 count=1440
#Insert your .bin to the first sector of the floppy disk
dd if=boot.bin of=boot.img conv=notrunc 

运行此程序将生成可引导软盘映像boot.img

有关更多信息,请参阅此答案:https://stackoverflow.com/a/34108769/5269447

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 2012-04-09
    • 2015-11-28
    • 2011-05-07
    • 1970-01-01
    • 2016-03-20
    相关资源
    最近更新 更多