How to move c static variable into register inline assembly
<p>I have the following C code:</p>

<pre><code>/* ctsw.c : context switcher
 */

#include &lt;xeroskernel.h&gt;

void _ISREntryPoint();
static void *k_stack;
static unsigned long *P_ESP;
static unsigned long *ARGS;

void contextinit() {
  set_evec(59, (long) _ISREntryPoint);
}

int contextswitch( pcb *p ) {
  P_ESP = p-&gt;esp;
  int retval = p-&gt;retval;
  __asm __volatile("pushf\n\t"
                   "pusha\n\t"
                   "movl %%esp, k_stack\n\t"
                   "movl P_ESP, %%esp\n\t"
                   "movl retval, 28(%%esp)\n\t"
                   "popa\n\t"
                   "iret\n\t"
                   "_ISREntryPoint:\n\t"
                   "    pusha\n\t"
                   "    movl %%esp, P_ESP\n\t"
                   "    movl 44(%%esp), ARGS\n\t"
                   "    movl k_stack, %%esp\n\t"
                   "    popa\n\t"
                   "    popf\n\t"
                   :
                   :
                   : "%eax"
                   );
  p-&gt;esp = P_ESP;
  p-&gt;args = ARGS + 1;
  return *ARGS;
}
</code></pre>

<p>It is giving me the following compile error:</p>

<pre><code>../c/ctsw.c: Assembler messages:
../c/ctsw.c:21: Error: too many memory references for `mov'
../c/ctsw.c:26: Error: too many memory references for `mov'
</code></pre>

<p>What am I doing wrong? How do mov register values to static variables and vice versa? Thanks</p>