title: 64 assembly language using nasm on ubuntu
body: <p>I am trying to write a simple hello world program in 64-bit assembly and run on Ubuntu 64 bit.  The program is as follows :</p>
  
  <pre><code>global _start           ; entry point export for ld section .text   
  _start:     ; system call to write message to stdout
      mov rax, 1      ; sys_write
      mov rdi, 1      ; stdout
      mov rsi, mes    ; message address
      mov rdx, len    ; message length
      syscall     ; exit sys call
      mov rax, 60     ; exit call id
      mov rdi, 0      ; return success
      syscall
  section .data
      mes: db 'Hello, world!',0x0A    ; message
      len :   equ $-mes   
  </code></pre>
  
  <p>I assembled it using  <code>nasm -f elf64 hello64.asm</code>
  and tried linking it using <code>ld -o hello64 hello64.o</code>
  it gives me following error -  </p>
  
  <blockquote>
    <p>ld: i386:x86-64 architecture of input file `hello64.o' is incompatible
    with i386 output</p>
  </blockquote>
  
  <p>I get same error even when using flags --oformat elf64-x86-64 or elf64-little or elf64-big.</p>
  
  <p>can someone help out ?</p>