【问题标题】:Printing character from boot loader从引导加载程序打印字符
【发布时间】:2012-03-22 16:22:00
【问题描述】:

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

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

【问题讨论】:

    标签: bootloader


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:
      [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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-07
        • 1970-01-01
        • 2021-06-28
        • 2021-07-19
        • 2016-12-02
        • 2017-07-05
        • 2016-04-30
        • 2016-10-30
        相关资源
        最近更新 更多