2

我正在尝试使用代码从引导加载程序打印字符

[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 上测试我的代码。

4

2 回答 2

2

对于实模式 X86 的调试,可以尝试集成 Dosbox 的调试器。

于 2010-01-12T05:59:48.767 回答
0
[BITS 16]       ; We need 16-bit intructions for Real mode
[ORG 0x7C00]    ; The BIOS loads the boot sector into memory location
0x7C00
       mov ah, 0Eh     ; We want to print a single character
       mov al, 'A'     ; That character is 'A'
       mov bh, 0Eh     ; White text on black background, not blinking
       mov bl, 0       ; Page number 0
       int 10h

hang:
       jmp hang        ; Loop, self-jump

times 510-($-$$) db 0  ; Fill the rest of the files with zeros, until we reach 510 bytes
dw 0AA55h              ; Our boot sector identifyer

- 我在 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上获得所有这些信息

于 2012-03-22T08:22:00.147 回答