我正在尝试使用代码
从引导加载程序中打印字符[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
按照Writing 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上测试我的代码。
答案 0 :(得分:2)
对于调试实模式X86,您可以尝试与Dosbox集成的调试器。
答案 1 :(得分: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