我对汇编编程还是比较陌生,想知道为什么我的代码不能显示预期的字符串。完成后,该项目应该是引导加载程序。我正在使用命令nasm -f bin boot.asm -o boot.bin
进行编译。编译期间没有错误。
boot.asm
bits 16
org 0x7C00
%include "print.asm"
%include "text.asm"
boot:
mov si, boot_string_00
call print
mov si, boot_string_01
call print
times 510 - ($-$$) db 0
dw 0xAA55
print.asm
print:
mov ah, 0x0E
.print_loop:
lodsb
or al, al
je .print_done
int 0x10
jmp .print_loop
.print_done:
cli
ret
text.asm
boot_string_00: db "Placeholder OS Title v0.0.1", 0
boot_string_01: db "Loading Operating system", 0
预期输出:
PlaceHolder OS Title v0.0.1Loading Operating System
实际输出:
S
而且,我想知道如何在汇编中实现换行符,以便在字符串中仅使用'\ n'。
感谢您的任何答复!
请尝试这样的boot.asm:
bits 16
org 0x7C00
boot:
mov si, boot_string_00
call print
mov si, boot_string_01
call print
%include "print.asm"
%include "text.asm"
times 510 - ($-$$) db 0
dw 0xAA55
在qemu上工作。