惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
U
Unit 42
罗磊的独立博客
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
博客园 - 【当耐特】
H
Help Net Security
The GitHub Blog
The GitHub Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Some basic understanding of function calls
E_Chronosands:: · 2026-05-12 · via DEV Community

Functions are a very important concept in program design. They can encapsulate relatively independent logic into a simple call, increasing the reusability of the logic. From a usage perspective, functions emphasize input and output; they accept parameters, perform a specific process, and then output the result.

A function is a type of subprogram, and it is also a type of callable unit. A programmer can write a function in source code that is compiled to machine code that implements similar semantics

Function calls are primarily accomplished using a stack data structure. In summary, It saves the current execution context by pushing onto the stack, then jumps to another piece of code to execute, and then pops the stack back to the previous context after execution is complete. And the structure used to save the current state is usually called a stack frame.

The structure used to save the current state is usually called a stack frame. From the perspective of high-level programming languages, it can be compared to a structure. However, in the underlying implementation using assembly language, it may simply use registers to record the top and bottom of the stack.

The CPU has no concept of functions, methods, classes, objects. The CPU only recognizes: instruction addresses, registers, memory, jumps, When you call an add function in a main function, for example:

int add(int a, int b) {
  // xxxx
}

int main() {
  add(1, 4);
  return 0;
}

The underlying assembly might look like this (x86–64):

"add(int, int)":
        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], edi
        mov     DWORD PTR [rbp-8], esi
        mov     edx, DWORD PTR [rbp-4]
        mov     eax, DWORD PTR [rbp-8]
        add     eax, edx
        pop     rbp
        ret
"main":
        push    rbp
        mov     rbp, rsp
        mov     esi, 5
        mov     edi, 1
        call    "add(int, int)"
        mov     eax, 0
        pop     rbp
        ret

The two crucial statements at the beginning of each function: push rbp and mov rbp, rsp, are used to create stack frames. (The purpose of push rbp is to restore the rbp register to its value before the call ends)

rbp and rsp are two commonly used register names.
rbp -> bottom of the current function stack
rsp -> top of the current stack

The call add(int, int) statement then performs two operations: saves the return address (next instruction address) and jumps to the new function to run:

And then it may also save some local variables and other information:

Next, some operations are performed using registers, and the results are saved to the eax register (this register is usually used to store the return value). Then, pop rbp restores the rbp register to its state before this function was called.

Finally, the ret statement corresponds to the call statement, and it also does two things: its function is to retrieve the return address from the top of the stack and jump back to main function. This concludes the call to the add function. Then execution will continue from the line mov eax, 0 in the main function.

Of course, please also note that the so-called popping of a stack frame may not actually clear old data for performance reasons; it may only change the state of registers.

Furthermore, with the advancement of modern compilers, many unnecessary steps are omitted, so the actual implementation may be even more streamlined and difficult to understand.

A more technical description of this process is that it involves temporarily transferring enforcement power and then restoring it.