4

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

Ammar Atef
  • 96
  • 1
  • 11
  • 11
    When using _ELF_ the _[ORG]_ directive doesn't apply. With _ELF_ You set the origin point using the linker when generating the final binary. If you don't want _ELF_ and want a straight binary use `nasm -f bin` instead. – Michael Petch Mar 10 '17 at 14:16

1 Answers1

5

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.

Ted Klein Bergman
  • 9,146
  • 4
  • 29
  • 50