title: AT&T - reading file
body: <p>I'm trying to read (at least) first line of the file. I'm using syscalls to open and close file, but it seems I have a problem with reading contents from file, because the result is just some unknown symbol.</p>
  
  <pre><code>.data
  name: .string "temp.txt"
  fd: .byte 0
  buf: .string "0"
  len: .long 512
  .text                       
  .globl  main           
  .type   main, @function       
  main:
      # open file
      movl $5, %eax # sys_open
      movl $name, %ebx
      movl $0, %ecx # access: read-only
      movl $0777, %edx # read, write and execute by all
      int $0x80
  
      # get file descriptor
      movl %eax, fd
  
      # read from file
      movl $3, %eax # sys_read
      movl $fd, %ebx
      movl $buf, %ecx
      movl $len, %edx
      int $0x80
  
      # close file
      movl $6, %eax # sys_close
      movl $name, %ebx
      int $0x80
  
  # print
     movl $4, %eax
     movl $1, %ebx
     movl $fd,%ecx
     movl $len, %edx
     int $0x80
  
   # exit(0)
      movl    $1, %eax  
      movl    $0, %ebx   
      int     $0x80     
  
  .size   main, . - main  
  </code></pre>
  
  <p>Compiling it like <code>gcc code.s -o code</code> and running <code>./code</code></p>