My Operating system Development Experience and understanding -Part 09

User mode

Setting Up For User Mode

Entering User Mode

[esp + 16]  ss     ;the stack segment selector we want for user mode
[esp + 12] esp ;the user mode stack pointer
[esp + 8] eflags ;the control flags we want to use in user mode
[esp + 4] cs ;the code segment selector
[esp + 0] eip ;the instruction pointer of user mode code to execute
USER_MODE_CODE_SEGMENT_SELECTOR equ 0x18
USER_MODE_DATA_SEGMENT_SELECTOR equ 0x20
mov cs, USER_MODE_CODE_SEGMENT_SELECTOR | 0x3
mov ss, USER_MODE_DATA_SEGMENT_SELECTOR | 0x3

Creating User Mode Programs in C

-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -   nostartfiles -nodefaultlibs
-T link.ld -melf_i386  # emulate 32 bits ELF, the binary output is specified              # in the linker script

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store