Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
RawContext: add comments for x86 raw_swapcontext()
[simgrid.git] / src / simix / RawContext.cpp
index 4405027..a1f1f21 100644 (file)
@@ -242,18 +242,24 @@ __asm__ (
    ".type raw_swapcontext,@function\n"
    "raw_swapcontext:\n"
 #endif
-   "   movl 4(%esp),%eax\n" /* old */
-   "   movl 8(%esp),%edx\n" /* new */
+   // Fetch the parameters:
+   "   movl 4(%esp),%eax\n" /* old (raw_stack_t*) */
+   "   movl 8(%esp),%edx\n" /* new (raw_stack_t)  */
+   // Save registers of the current context on the stack:
    "   pushl %ebp\n"
    "   pushl %ebx\n"
    "   pushl %esi\n"
    "   pushl %edi\n"
+   // Save the current context (stack pointer) in *old:
    "   movl %esp,(%eax)\n"
+   // Switch to the stack of the new context:
    "   movl %edx,%esp\n"
+   // Pop the values of the new context:
    "   popl %edi\n"
    "   popl %esi\n"
    "   popl %ebx\n"
    "   popl %ebp\n"
+   // Return using the return address of the new context:
    "   retl\n"
 );
 #else