Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 错误:无法识别的指令[ORG]_Assembly_Nasm_Bootloader_Dosbox - Fatal编程技术网

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

Assembly 错误:无法识别的指令[ORG],assembly,nasm,bootloader,dosbox,Assembly,Nasm,Bootloader,Dosbox,我正试图编写一个引导加载程序,以便在dos盒中使用 我编写了以下代码 [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

我正试图编写一个引导加载程序,以便在dos盒中使用 我编写了以下代码

[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]


我使用的是Ubuntu14.04 LTS,nasm的版本是2.10.09

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

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


使用ELF时,[ORG]指令不适用。使用ELF,您可以在生成最终二进制文件时使用链接器设置原点。如果您不想要ELF,而想要一个直接的二进制文件,请使用
nasm-f bin
。复制自注释部分的@MichaelPetch,这样这个问题就有了答案。