5.1.10 · D1 · HinglishInstruction Set Architecture (ISA)

FoundationsCalling conventions and ABI

1,652 words8 min read↑ Read in English

5.1.10 · D1 · Hardware › Instruction Set Architecture (ISA) › Calling conventions and ABI

Yeh page har word, register name, aur symbol ko build karta hai jo parent note tumhare saamne fek deta hai, ek aisi reader ke liye shuru karke jisne kabhi assembly dekhi hi nahi. Neeche kuch bhi uss par depend nahi karta jo usse upar hai.


1. Register — CPU ke andar ek named box

Figure dekho: CPU left wala box hai, jisme labelled cells ki ek chhoti row hai. Bas itne hi registers hote hain. Memory right wali lambi strip hai.

Figure — Calling conventions and ABI

rax, rdi, rsp mein r ka matlab sirf hai "register, 64-bit". Baad ke letters historical hain (a = accumulator, di = destination index, sp = stack pointer). Inhe boxes ke naam samjho, bas itna hi. Poore set ke liye Registers and Register File dekho.


2. Memory aur address — lambi numbered strip

Square brackets woh sabse important notation hai jo parent note bina define kiye use karta hai:

Bina brackets ke = box ki apni value. Brackets ke saath = box ko ek arrow ki tarah follow karke memory mein jao.

Figure — Calling conventions and ABI

Reveal-test:

rsp mein jo value hai
ek number jo ek address hai (memory mein ek location)
[rsp]
us location par actually stored data

3. Stack — ek scratch region jo neeche ki taraf badhta hai

"Neeche ki taraf badhta hai" wala fact explain karta hai ki parent kyun likhta hai: jagah banana matlab neeche jaana.

Figure — Calling conventions and ABI

4. Instruction pointer aur push / pop / call / ret

(ya ::=) symbol jo parent use karta hai ka matlab sirf hai "bilkul same hi define kiya gaya hai". Toh call f ≡ push rip_next; jmp f padha jaata hai: "call instruction sirf ek push aur ek jump hai." Kuch magical nahi — yeh upar wale pieces se bana hai.


5. Arguments, return value, aur "convention" khud

Reveal-test:

?
haan — , remainder 8
?
nahi — , 16 ka multiple hai, remainder 0

Prerequisite map

Register - box in CPU

Calling convention

Memory and address

Stack grows down

Stack frame

Bracket notation - deref

rsp and rip

push pop call ret

Arg and return slots

ABI - full rulebook


Equipment checklist

Register kya hota hai?
CPU ke andar ek tiny fast named storage box, jo ek 64-bit word hold karta hai; bas kuch hi hote hain.
rsp mein kya hota hai?
Stack ke current top ka address.
[rsp+8] ka kya matlab hai?
Us address par memory contents jo (rsp mein value) + 8 hai.
x86-64 par stack kis direction mein badhta hai?
Neeche ki taraf — chhote addresses ki taraf; push rsp se subtract karta hai, pop add karta hai.
call f simple pieces mein kya karta hai?
Return address stack par push karo, phir f par jump karo (rip = f set karo).
ret kya karta hai?
Return address ko stack se rip mein pop karo, caller ko resume karo.
Arguments aur return values ko convention ki zarurat hi kyun hai?
CPU ka unka koi concept nahi hai; sirf fixed registers/slots par agreement hi "argument" aur "return value" ko meaningful banati hai.
Function entry par rsp ≡ 8 (mod 16) ka kya matlab hai?
rsp ko 16 se divide karne par remainder 8 aata hai, toh call se pehle stack 16-aligned tha aur call ne 8-byte return address push kiya.
"calling convention ⊂ ABI" mein ka kya matlab hai?
"Ka hissa hai / subset hai" — convention bade ABI rulebook ka ek chapter hai.