Segmentation

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 |

| Software Engineering Undergraduate| University Of Kelaniya | Sri Lankan|