5.1.12 · D3 · HinglishInstruction Set Architecture (ISA)

Worked examplesInstruction-level semantics and exceptions

3,668 words17 min read↑ Read in English

5.1.12 · D3 · Hardware › Instruction Set Architecture (ISA) › Instruction-level semantics and exceptions


Pehle, woh words jo hum poore page mein use karte hain: commit aur retire

Kisi bhi example se pehle, hume ek idea define karna zaroori hai jiska parent note ne sirf ishara kiya tha, kyunki har "which PC?" ka jawab chhupe taur par isi par depend karta hai.

Figure — Instruction-level semantics and exceptions

Do model conventions jo hum pehle se fix karte hain taaki baad mein kuch bhi ambiguous na ho:


Scenario matrix

Yeh us case-classes ka poora grid hai jo yeh topic aap par throw kar sakta hai. Iske baad wali figure wohi grid hai jo ek coloured map ki tarah draw ki gayi hai, taaki aap ek nazar mein dekh sako ki nau cases space of behaviours ko kaise partition karte hain (ek axis par return-PC rule se, doosri par cause se).

# Case class Distinguishing question Covered by
A Fault on a memory access Return to same instruction Ex 1
B Trap (deliberate) Return to next instruction Ex 2
C Abort (unrecoverable) Koi return nahi Ex 3
D Zero / degenerate input (÷0) Fault data se trigger hoti hai, address se nahi Ex 4
E Tie-break — do faults same cycle mein Program-order-oldest report karo Ex 5
F Asynchronous interrupt Kisi ek instruction se tied nahi; ise kahan insert karein Ex 6
G Speculative / squashed instruction faults Ek fault jo throw away honi chahiye Ex 7
H Word problem (real syscall trace) Kaafi saare rules ko chain karke joodo Ex 8
I Exam twist — branch delay / limiting PC Kaun sa PC jab faulting instr bhi PC change kare? Ex 9
Figure — Instruction-level semantics and exceptions

Do ideas har cell mein repeat hoti hain, toh inhe abhi pin karo:

Recall Woh ek number jo sab decide karta hai: return PC

Handler Exception PC (EPC) mein kaun sa PC save karta hai? Fault ::: faulting instruction ki address khud (use retry karo) Trap ::: next instruction ki address (hum kaam kar chuke hain) Abort ::: koi return nahi — program kill ho jaata hai Interrupt ::: next instruction ki address jo abhi tak committed nahi hui (jahan pause kiya tha wahan resume karo)

Ek fixed-length ISA assume karo: har instruction 4 bytes ki hai, toh "next instruction" ka matlab hai "current address " jab tak branch kuch aur na kahe.


Ex 1 — Cell A · Load par Fault

Neeche wali figure is fault ko ek trap ke saath same picture par place karti hai taaki EPC arithmetic visual ho.

Figure — Instruction-level semantics and exceptions

Ex 2 — Cell B · Trap (deliberate)


Ex 3 — Cell C · Abort (koi return nahi)


Ex 4 — Cell D · Zero / degenerate input (÷0)


Ex 5 — Cell E · Do faults, same cycle (tie-break)

Figure — Instruction-level semantics and exceptions

Ex 6 — Cell F · Asynchronous interrupt (masking & priority ke saath)


Ex 7 — Cell G · Speculative instruction jo fault karti hai, phir squash ho jaati hai

Figure — Instruction-level semantics and exceptions

Ex 8 — Cell H · Word problem (chained rules, real trace)


Ex 9 — Cell I · Exam twist: faulting instruction khud ek branch hai

Figure — Instruction-level semantics and exceptions

Wrap-up recall

Recall Ek question se poora matrix reconstruct karo

"Kya instruction committed hui, aur kya woh khatam karna chahti thi?" Fault (committed nahi, retry karna zaroori) → EPC ::: faulting instruction ki address Trap (apna kaam committed kiya) → EPC ::: next instruction ki address Abort (uncorrectable) → EPC ::: koi nahi; process killed Interrupt (external, cleanly paused, maskable) → EPC ::: next uncommitted instruction Squashed speculative fault → reported? ::: kabhi nahi — yeh committed hi nahi hua Do faults same cycle → kaun sa report karein? ::: program-order-oldest wala Interrupt + exception same cycle → kaun jeeega? ::: synchronous exception (interrupt pending rehta hai)

Parent topic par wापas jaao · yeh poora page hardware–software contract ka practical face hai.