hsh*_*hab 3 x86 assembly function bios nasm
我正在从头开始构建一个简单的操作系统,所以我正在测试一些启动扇区代码,我正在使用Qemu进行模拟.
我的启动扇区代码应该在操作系统启动时打印"A".
这是引导扇区代码的第一个版本(没有使用函数调用)
[org 0x7c00]
mov al,'A'
mov ah,0x0e ; int 10/ ah = 0eh -> scrolling teletype BIOS routine
int 0x10
jmp $
times 510 -( $ - $$ ) db 0
dw 0xaa55
Run Code Online (Sandbox Code Playgroud)
执行nasm生成的二进制文件后使用:
qemu-system-i386 test.bin
Run Code Online (Sandbox Code Playgroud)
结果是正确的,字符'A'出现在它应该的位置
但是,在尝试使用打印存储在al中的字符的功能后,屏幕上不会打印任何内容
这是test.asm文件的第二个版本(这次包括函数调用)
[org 0x7c00]
mov al,'A'
call my_print_function
jmp $
times 510 -( $ - $$ ) db 0
dw 0xaa55
my_print_function:
pusha ; push all registers
; same code as the first version to print a character stored in al
mov ah,0x0e
int 0x10
popa ; pop all registers
ret
Run Code Online (Sandbox Code Playgroud)
那为什么它不能正常运作?
任何帮助将不胜感激.
谢谢
您必须在其末尾具有引导扇区的签名.我在谈论这部分:
times 510 -( $ - $$ ) db 0
dw 0xaa55
Run Code Online (Sandbox Code Playgroud)
现在你my_print_function跌倒在bootsector之外,甚至没有被BIOS加载.
您需要在签名之前将此功能移动到此处.