【问题标题】:How do I test my bootloader on a floppy disk如何在软盘上测试引导加载程序
【发布时间】:2014-02-05 06:21:51
【问题描述】:

这是我的代码: http://pastebin.com/pSncVNPK

    [BITS 16]           ;Tells the assembler that its a 16 bit code
    [ORG 0x7C00]        ;Origin, tell the assembler that where the code will
                        ;be in memory after it is been loaded

    MOV SI, HelloString ;Store string pointer to SI
    CALL PrintString    ;Call print string procedure
    JMP $       ;Infinite loop, hang it here.


PrintCharacter: ;Procedure to print character on screen     
                ;Assume that ASCII value is in register
    AL MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
    MOV BH, 0x00    ;Page no.
    MOV BL, 0x07    ;Text attribute 0x07 is lightgrey font on black background

    INT 0x10    ;Call video interrupt RET       ;Return to calling procedure



PrintString:    ;Procedure to print string on screen
                ;Assume that string starting pointer is in register SI

next_character: ;Label to fetch next character from string
    MOV AL, [SI]    ;Get a byte from string and store in AL register
    INC SI      ;Increment SI pointer
    OR AL, AL   ;Check if value in AL is zero (end of string)
    JZ exit_function ;If end then return
    CALL PrintCharacter ;Else print the character which is in AL register
    JMP next_character  ;Fetch next character from string
exit_function:  ;End label
    RET     ;Return from procedure


    ;Data
    HelloString db 'Hello World', 0 ;HelloWorld string ending with 0

    TIMES 510 - ($ - $$) db 0   ;Fill the rest of sector with 0
    DW 0xAA55           ;Add boot signature at the end of bootloader

如您所见,语法似乎是正确的,将其编译为 .bin 文件,但我正在尝试弄清楚如何对其进行测试。请像我有点慢一样对待我,因为我花了 HOURS 谷歌搜索这个主题,但似乎没有任何效果,我什至按照一些教程尝试使用十六进制编辑器,但它没有用。这似乎是我得到的最接近的使用这些说明: http://puu.sh/6KzUo.png

来自此链接:How to make an bootable iso(not cd or flash drive) for testing your own boot loader?

除了我不太明白第 6 步,因为 VM 框不会让我选择 img 文件作为可启动磁盘。

谢谢!

【问题讨论】:

  • 您使用的是 5 1/4 英寸还是 3 1/2 英寸的软盘?
  • @mattingly890 我正在尝试使用虚拟软盘
  • 啊,好吧。您使用的是什么类型的虚拟环境? (VMWare、VirtualBox....)
  • @mattingly890 我正在使用虚拟盒子,我也安装了 ubuntu,这是我将 .asm 编译成 .bin 的地方
  • 您是否能够创建实际的 .img 文件(不是引导它,而是创建它)?

标签: linux assembly operating-system virtualbox bootloader


【解决方案1】:

如果您只需要将软盘添加到磁盘控制器中,请执行以下操作:

单击软盘控制器。带有绿色加号的软盘图标应出现在您选择的左侧。点击这个小图标。


现在应该会出现一个对话框:

选择“选择磁盘”

会出现文件选择框---此时,从文件选择框中选择您的.img文件。

此时您应该能够从软盘启动虚拟机并测试您的引导加载程序。

【讨论】:

  • 感谢您的回复,我意识到我搞砸了,并认为控制器是软盘,我确实像您发布的那样工作了!谢谢
  • @oorosco。如果此答案效果很好,请考虑接受并投票。祝你好运。
猜你喜欢
  • 2014-07-16
  • 1970-01-01
  • 2023-02-21
  • 2018-07-01
  • 1970-01-01
  • 2018-09-09
  • 2020-10-21
相关资源
最近更新 更多