Build Your Own OS #4

Segmentation Process

Segmentation in x86

Accessing Memory

func:
mov eax, [esp+4]
mov ebx, [eax]
add ebx, 8
mov [eax], ebx
ret
func:
mov eax, [ss:esp+4]
mov ebx, [ds:eax]
add ebx, 8
mov [ds:eax], ebx
ret

The Global Descriptor Table (GDT)

Loading the GDT

struct gdt {
unsigned int address;
unsigned short size;
} __attribute__((packed));
lgdt [eax]
Bit:     | 15                                3 | 2  | 1 0 |
Content: | offset (index) | ti | rpl |
mov ds, 0x10
mov ss, 0x10
mov es, 0x10
.
.
.
; code here uses the previous cs
jmp 0x08:flush_cs ; specify cs when jumping to flush_cs flush_cs:
; now we've changed cs to 0x08

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My journey through TCS Digital

Building Android Landmark App with AWS Amplify, Google Sign-In with GraphQL

I left the web form and switched to Razor Pages.

Variables in Golang

Software Automation : A to Z : Unit 1

GameRank — CIM413 Midterm

Kryptonetikz_v.1_24/3/21

My IT Journey

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
Niroshan Pushparaj

Niroshan Pushparaj

More from Medium

Automating Cisco IOS updates with Unimus — Part 1

Challenges Discovered in Migration of Application to Another Platform

Blibli Future Program Batch 5 — Data Track: Project 2

CS373 Spring 2022: Yifan Zhou, Week 2