assembly - BIOS Interrupt 0x10 Does Not Print/Display Anything
问题描述
I am trying to print a string using assembly (FASM) and the BIOS interrupt 0x10.
I declared the string, and used a loop to load the string character by character into memory and print the individual characters via int 0x10
.
I tested my code in QEMU, but the string never got printed out. I tried to print only a single character and that did not work.
Here is the bootloader code 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
Here is linker.ld
:
ENTRY(_start);
SECTIONS
{
. = 0x7C00;
.text : AT(0x7C00)
{
_text = .;
*(.text);
_text_end = .;
}
.rodata :
{
*(.rodata)
}
.data :
{
*(.data)
}
.bss :
{
*(COMMON)
*(.bss)
}
}
The code was built via the following commands:
fasm boot.asm boot.o
i686-elf-gcc -T linker.ld -o test.bin -ffreestanding -O2 -nostdlib boot.o
and was run via this command: qemu-system-i386 -L "%QEMU%" -machine type=pc-i440fx-3.1 -kernel test.bin
What is certainly odd is that if I remove the format COFF
from boot.asm
, assemble it with: fasm boot.asm boot.bin
, turn it it to a .img file via copy /b boot.bin boot.img
, and use QEMU to test it, it actually prints the string.
Any thoughts on why nothing gets printed in the original code but it does with the modified one? Have I done/understood/overlook something?
Any help is appreciated.
解决方案
推荐阅读
- html - CSS中的背景图像无法正常工作
- python - 在 python 中解析带有特殊字符 \" 的 JSON 对象
- angular - jqWdigets TreeTable 在 angular2 代码中面临以下错误:addButton.jqxButton
- php - 使用php中的系统函数在变量中返回mysql错误
- ios - 获取 iOS 上 NavigationBar 的默认高度(或 maxY)
- batch-file - .bat 文件中嵌套 if 中 %errorlevel% 的错误值
- c - 打印编译时保存的文件名
- pointers - Go中如何使用地图作为数据载体?
- css - Woocommerse minicart 小部件按钮悬停覆盖
- sql-server - 每批表达式的 SSIS 行数