Ammar Atef
Ammar Atef

Reputation: 126

error: unrecognised directive [ORG]

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

Upvotes: 5

Views: 3944

Answers (1)

Ted Klein Bergman
Ted Klein Bergman

Reputation: 9766

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

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.

Upvotes: 5

Related Questions