title: Use int rand(void) in assembly
body: <p>I am trying to use the function </p>
  
  <pre><code>int rand(void)
  </code></pre>
  
  <p>in assembly.</p>
  
  <p>How do I use it? I want to get a random number between 0 and 20.</p>
  
  <p>How can I do that? </p>
  
  <p>I'm working on a Ubuntu 32 bits OS and using the at&amp;t assembly syntax.
  This is a sample of my code, i want it to put a random number between 0 and 20 in the %edx registry.</p>
  
  <p>EDIT:</p>
  
  <pre><code>    mov $APPLES_X, %ebx
      mov $0, %ecx
      mov $20, %edx
  loop_ax:
      call    rand
      idiv    %edx
      mov %edx, (%ebx)
  
      add $4, %ebx
  
      inc %ecx
      cmp NAPPLES, %ecx
      jne loop_ax
  </code></pre>