错误:无法识别的指令[ORG] [英] error: unrecognised directive [ORG]

查看:188
本文介绍了错误:无法识别的指令[ORG]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was trying to write a boot-loader to use in dos-box I wrote the following code

[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进行组装

I was trying to assemble it using nasm by the following command

nasm -f elf myfile.asm

然后我看到那个错误

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

error: unrecognised directive [ORG]

我正在使用ubuntu 14.04 LTS,并且nasm的版本是2.10.09

I'm using ubuntu 14.04 LTS and the version of nasm is 2.10.09

推荐答案

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

Copied from @MichaelPetch in the comment section so this question has an answer:

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

When using ELF the [ORG] directive doesn't apply. With ELF, you set the origin point by using the linker when generating the final binary. If you don't want ELF and want a straight binary, use nasm -f bin myfile.asm instead.

这篇关于错误:无法识别的指令[ORG]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆