英文:
Why my print function doesn't print my string?
问题
我刚刚开始创建我的第一个操作系统,我想从一个非常简单的引导加载程序开始,基本上只是打印一个非常简单的字符串。但我弄不明白为什么无论是什么字符串,虚拟机(qemu)都只会打印一个'U'
这是我的代码:
ORG 0x7c00
BITS 16
%include "lib/print.asm"
boot:
mov si, boot_msg
call Print
jmp $
boot_msg: db "操作系统已正确加载!", 0
times 510 - ($ - $$) db 0
dw 0xAA55
打印函数 (lib/print.asm):
Print:
mov ah, 0x0e
mov al, [si]
psloop:
int 0x10
inc si
mov al, [si]
cmp al, 0
jne psloop
ret
ret
英文:
I just started creating my first operating system, I wanted to start with a very simple bootloader that basically just prints a very simple string. But I can't figure out why, whatever string, the virtual machine (qemu) just prints a 'U'
This is my code:
ORG 0x7c00
BITS 16
%include "lib/print.asm"
boot:
mov si, boot_msg
call Print
jmp $
boot_msg: db "The os is correctly loaded!", 0
times 510 - ($ - $$) db 0
dw 0xAA55
Print function (lib/print.asm):
Print:
mov ah, 0x0e
mov al, [si]
psloop:
int 0x10
inc si
mov al, [si]
cmp al, 0
jne psloop
ret
ret
答案1
得分: 2
I put jmp boot
before Print label.
使用nasm -f bin boot.asm -o boot.bin
编译boot.asm。
将boot.bin
复制到qemu文件夹并运行qemu-system-i386 -fda boot.bin
。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论