NASM 制作引导加载程序时出现编译器错误

NASM compiler error while making bootloader

我正在汇编中制作引导加载程序,在 NASM 中编译我的文件时出现编译器错误。 输出是:

bootloader.asm:1: error: label or instruction expected at start of line
bootloader.asm:16: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
bootloader.asm:23: warning: label alone on a line without a colon might be in error [-w+orphan-labels]

有人可以帮忙吗?这是我的代码:

[BITS 16]
[ORG 0x7C00]

MOV SI, BOOTLOADERSTR
CALL PrintString
JMP $

PrintCharacter:
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07

INT 0x10
RET

PrintString
next_character:
MOV AL, [SI]
INC SI
OR AL, AL
JZ exit_function
CALL PrintCharacter
exit_function
RET

;DATA
BOOTLOADERSTR db 'it-is-OK Bootloader for OpenKasrix' , 0

TIMES 510 - ($ - $$) db 0
DW 0xAA55

bootloader.asm:1: error: label or instruction expected at start of line

我无法用 NASM version 2.11.08 重现第一个错误,所以一定还有另一个问题,例如 BOM (Byte-Order-Mark)。因此,检查第一个字节是否与本文中提到的序列之一相匹配——如果是,则删除它们(使用 Hex-Editor 或 Saving-Options 或 ...)。然后这个无法识别的错误应该神奇地消失了。

接下来的两个错误是标签末尾缺少 :

PrintString      ; line 16
exit_function    ; line 23

在末尾添加一个冒号,错误将消失。所以它们应该看起来像

PrintString:     ; line 16
exit_function:   ; line 23