diff options
| author | Michal Idziorek <m.i@gmx.at> | 2015-05-16 03:48:35 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2015-05-16 03:48:35 +0200 |
| commit | f92a23a2fcee6cbb97af9c7681e6872374d3c789 (patch) | |
| tree | 41669345c8a5a60548e8e07cf805df9ef01c1c26 /asm/usermode.s | |
| parent | ba10657752ba869b1c46c861cbda689b535e8214 (diff) | |
finally working ring 3
Diffstat (limited to 'asm/usermode.s')
| -rw-r--r-- | asm/usermode.s | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/asm/usermode.s b/asm/usermode.s new file mode 100644 index 0000000..acf4b04 --- /dev/null +++ b/asm/usermode.s @@ -0,0 +1,35 @@ +.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? + + + + |
