Index: src/libcfa/concurrency/CtxSwitch-i386.S
===================================================================
--- src/libcfa/concurrency/CtxSwitch-i386.S	(revision e4745d7a69e805e1610459cace93880b062586f3)
+++ src/libcfa/concurrency/CtxSwitch-i386.S	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -0,0 +1,90 @@
+//                               -*- Mode: Asm -*-
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// CtxSwitch-i386.S --
+//
+// Author           : Thierry Delisle
+// Created On       : Tue Dec 6 12:27:26 2016
+// Last Modified By : Thierry Delisle
+// Last Modified On : Tue Dec 6 12:27:26 2016
+// Update Count     : 0
+//
+// This  library is free  software; you  can redistribute  it and/or  modify it
+// under the terms of the GNU Lesser General Public License as published by the
+// Free Software  Foundation; either  version 2.1 of  the License, or  (at your
+// option) any later version.
+//
+// This library is distributed in the  hope that it will be useful, but WITHOUT
+// ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+// for more details.
+//
+// You should  have received a  copy of the  GNU Lesser General  Public License
+// along  with this library.
+//
+
+// This context switch routine depends on the fact that the stack of a new
+// thread has been set up to look like the thread has saved its context in
+// the normal manner.
+//
+// void CtxSwitch( machine_context *from, machine_context *to );
+
+// Offsets in the context structure. This needs to be synchronized with the
+// high level code a little better.
+
+#define PTR_BYTE	4
+#define SP_OFFSET	( 0 * PTR_BYTE )
+#define FP_OFFSET	( 1 * PTR_BYTE )
+#define PC_OFFSET	( 2 * PTR_BYTE )
+
+.text
+	.align 2
+.globl	CtxSwitch
+CtxSwitch:
+
+	// Copy the "from" context argument from the stack to register eax
+	// Return address is at 0(%esp), with parameters following
+
+	movl 4(%esp),%eax
+
+	// Save volatile registers on the stack.
+
+	pushl %ebx
+	pushl %edi
+	pushl %esi
+
+	// Save old context in the "from" area.
+
+	movl %esp,SP_OFFSET(%eax)
+	movl %ebp,FP_OFFSET(%eax)
+//	movl 4(%ebp),%ebx	// save previous eip for debugger
+//	movl %ebx,PC_OFFSET(%eax)
+
+	// Copy the "to" context argument from the stack to register eax
+	// Having pushed three words (= 12 bytes) on the stack, the
+	// argument is now at 8 + 12 = 20(%esp)
+
+	movl 20(%esp),%eax
+
+	// Load new context from the "to" area.
+
+	movl SP_OFFSET(%eax),%esp
+	movl FP_OFFSET(%eax),%ebp
+
+	// Load volatile registers from the stack.
+
+	popl %esi
+	popl %edi
+	popl %ebx
+
+	// Return to thread.
+
+	ret
+
+// Local Variables: //
+// compile-command: "make install" //
+// End: //
Index: src/libcfa/concurrency/invoke.c
===================================================================
--- src/libcfa/concurrency/invoke.c	(revision 78b3f524dae38189ed4f479ebdc4c6f51903a1f1)
+++ src/libcfa/concurrency/invoke.c	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -28,13 +28,13 @@
 
 void __startCoroutine__A0_1_0___this_coroutine__PFP10scoroutine_Pd0___co_main__PF_Pd0___vtable__PFP9scoVtable_Pd0__F_Pd0PF_P9scoVtablePv___1(
-      struct coroutine *(*this_coroutine)(void * ), 
-      void (*co_main)(void *), 
-      struct coVtable *(*get_vtable)(void *), 
-      void *vthis, 
+      struct coroutine *(*this_coroutine)(void * ),
+      void (*co_main)(void *),
+      struct coVtable *(*get_vtable)(void *),
+      void *vthis,
       void (*invoke)(struct coVtable *, void *)
 ) {
 
-      #if ! defined( __x86_64__ )
-            #error Only __x86_64__ is supported for threads in cfa
+      #if ! defined( __x86_64__ ) && ! defined( __i386__ )
+            #error Only __x86_64__ and __i386__ is supported for threads in cfa
       #endif
 
