title: Compiling Assembly code
body: <p>I'm trying to compile an ASM program I wrote with NASM and the "ld" command from DJGPP.  This is the code for the batch file I'm using to compiling it:</p>
  
  <pre><code>@echo off
  set path=C:\NASM;%PATH%
  nasm -f aout -o start.o start.asm
  ld -T link.ld -o kernel.bin start.o
  </code></pre>
  
  <p>But when I run the file I get:</p>
  
  <pre><code>start.o: file not recognised: File format not recognized
  </code></pre>
  
  <p>What, in my build file, have I done wrong to cause this error message?</p>
  
  <h2>EDIT</h2>
  
  <p>This is my link.ld file:</p>
  
  <pre><code>OUTPUT_FORMAT("binary")
  ENTRY(start)
  phys = 0x00100000;
  SECTIONS
  {
    .text phys : AT(phys) {
      code = .;
      *(.text)
      *(.rodata)
      . = ALIGN(4096);
    }
    .data : AT(phys + (data - code))
    {
      data = .;
      *(.data)
      . = ALIGN(4096);
    }
    .bss : AT(phys + (bss - code))
    {
      bss = .;
      *(.bss)
      . = ALIGN(4096);
    }
    end = .;
  }
  </code></pre>
  
  <h2>EDIT</h2>
  
  <p>Nothing else is working, so here is the code for my ASM file (I was creating kernel for an Operating System I've been working on):</p>
  
  <pre><code>[BITS 32]
  global start
  start:
      mov esp, _sys_stack
      jmp stublet
  
  ALIGN 4
  mboot:
      MULTIBOOT_PAGE_ALIGN    equ 1&lt;&lt;0
      MULTIBOOT_MEMORY_INFO   equ 1&lt;&lt;1
      MULTIBOOT_AOUT_KLUDGE   equ 1&lt;&lt;16
      MULTIBOOT_HEADER_MAGIC  equ 0x1BADB002
      MULTIBOOT_HEADER_FLAGS  equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO |         MULTIBOOT_AOUT_KLUDGE
      MULTIBOOT_CHECKSUM  equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
      EXTERN code, bss, end
  
      dd MULTIBOOT_HEADER_MAGIC
      dd MULTIBOOT_HEADER_FLAGS
      dd MULTIBOOT_CHECKSUM
  
      dd mboot
      dd code
      dd bss
      dd end
      dd start
  
  stublet:
      jmp $
  
  SECTION .bss
      resb 8192
  _sys_stack:
  </code></pre>