BIOS 中断 0x10 不打印/显示任何内容

问题描述

我正在尝试使用程序集 (FASM) 和 BIOS 中断 0x10 打印字符串。
我声明了字符串,并使用循环将字符串逐个字符加载到内存中,并通过 int 0x10 打印各个字符。

我在 QEMU 中测试了我的代码,但字符串从未打印出来。我试图只打印一个字符,但没有成功。

这是引导加载程序代码 boot.asm

format COFF 
public _start

_start:

    org 0x7C00
    mov si,msg
    mov ah,0x0E     ; Set interrupt code

    print:
        lodsb        ; Load the character
        or al,al    ; Check for 0x0
        jz hang
        int 0x10     ; Call interrupt
        jmp print


hang:
    jmp hang         ; Infinite loop

msg db 'This is a test sentence.',0x0
times 510 - ($-$$) db 0
db 0xAA
db 0x55

这是linker.ld

ENTRY(_start);
SECTIONS
{
    . = 0x7C00;
    .text : AT(0x7C00)
    {
        _text = .;
        *(.text);
        _text_end = .;
    }
    .rodata :
    {
        *(.rodata)
    }

    .data :
    {
        *(.data)
    }

    .bss :
    {
        *(COMMON)
        *(.bss)
    }

}

代码是通过以下命令构建的:

fasm boot.asm boot.o
i686-elf-gcc -T linker.ld -o test.bin -ffreestanding -O2 -nostdlib boot.o

并通过以下命令运行:qemu-system-i386 -L "%QEMU%" -machine type=pc-i440fx-3.1 -kernel test.bin

奇怪的是,如果我从 format COFF 中删除 boot.asm,将其组装为: fasm boot.asm boot.bin ,然后通过 copy /b boot.bin boot.img 将其转换为 .img 文件,并使用QEMU测试它,它实际上打印了字符串。

有没有想过为什么原始代码中没有打印任何内容,但修改后的代码却打印出来了?我做过/理解/忽略了什么吗?
任何帮助表示赞赏。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...