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

时间:2017-03-10 14:15:58

标签: 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

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

nasm -f elf myfile.asm

然后我看到了那个错误

  

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

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

1 个答案:

答案 0 :(得分:3)

从@MichaelPetch的注释部分复制,因此此问题有答案:

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

相关问题