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

스택 프레임과 지역 변수

베이스 포인터(EBP/RBP)를 사용해 스택 프레임을 설정하고 해제하며, 프로시저 내부에서 지역 변수를 할당하고 매개변수에 안정적으로 접근하는 방법을 배웁니다.

스택 프레임과 지역 변수은(는) 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개의 강의가 포함되어 있습니다.

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

Why Stack Frames?

A procedure needs space for its own local variables and a stable way to find its parameters. A stack frame gives each call its own private region of the stack.

The Base Pointer

The base pointer (EBP in 32-bit, RBP in 64-bit) provides a fixed reference into the frame, while ESP keeps moving as you push and pop.

The Prologue

A procedure begins by saving the old base pointer and setting up a new frame.

push ebp
mov ebp, esp

Allocating Locals

Reserve space for locals by subtracting from the stack pointer. The locals then live at negative offsets from EBP.

sub esp, 8       ; room for two 4-byte locals

Accessing Locals

Reference each local by a fixed offset below the base pointer.

mov dword [ebp-4], 10   ; first local = 10

Accessing Parameters

With the classic cdecl layout, parameters sit above the saved EBP and return address, at positive offsets.

mov eax, [ebp+8]        ; first argument

The Epilogue

Before returning, restore the stack and base pointer so the caller frame is intact.

mov esp, ebp
pop ebp
ret

The LEAVE Shortcut

The LEAVE instruction performs mov esp, ebp then pop ebp in one step, a compact epilogue.

leave
ret

Frame Layout Map

From high to low addresses in a typical frame:

  • Parameters [ebp+8], [ebp+12]
  • Return address [ebp+4]
  • Saved EBP [ebp]
  • Locals [ebp-4], [ebp-8]

Why Save EBP?

Each call saves the callers EBP so nested calls can each have a valid frame and the chain can be unwound, which debuggers use to print stack traces.

Frame Pointer Omission

Optimizing compilers may skip EBP setup to free a register, addressing locals relative to ESP instead. This is faster but harder to debug.

Quick Check

Test your understanding of stack frames.

Recap

You learned stack frames:

  • Prologue: push ebp, mov ebp, esp
  • Reserve locals with sub esp, access at [ebp-N]
  • Parameters at [ebp+N]
  • Epilogue restores frame; LEAVE is the shortcut

자주 묻는 질문

“스택 프레임과 지역 변수” 강의는 무료인가요?

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

“스택 프레임과 지역 변수”에서 뭘 배우나요?

베이스 포인터(EBP/RBP)를 사용해 스택 프레임을 설정하고 해제하며, 프로시저 내부에서 지역 변수를 할당하고 매개변수에 안정적으로 접근하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 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번째 강의입니다.

“스택 프레임과 지역 변수” 강의는 얼마나 걸리나요?

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

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

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

이 강의의 모든 강의

  1. 호출 스택 기초
  2. 프로시저 정의와 호출
  3. 인수와 반환 값 전달
  4. 스택 프레임과 지역 변수
← Assembly Language & x86 Low-Level Systems Programming(으)로 돌아가기