5.1.3 · D3 · HinglishInstruction Set Architecture (ISA)

Worked examplesAddressing modes

3,044 words14 min read↑ Read in English

5.1.3 · D3 · Hardware › Instruction Set Architecture (ISA) › Addressing modes

Yeh ek Deep Dive child hai 5.1.3 Addressing modes ka. Parent ne tumhe ke formulas diye the. Yahan hum unhe exhaust karte hain — har mode, har degenerate case, har trap jo exam set kar sakta hai. Agar koi scenario exist karta hai, toh woh neeche ki matrix mein hai aur uska ek fully worked example bhi hai.

Shuru karne se pehle, paanch plain-word reminders (hum koi bhi symbol tab tak use nahi karenge jab tak hum use re-earn na kar lein):


Scenario matrix

Neeche ke har worked example ko us cell ke saath tag kiya gaya hai jise woh cover karta hai. Goal: koi bhi reader kisi aisi case se na mile jise humne skip kiya ho.

Cell Isko tricky kya banata hai Covered by
C1 — zero memory access operand kabhi memory touch nahi karta (immediate / register) Ex 1
C2 — the "how many trips?" axis direct (1) vs indirect (2) vs register-indirect (1) Ex 2
C3 — sign of the displacement can be negative (backward offset) Ex 3
C4 — degenerate / zero inputs , ya — kya rules phir bhi hold karte hain? Ex 4
C5 — scaled indexing (arrays of wide elements) element size byte Ex 5
C6 — PC-relative, both directions forward branch aur backward loop Ex 6
C7 — auto-increment / decrement ordering access ke relative kab change hota hai? Ex 7
C8 — the stack (real-world word problem) push/pop as auto-dec/auto-inc Ex 8
C9 — exam twist: same bits, four modes ek instruction word chaar tarike se decode kiya Ex 9
C10 — limiting behaviour / wrap-around address space se exceed kar jaata hai Ex 10

Shared machine state sabhi examples ke liye (yeh street yaad kar lo):

Address Contents Register Contents
100 500 R1 400
200 108 R2 3
400 700 R3 408
403 900 Rz 0
404 111 PC 200
408 222 SP 600
500 800 Rb 596
596 42
600 55
608 333

Worked examples

Ex 1 — C1: woh operand jo instruction se bahar nahi jaata


Ex 2 — C2: "how many trips?" axis, teen modes, same


Ex 3 — C3: ek negative displacement (backward offset)


Ex 4 — C4: degenerate / zero inputs


Ex 5 — C5: wide elements ki array ke liye scaled indexing


Ex 6 — C6: PC-relative dono directions mein


Ex 7 — C7: auto-increment vs auto-decrement ordering


Ex 8 — C8: stack — ek real-world word problem


Ex 9 — C9: exam twist — ek instruction word, chaar modes


Ex 10 — C10: limiting behaviour — address wrap-around


Recall

Recall Humne kaun si cells cover kiin?

Sab dus: zero-access (Ex1), trip-count axis (Ex2), negative displacement (Ex3), zero/degenerate collapse (Ex4), scaled index (Ex5), PC-relative dono taraf (Ex6), inc/dec ordering (Ex7), stack (Ex8), one-word-four-modes (Ex9), wrap-around (Ex10). Har ek formula tha; har operand ko ek trip count ki zaroorat thi. Un do habits ko master karo.

Recall Quick self-test

LOAD (100) with M[100]=500, M[500]=800 — operand aur trips? ::: operand 800, 2 memory trips (indirect). LOAD 0(R1) with (R1)=400 — yeh kis mode mein degenerate hota hai? ::: register-indirect; EA=400, operand M[400]=700. Scaled arr[3], base 596, element size 4 — EA aur operand? ::: EA = 596 + 3×4 = 608, operand M[608]=333. Push onto a downward stack, SP=600 — kaun sa auto-mode aur new SP? ::: pre-decrement -(SP); SP becomes 599. LOAD 6(Rw), (Rw)=5, 3-bit address space — EA? ::: 11 mod 8 = 3.

"Kitne modes offer bhi karein?" ke peeche ka RISC-vs-CISC tension RISC vs CISC mein hai.