title: Inline assembly inside loops
body: <p>I use inline assembly massively in a project where I need to call functions with an unknown number of arguments at compile time and while I manage myself to get it to work, sometimes, in linux (in windows I don't recall having that problem) strange things like this happen:</p>
  
  <p>If I have something like</p>
  
  <pre><code>for(int i = 1; i &gt;= 0; i--)
     asm("push %0"::"m"(someArray[i]));
  </code></pre>
  
  <p>It works.</p>
  
  <p>If I have </p>
  
  <pre><code>for(int i = this-&gt;someVar; i &gt;= 0; i--)
     asm("push %0"::"m"(someArray[i]));
  </code></pre>
  
  <p>and I guarantee with my life that someVar is holding the value 1 it throws segmentation fault.</p>
  
  <p>Also if I have</p>
  
  <pre><code>int x = 1;
  for(int i = x; i &gt;= 0; i--)
     asm("push %0"::"m"(someArray[i]));
  </code></pre>
  
  <p>it works but</p>
  
  <pre><code>int x = this-&gt;someVar;
  for(int i = x; i &gt;= 0; i--)
      asm("push %0"::"m"(someArray[i]));
  </code></pre>
  
  <p>does not.</p>
  
  <p>Also, and also strangely, I can say that while in some functions I don't have problems doing that in others I have, all in the same object.</p>
  
  <p>If someone can point me to some information that can clear up what's the problem there, I would appreciate.</p>
  
  <p>Beware that I really have to push the arguments in a for loop so avoiding it is not an option.</p>
  
  <p>I also tried using the inline assembly word "volatile" but nothing changed.</p>