从引导加载程序打印字符
我正在尝试使用代码从引导加载程序打印字符
[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 AL, 65
CALL PrintCharacter
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
TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with 0
DW 0xAA55 ;Add boot signature at the end of bootloader
按照 编写 Hello World Bootloader。但它只是挂起而不打印任何内容。我们如何调试这个?我已使用以下代码成功创建了挂起引导加载程序,
[BITS 16] ;tell 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
JMP $ ;infinite loop
TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0
DW 0xAA55 ; add boot signature at the end of bootloader
我正在 VMware 3.0.0 build-203739 上测试我的代码。
I am trying to print character from boot loader using code
[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 AL, 65
CALL PrintCharacter
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
TIMES 510 - ($ - $) db 0 ;Fill the rest of sector with 0
DW 0xAA55 ;Add boot signature at the end of bootloader
As directed in Writing Hello World Bootloader. But it just hangs without printing anything. How can we debug this ? I have successfully created hanging boot loader using following code
[BITS 16] ;tell 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
JMP $ ;infinite loop
TIMES 510 - ($ - $) db 0 ;fill the rest of sector with 0
DW 0xAA55 ; add boot signature at the end of bootloader
I am testing my code on VMware 3.0.0 build-203739.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要调试实模式 X86,您可以尝试与 Dosbox 集成的调试器。
For debugging real-mode X86, you can try the debugger integrated with Dosbox.
-
我在Windows下的nasm和Bochs的帮助下成功运行了这段代码。
指示 :-
1)nasm -f bin booting.asm -o booting.bin
“-f bin”指定纯二进制格式。
2)将文件复制到 Bochs 目录中并使用 booting.bin 作为软盘运行它,我们就完成了
我什至通过在闪存驱动器上刻录 bin 文件的映像来测试它,并在启动该闪存驱动器时我能够得到我所期望的。您可以获取所有这些信息
http://www.weethet.nl/english/hardware_bootfromusbstick.php
-
i successfully managed to run this code with the help of nasm and Bochs under windows.
Instructions :-
1)nasm -f bin booting.asm -o booting.bin
The '-f bin' specifies the format to plain binary.
2)Copy the file into Bochs' directory and run it with the booting.bin as a floppy and we're done
I even tested it by burning the image of bin file on a flash drive and on booting that flash drive i was able to get what i expected. You can get all that info on
http://www.weethet.nl/english/hardware_bootfromusbstick.php