错误:无法识别的指令 [ORG]

Amm*_*tef 5 assembly nasm bootloader dosbox

我试图编写一个引导加载程序以在 dos-box 中使用我编写了以下代码

[BITS 16]   ;tell the assembler that its a 16 bit code
[ORG 0x7C00]    ;Origin, tell the assembler that where the code will
;be in memory after it is been loaded

JMP $       ;infinite loop

TIMES 510 - ($ - $$) db 0   ;fill the rest of sector with 0
DW 0xAA55           ; add boot signature at the end of bootloader
Run Code Online (Sandbox Code Playgroud)

我试图通过以下命令使用 nasm 组装它

nasm -f elf myfile.asm
Run Code Online (Sandbox Code Playgroud)

然后我看到那个错误

错误:无法识别的指令 [ORG]

我使用的是ubuntu 14.04 LTS,nasm的版本是2.10.09

Ted*_*man 5

从评论部分的@MichaelPetch 复制,所以这个问题有一个答案:

使用ELF时, [ORG]指令不适用。使用ELF,您可以在生成最终二进制文件时使用链接器设置原点。如果您不需要ELF并且想要直接的二进制文件,请nasm -f bin myfile.asm改用。