linux - 如何在软盘上测试引导加载程序

标签 linux assembly operating-system virtualbox bootloader

这是我的代码: 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 box 不允许我选择 img 文件作为可启动磁盘。

谢谢!

最佳答案

如果您只需要在磁盘 Controller 中添加一张软盘,可以这样做:

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

enter image description here


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

enter image description here

选择“选择磁盘”

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

enter image description here

从现在开始,您应该能够从软盘启动虚拟机并测试您的引导加载程序。

关于linux - 如何在软盘上测试引导加载程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21570017/

相关文章:

windows - 我怎样才能返回Windows 7和Windows XP和Linux的引导加载程序

linux - "$1/*"中的 "for file in $1/*"是什么意思

c - 在Y86汇编中如何为多个数组分配好空间?

assembly - 在 .data 中添加另一个单词会扰乱 x86 中的值

arrays - 程序给出信号 SIGABRT : Process abort signal in one code and does not in other code

html - 如何让我的搜索栏在所有屏幕上正确对齐。(和操作系统)

linux - 为什么要在保护模式下启用 A20 线?

linux - 与 linux/mac 相比,在 solaris 中查找的用法

linux - grep -1 卡住,但它应该报告无效标志

linux - 如何在 GNU 汇编中将数据列表作为参数传递?