Skip to content
Proyek

acodercat/function-calls-under-the-hood

Lihat di GitHub

Tentang

What happens when you call a function? A visual guide to understanding stack frames, control transfer, and function call mechanics through assembly language.

Pembelajaran dan pendidikan

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
0
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Function Calls Under the Hood

What happens when you call a function?

A visual guide to function call principles through assembly language.

English | 中文

Stack Frame Diagram


About This Guide

This visual guide explains how function calls work at the low level, using detailed diagrams to illustrate the complete stack evolution during function execution. Through hands-on examples on the x86-64 platform, you'll gain a solid understanding of how C code translates to assembly instructions. The guide concludes with practical examples demonstrating interesting stack frame behaviors.

What You Will Learn

  • How control transfers between functions
  • How data is passed between functions
  • How stack frames are created and destroyed
  • The dangers of array out-of-bounds access in C/C++
  • Why inline functions are more efficient
  • Why loops are preferred over recursion
  • Why static variables persist after function returns
  • What stack overflow attacks are and how they work

Table of Contents

  1. Prerequisites
  2. The Stack in Memory
  3. Control Transfer
  4. Data Passing
  5. Register Saving and Restoring
  6. Storage of Local Variables
  7. Function Stack Frame
  8. C Function Stack Frame Example
  9. Stack Frame Memory Reuse
  10. Manually Modifying Stack Frame Data
  11. Summary

References

Acknowledgments

All diagrams were created with Excalidraw.

Translation assisted by Claude (Anthropic).

License

MIT

Jelajahi proyek terkait

Memuat…