[Prev][Next][Index][Thread]

thread switch



Hello oskit-users,

  I am testing my switching code,and I use the following code
void switchto(struct type_thread  *from,struct type_thread  *to)
{
        printf("Now in the switchto function\n");
        getchar();
        asm volatile("movl %%eax,%0\n\t"        \
                     "movl %%ebx,%1\n\t"        \
                        "movl %%ecx,%2\n\t"             \
                        "movl %%edx,%3\n\t"             \
                        "movl %4,%%eax\n\t"             \
                        "movl %5,%%ebx\n\t"             \
                        "movl %6,%%ecx\n\t"             \
                        "movl %7,%%edx\n\t"             \
                       :"=m"(from->context.eax),"=m"(from->context.ebx),       \
                        "=m"(from->context.ebp),"=m"(from->context.edx):       \
                        "m"(to->context.eax),"m"(to->context.ebx),         \
                        "m"(to->context.ecx),"m"(to->context.edx) );
        printf("ok for first setction of asm code\n");
        getchar();
        asm volatile("movl %%esi,%0\n\t"        \
                     "movl %%edi,%1\n\t"        \
                        "movl %%ebp,%2\n\t"             \
                        "movl %%esp,%3\n\t"             \
                        "movl %4,%%esi\n\t"             \
                        "movl %5,%%edi\n\t"             \
                        "movl %6,%%ebp\n\t"             \
                        "movl %7,%%esp\n\t"             \
                :"=m"(from->context.esi),"=m"(from->context.edi),       \
                        "=m"(from->context.ebp),"=m"(from->context.esp):       \
                        "m"(to->context.esi),"m"(to->context.edi),         \
                        "m"(to->context.ebp),"m"(to->context.esp) );  
but when I use it,the monitor screen crashes.
I don't know why?
Could anyone point out my fault?
Thanks in advance!
-- 
Best regards,
 cool                          mailto:hust



Follow-Ups: