title: Conditional jump not taken
body: <p>I'm beginning with assembly (x86, linux), just for fun. This is my very first little program, which just checks if I passed one argument through command line and if not it prints a message, and it exits after that:</p>
  
  <pre><code>section .text
      global  _start
  
  _start: 
      pop ebx     ;argc
      dec ebx
      test    ebx,1
      jne print_string
  exit:
      mov ebx,0
      mov eax,0
      int 0x80
  
  print_string:
      mov edx,len
      mov ecx,msg
      mov ebx,1
      mov eax,4
      int 0x80
      call    exit
  
  section .data
  msg db  "Ok, no arg was passed",0xa
  len equ $ - msg
  </code></pre>
  
  <p>I'm having two problems with the code above:</p>
  
  <ol>
  <li><code>jne</code> is not taken. I checked with gdb that <code>ebx</code> is equal to 0x00 after <code>dec</code>, but EFLAGS are not changed by the <code>test</code> instruction.</li>
  <li><em>exit</em> syscall does not exit! So instead of exiting I just got my message printed in an infinite loop, as <em>print_string</em> is calling <em>exit</em> and after <em>exit</em> there goes <em>print_string</em> over and over again.</li>
  </ol>
  
  <p>What's happening here? Also any other recommendations about the code will be welcome. Thanks.</p>