title: Declaring variable-sized arrays in assembly
body: <p>I'm writing an assembly program which I want to be able to do the (basic) following:</p>
  
  <pre><code>x = 100;
  y = int[x]
  </code></pre>
  
  <p>E.g. the size of y depends on the value of x.</p>
  
  <p>NOTE: I am using NASM instruction set on a 64 bit Ubuntu system.</p>
  
  <p>In assembly I know that the size of an array needs to be declared in the data section of the file e.g.</p>
  
  <pre><code>myvariable resq 1000
  </code></pre>
  
  <p>The problem is I won't know how big to make it till I have done a previous calculation.
  What I really want is something like:</p>
  
  <pre><code>mov rax, 100
  myvariable resq rax
  </code></pre>
  
  <p>But that's not allowed right? Just having some confusion over array access/declarations in assembly.</p>
  
  <p>Any pointers appreciated!</p>