【问题标题】:error: unrecognised directive [ORG]错误:无法识别的指令 [ORG]
【发布时间】:2017-03-10 14:15:57
【问题描述】:

我正在尝试编写一个引导加载程序以在 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

【问题讨论】:

  • 使用 ELF 时,[ORG] 指令不适用。使用 ELF 您在生成最终二进制文件时使用链接器设置原点。如果您不想要 ELF 而想要直接二进制,请改用 nasm -f bin

标签: assembly nasm bootloader dosbox


【解决方案1】:

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

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

【讨论】:

  • 复制自评论部分的@MichaelPetch,所以这个问题有答案。
猜你喜欢
  • 2016-08-30
  • 1970-01-01
  • 2011-10-25
  • 1970-01-01
  • 2017-12-18
  • 1970-01-01
  • 2019-08-27
  • 2017-06-09
  • 1970-01-01
相关资源
最近更新 更多