Çağrı Kuralları: cdecl, stdcall ve System V
Başlıca x86 çağrı kurallarını karşılaştırın; böylece assembly ve C kodunuz bağımsız değişkenlerin nereye yerleştirildiği, yığını kimin temizlediği ve hangi yazmaçların korunduğu konusunda uyumlu çalışsın.
Çağrı Kuralları: cdecl, stdcall ve System V, CoddyKit'te ücretsiz bir Assembly Language & x86 Low-Level Systems Programming dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Assembly Language & x86 Low-Level Systems Programming öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Assembly Language & x86 Low-Level Systems Programming kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
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 cleansstdcall
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 bytesCaller 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 funcMicrosoft 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
Sıkça Sorulan Sorular
“Çağrı Kuralları: cdecl, stdcall ve System V” dersi ücretsiz mi?
Evet — “Çağrı Kuralları: cdecl, stdcall ve System V” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Assembly Language & x86 Low-Level Systems Programming kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Assembly Language & x86 Low-Level Systems Programming kursu toplamda 4 dersten oluşur.
“Çağrı Kuralları: cdecl, stdcall ve System V” dersinde ne öğreneceğim?
Başlıca x86 çağrı kurallarını karşılaştırın; böylece assembly ve C kodunuz bağımsız değişkenlerin nereye yerleştirildiği, yığını kimin temizlediği ve hangi yazmaçların korunduğu konusunda uyumlu çalı… Assembly Language & x86 Low-Level Systems Programming ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Assembly Language & x86 Low-Level Systems Programming öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Assembly Language & x86 Low-Level Systems Programming, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Çağrı Kuralları: cdecl, stdcall ve System V” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Assembly Language & x86 Low-Level Systems Programming dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Assembly Language & x86 Low-Level Systems Programming dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- C'den Assembly Çağırma
- Assembly'den C Çağırma
- Birden Fazla Dille Programlama Teknikleri
- Çağrı Kuralları: cdecl, stdcall ve System V