error: unrecognised directive [ORG]

2019-07-25 10:52发布

问题:

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

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

nasm -f elf myfile.asm

Then I see that error

error: unrecognised directive [ORG]

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