Assembly Language & x86 Low-Level Systems Programming · 강의

세그먼테이션과 전역 디스크립터 테이블(GDT)

페이징과 함께 작동하는 x86 세그먼테이션을 배웁니다. 세그먼트 선택자, 디스크립터, GDT와 평면 메모리 모델이 보호 모드의 기반을 마련하는 방식을 다룹니다.

레슨 4/413개 단계

세그먼테이션과 전역 디스크립터 테이블(GDT)은(는) CoddyKit의 무료 Assembly Language & x86 Low-Level Systems Programming 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Assembly Language & x86 Low-Level Systems Programming 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Assembly Language & x86 Low-Level Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What Is Segmentation?

Segmentation divides memory into variable-sized regions called segments, each with a base address, limit, and access rights. It predates paging and is the first translation step in x86 address generation.

Real Mode Segments

In 16-bit real mode, a physical address is computed as segment * 16 + offset. This gave access to 1 MB using 16-bit registers but offered no protection at all.

Protected Mode Selectors

In protected mode a segment register no longer holds a base directly. It holds a selector — an index into a descriptor table plus a privilege level and table indicator bit.

The Segment Descriptor

Each descriptor is 8 bytes and encodes:

  • Base (32-bit start address)
  • Limit (size of the segment)
  • Type (code, data, system)
  • DPL (descriptor privilege level 0-3)
  • Flags (granularity, default size)

The Global Descriptor Table

The GDT is an array of these descriptors in memory. The CPU finds it through the GDTR register, which holds the table base and limit. Entry 0 is always the null descriptor.

Loading the GDT

You point the CPU at your GDT with the lgdt instruction, which reads a 6-byte pseudo-descriptor (limit + base).

gdt_descriptor:
    dw gdt_end - gdt_start - 1   ; limit
    dd gdt_start                 ; base

lgdt [gdt_descriptor]            ; load GDTR

Defining a Flat Code Segment

Modern OSes use a flat model: base 0 and a 4 GB limit, so segmentation becomes a no-op and paging does the real work. Here is a typical code descriptor.

gdt_code:
    dw 0xFFFF      ; limit low
    dw 0x0000      ; base low
    db 0x00        ; base mid
    db 10011010b   ; present, ring 0, code, readable
    db 11001111b   ; granularity 4K, 32-bit, limit high
    db 0x00        ; base high

Activating Protected Mode

You enter protected mode by setting bit 0 (PE) of control register CR0, then performing a far jump to flush the prefetch queue and load CS with a protected-mode selector.

mov eax, cr0
or eax, 1          ; set PE bit
mov cr0, eax
jmp 0x08:pmode     ; far jump, 0x08 = code selector

Selectors in Practice

A selector like 0x08 breaks down as: index 1 (byte offset 8 / 8), table indicator 0 (GDT), requested privilege level 0. After the jump, data segment registers are loaded with the data selector (often 0x10).

Segmentation vs Paging Today

In long (64-bit) mode segmentation is largely disabled: base and limit are ignored for most segments. Protection and translation are handled by paging. Segmentation survives mainly for FS/GS base pointers used for thread-local storage.

Why It Still Matters

Even though the flat model neutralizes segmentation, every protected-mode and long-mode OS must set up a valid GDT to boot. Understanding selectors and descriptors is essential for kernel bring-up and exception handling.

Quick Check

Test your segmentation knowledge.

Recap

You learned x86 segmentation:

  • A selector indexes a descriptor in the GDT
  • Descriptors hold base, limit, type, and privilege level
  • lgdt loads the table; setting CR0.PE plus a far jump enters protected mode
  • The flat model neutralizes segmentation so paging does the work
무료로 시작

AI 튜터와 함께 Assembly을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
12
레슨
48

자주 묻는 질문

“세그먼테이션과 전역 디스크립터 테이블(GDT)” 강의는 무료인가요?

네 — “세그먼테이션과 전역 디스크립터 테이블(GDT)” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Assembly Language & x86 Low-Level Systems Programming 강의 전체를 잠금 해제할 수 있습니다. Assembly Language & x86 Low-Level Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.

“세그먼테이션과 전역 디스크립터 테이블(GDT)”에서 뭘 배우나요?

페이징과 함께 작동하는 x86 세그먼테이션을 배웁니다. 세그먼트 선택자, 디스크립터, GDT와 평면 메모리 모델이 보호 모드의 기반을 마련하는 방식을 다룹니다. 브라우저에서 직접 실행하는 실습 코드로 Assembly Language & x86 Low-Level Systems Programming을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Assembly Language & x86 Low-Level Systems Programming을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Assembly Language & x86 Low-Level Systems Programming은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“세그먼테이션과 전역 디스크립터 테이블(GDT)” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Assembly Language & x86 Low-Level Systems Programming 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Assembly Language & x86 Low-Level Systems Programming 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 페이징과 메모리 관리 장치(MMU)
  2. 보호 링과 권한
  3. 하이퍼바이저와 가상화 기초
  4. 세그먼테이션과 전역 디스크립터 테이블(GDT)
← Assembly Language & x86 Low-Level Systems Programming(으)로 돌아가기