为什么我的打印函数不打印我的字符串?

huangapple go评论52阅读模式
英文:

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

英文:

I put jmp boot before Print label.

Compile boot.asm with nasm -f bin boot.asm -o boot.bin

Copy boot.bin to qemu folder and run qemu-system-i386 -fda boot.bin

为什么我的打印函数不打印我的字符串?

huangapple
  • 本文由 发表于 2023年5月23日 01:19:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定