.global asm_usermode .extern userfunc # pass address to func to exec (TODO) asm_usermode: // 0x23 is user data segment (|2 low bits) // 0x1b is user code segment (|2 low bits) // set segment registers mov $0x23, %ax mov %ax, %ds mov %ax, %es mov %ax, %fs mov %ax, %gs // ss is handled by iret mov %esp, %eax pushl $0x23 // user data segment pushl %eax // current stack pushf // // http://x86.renejeschke.de/html/file_module_x86_id_145.html //mov $0x200, %eax //push %eax // eflags image pushl $0x1B // return code segment selector push $userfunc // return instruction pointer iret jmp . // will never be reached?