title: redirecting result of running assembly code in linux to text file
body: <p>I'm trying to write a Python script to test the output of some various code I've written in assembly against an expected output. However I am having difficulty redirecting the output into a file.
  I have written the following:</p>
  
  <pre><code>extern printf
  LINUX   equ     80H     ; interupt number for entering Linux kernel
  EXIT    equ     1       ; Linux system call 1 i.e. exit ()
  section .data
      intfmt: db "%ld", 10, 0
  
  segment .text
      global  main
  
  
  main:
      push rax
      push rsi
      push rdi
      mov rsi, 10
      mov rdi, intfmt
      xor rax, rax
      call printf
      pop rdi
      pop rsi
      pop rax 
      call os_return      ; return to operating system
  
  
  os_return:
      mov  rax, EXIT      ; Linux system call 1 i.e. exit ()
      mov  rbx, 0     ; Error code 0 i.e. no errors
      mov rcx, 5
      int  LINUX      ; Interrupt Linux kernel
  </code></pre>
  
  <p>I then procede to do the following in the console:</p>
  
  <pre><code>nasm -f elf64 basic.asm
  gcc -m64 -o basic basic.o
  ./basic
  </code></pre>
  
  <p>Which outputs 10 to the screen.
  However if I enter</p>
  
  <pre><code>./basic &gt; basic.txt
  cat basic.txt
  </code></pre>
  
  <p>basic.txt appears as an empty file.
  My overall goal is to write a shell script that loops over each assembly file to compiling and run the file and then redirect the output of this script into a file. However I cannot do this until I can get it to work with a single file.
  I was wondering it it was something to do with my call to printf? Although I was under the illusion that printf writes to STDOUT.</p>
  
  <p>Thanks in advance!</p>