5.1.5 · D3 · HinglishInstruction Set Architecture (ISA)

Worked examplesx86 architecture overview

3,396 words15 min read↑ Read in English

5.1.5 · D3 · Hardware › Instruction Set Architecture (ISA) › x86 architecture overview

Do prerequisite ideas jinpe hum rely karte hain, dono neeche scratch se build ki gayi hain taaki koi symbol unfamiliar na lage:

  • Ek hex digit mein se ek hai — solah values, yaani exactly 4 bits (kyunki ). Yehi wajah hai ki x86 ko hex pasand hai: ek hex digit = ek nibble = 4 wires.
  • Shift-left-by- jo likha jaata hai, matlab hai "x ki binary form ke right end mein zero-bits jod do," jo value ko se multiply karta hai. Toh matlab hai, yaani "ek hex zero append karo."

Neeche do plain math shorthand use hote hain — yeh unka matlab hai taaki koi symbol surprise na kare:

  • (ek interval) shorthand hai "har value se tak, endpoints shamil." Toh ka matlab sirf hai.
  • (modulo) matlab hai " mein se ke poore copies nikaalke jo remainder bachta hai" — yaani jab , size ke ek wheel par wrap around kar chuka ho tab kya bachta hai. Example ke liye kyunki yeh exactly ek baar wrap karke start pe aa jaata hai.

Scenario matrix

Is topic ki har cheez inhi cells mein se ek hai. Neeche har worked example us cell ke saath tagged hai jo woh cover karta hai, taaki end tak koi cell unseen na rahe.

# Case class Isme kya special hai Example
A Address: ordinary case segment & offset dono nonzero, koi wrap nahi Ex 1
B Address: zero degenerate offset , ya segment Ex 2
C Address: overlap / aliasing do alag (seg, off) pairs → same byte Ex 3
D Address: wrap-around / limit sum 20 bits se zyada ( 1 MB) Ex 4
E Register: ordinary window read RAX mein se EAX/AX/AL/AH nikaalana Ex 5
F Register: partial-write trap EAX likhne se upper 32 zero ho jaate hain; AL/AH/AX/RAX writes alag behave karti hain Ex 6
G Word problem (real world) "kya yeh .COM file fit hogi?" Ex 7
H Exam twist instruction-length reasoning + ek "gotcha" address Ex 8

Neeche, 0x prefix wale saare numbers hexadecimal (base 16) hain; baaki sab decimal hain.


Cell A — ordinary address

Neeche ki figure literally assembly dikhati hai: dekho yellow box ek trailing 0 kaise gain karta hai (woh hai), phir green offset low nibbles mein kaise aata hai, aur red result 0x2F140 milta hai.

Figure — x86 architecture overview

Cell B — zero degenerate


Cell C — overlap / aliasing (fossil ki sabse weird bug)

Neeche ki figure single red target byte 0x12345 ko ek physical number line par plot karti hai, blue pair (base 0x12340 se chhota +0x05 hop) aur green pair (base 0x12300 se lamba +0x45 hop) dono usi par pahunchte hain — do arrows, ek landing spot.

Figure — x86 architecture overview

Cell D — wrap-around / 1 MB limit


Cell E — ordinary register window

Neeche ki figure RAX ke 16 hex digits stack karti hai aur right se har name ki window bracket karti hai: green EAX (8 digits), yellow AX (4), red AL (2), aur — low end se offset — orange AH bracket, jo vivid banata hai ki AH bottom par nahi hai.

Figure — x86 architecture overview

Cell F — partial-write trap (saare chaar widths)


Cell G — real-world word problem


Cell H — exam twist (address + instruction length saath mein)


Recall

Recall Answers
  1. e.g. segment 0x30A0 - 1 = 0x309F, offset 0x0008 + 0x10 = 0x00180x309F:0x0018 (dono 0x309A8 dete hain).
  2. 0xFFFF0 + 0x11 = 0x100001 → wraps to 0x00001.
  3. mov eax, 1 zero-extends → 0x0000000000000001; mov ah, 2 byte 1 merge karta hai → 0x0000000000000201; mov al, 3 byte 0 merge karta hai → 0x0000000000000203.
  4. 0x10000 = 65536 bytes.

Cross-links: Instruction Set Architecture (ISA) · Registers and the Register File · Fetch-Decode-Execute Cycle · ARM Architecture · parent x86 overview.