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

Aufrufkonventionen: cdecl, stdcall und System V

Vergleichen Sie die wichtigsten x86-Aufrufkonventionen, damit Ihre Assembly- und C-Codes übereinstimmen, wo Argumente übergeben werden, wer den Stack bereinigt und welche Register erhalten bleiben.

Aufrufkonventionen: cdecl, stdcall und System V ist eine kostenlose Assembly Language & x86 Low-Level Systems Programming-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Assembly Language & x86 Low-Level Systems Programming-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Assembly Language & x86 Low-Level Systems Programming-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Conventions Matter

For assembly and C to interoperate, both sides must agree on a calling convention: how arguments are passed, who cleans the stack, and which registers must be preserved.

Argument Passing

Conventions differ on where arguments go: on the stack, in registers, or a mix. Getting this wrong corrupts data silently.

cdecl

cdecl (32-bit, the C default) pushes arguments on the stack right to left, and the caller cleans them up after the call.

push arg2
push arg1
call func
add esp, 8     ; caller cleans

stdcall

stdcall also passes on the stack right to left, but the callee cleans the stack via ret n. The Win32 API uses it.

ret 8          ; callee cleans 8 bytes

Caller vs Callee Cleanup

The key contrast:

  • cdecl: caller cleans, supports variadic functions
  • stdcall: callee cleans, smaller call sites

System V AMD64

The 64-bit Linux/macOS convention passes the first six integer args in registers: RDI, RSI, RDX, RCX, R8, R9; extras go on the stack.

mov rdi, arg1
mov rsi, arg2
call func

Microsoft x64

64-bit Windows uses a different register set: RCX, RDX, R8, R9 for the first four args, plus 32 bytes of shadow space.

Return Values

Integer and pointer results come back in EAX (32-bit) or RAX (64-bit); floating point uses XMM0 in 64-bit conventions.

Preserved vs Scratch Registers

Each convention designates callee-saved registers (the callee must restore them) and caller-saved ones (free to clobber). Violating this corrupts the caller.

Stack Alignment

System V requires the stack to be 16-byte aligned at a call. Forgetting this crashes code that uses SSE instructions.

Matching the Compiler

Always declare functions on the C side with the matching convention attribute (e.g. __stdcall) so both halves agree.

Quick Check

Test your understanding of calling conventions.

Recap

You learned calling conventions:

  • cdecl: stack args, caller cleans, supports varargs
  • stdcall: stack args, callee cleans
  • System V x64: args in RDI,RSI,RDX,RCX,R8,R9
  • Return in EAX/RAX; respect callee-saved registers and alignment

Häufig gestellte Fragen

Ist die Lektion „Aufrufkonventionen: cdecl, stdcall und System V“ kostenlos?

Ja — der vollständige Text von „Aufrufkonventionen: cdecl, stdcall und System V“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Assembly Language & x86 Low-Level Systems Programming-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Assembly Language & x86 Low-Level Systems Programming-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Aufrufkonventionen: cdecl, stdcall und System V“?

Vergleichen Sie die wichtigsten x86-Aufrufkonventionen, damit Ihre Assembly- und C-Codes übereinstimmen, wo Argumente übergeben werden, wer den Stack bereinigt und welche Register erhalten bleiben. Du übst Assembly Language & x86 Low-Level Systems Programming mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Assembly Language & x86 Low-Level Systems Programming zu starten?

Keine Vorkenntnisse erforderlich. Assembly Language & x86 Low-Level Systems Programming auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Aufrufkonventionen: cdecl, stdcall und System V“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Assembly Language & x86 Low-Level Systems Programming-Lektion Code schreiben und ausführen?

Ja. Jede Assembly Language & x86 Low-Level Systems Programming-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Assembler aus C aufrufen
  2. C aus Assembler aufrufen
  3. Techniken der Programmierung in mehreren Sprachen
  4. Aufrufkonventionen: cdecl, stdcall und System V
← Zurück zu Assembly Language & x86 Low-Level Systems Programming