0Pricing
Reverse Engineering & Binary Analysis Basics · Lección

La pila y las convenciones de llamada

Profundice en cómo las funciones pasan argumentos, devuelven valores y gestionan el marco de pila: conocimientos que permiten leer código desensamblado.

La pila y las convenciones de llamada es una lección gratuita de Reverse Engineering & Binary Analysis Basics en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Reverse Engineering & Binary Analysis Basics, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Reverse Engineering & Binary Analysis Basics incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Beyond a Single Call

You can read basic x86/x64 instructions and follow control flow. To truly understand function calls you must know the stack and calling conventions.

These rules govern how arguments arrive and how cleanup happens.

What the Stack Is

The stack is a region of memory that grows downward (toward lower addresses). It stores return addresses, saved registers, and local variables.

  • push decrements RSP and writes
  • pop reads and increments RSP
push rax   ; rsp -= 8, [rsp] = rax
pop  rbx   ; rbx = [rsp], rsp += 8

RSP and RBP

Two registers track the stack:

  • RSP (stack pointer) points to the current top
  • RBP (base pointer) anchors the current frame

Locals are addressed relative to RBP, like [rbp-8].

The Function Prologue

Most functions begin with a prologue that sets up the frame: save the old base pointer, then point RBP at the new frame.

push rbp
mov  rbp, rsp
sub  rsp, 0x20   ; reserve 32 bytes for locals

The Function Epilogue

The epilogue reverses the prologue, restoring the caller's frame before returning.

mov rsp, rbp
pop rbp
ret

Calling Conventions

A calling convention is the contract for passing arguments and returning values.

  • Where arguments go (registers or stack)
  • Who cleans up the stack
  • Which registers must be preserved

System V AMD64 (Linux x64)

On Linux x64 the first six integer arguments go in registers: rdi, rsi, rdx, rcx, r8, r9. The return value comes back in rax.

Extra arguments spill onto the stack.

; foo(1, 2, 3)
mov edi, 1
mov esi, 2
mov edx, 3
call foo

Microsoft x64 Convention

Windows x64 uses different registers: the first four arguments go in rcx, rdx, r8, r9, and the caller reserves 32 bytes of shadow space.

Recognizing the OS tells you which mapping to apply when reading arguments.

; Windows: bar(a, b)
mov rcx, a
mov rdx, b
sub rsp, 0x28   ; shadow space + alignment
call bar

Caller-Saved vs Callee-Saved

Some registers may be clobbered by a call (caller-saved), others must be preserved (callee-saved).

Seeing a function push rbx, rbp, and r12-r15 in its prologue is a strong hint about which registers it intends to use.

Reading Arguments in Practice

When you land in a function, mapping registers to arguments lets you label them. If the code reads rdi first on Linux, that is argument one.

This is how raw disassembly becomes readable pseudocode like send(sock, buf, len).

Stack-Passed Arguments

When a function has more arguments than the convention allows in registers, the extras are pushed onto the stack by the caller. The callee reads them at positive offsets from RBP, like [rbp+0x10].

Spotting these accesses helps you recover the full argument list.

; 7th System V argument
mov rax, [rbp+0x10]

Quick Check

Under the System V AMD64 convention, which register holds the FIRST integer argument?

Recap

You can now decode function calls at the metal level:

  • Stack grows down; RSP tops it, RBP anchors the frame
  • Prologue/epilogue set up and tear down frames
  • Calling conventions map registers to arguments (System V vs Microsoft x64)

This turns opaque disassembly into recognizable function signatures.

Preguntas frecuentes

¿La lección «La pila y las convenciones de llamada» es gratis?

Sí — el texto completo de «La pila y las convenciones de llamada» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Reverse Engineering & Binary Analysis Basics, actualiza a CoddyKit PRO. El curso de Reverse Engineering & Binary Analysis Basics incluye 4 lecciones en total.

¿Qué aprenderé en «La pila y las convenciones de llamada»?

Profundice en cómo las funciones pasan argumentos, devuelven valores y gestionan el marco de pila: conocimientos que permiten leer código desensamblado. Practicas Reverse Engineering & Binary Analysis Basics con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Reverse Engineering & Binary Analysis Basics?

No se requiere experiencia previa. Reverse Engineering & Binary Analysis Basics en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «La pila y las convenciones de llamada»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Reverse Engineering & Binary Analysis Basics?

Sí. Cada lección de Reverse Engineering & Binary Analysis Basics incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Fundamentos del ensamblador x86/x64
  2. Registros y operaciones de memoria
  3. Flujo de control y llamadas a funciones
  4. La pila y las convenciones de llamada
← Volver a Reverse Engineering & Binary Analysis Basics