【发布时间】: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