5.1.12 · D1 · HinglishInstruction Set Architecture (ISA)

FoundationsInstruction-level semantics and exceptions

2,242 words10 min read↑ Read in English

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

Parent note padhne se pehle tumhe ek vocabulary chahiye. Yeh page har word aur symbol build karta hai jo woh use karta hai, bilkul zero se start karke. Upar se neeche padho — har block sirf wahi words use karta hai jo uske upar already define ho chuke hain.


1. CPU as ek choti machine jo ek list padhti hai

Ek worker ko imagine karo jiske paas ek to-do list hai. List ki har line ek order hai: "yeh do cheezein add karo", "storage se yeh le aao", "line 40 par jump karo". Worker line 1 karta hai, phir line 2, phir line 3... jab tak koi line "kahin aur jump karo" nahi kehti.

Figure — Instruction-level semantics and exceptions

Woh to-do list ek program hai. Har line ek instruction hai. Yahi pura game hai: ek machine jo instructions ki list pe chalti rehti hai.


2. State — woh cheez jo machine yaad rakhti hai

Worker ke paas kuch scratch pads aur ek badi storage room hai. Yeh sab kuch hold karte hain jo machine ab "jaanti" hai.

Machine ki state chaar tarah ki cheezein se bani hoti hai. Unhe ek-ek karke milte hain.

2a. Registers

Notation R1, R2, ... bas yeh boxes name karti hai. Jab parent likhta hai ADD R1, R2, R3, iska matlab hai "box R1 mein R2 aur R3 mein jo hai unka sum daalo".

2b. Memory

2c. Program Counter (PC)

Figure — Instruction-level semantics and exceptions

2d. Flags


3. State ke do tarah: visible vs hidden

Yeh woh split hai jis par poora parent note tika hua hai.

Hidden side ke liye tumhe do aur supporting words chahiye:

  • Pipeline — ek assembly line jahan kai instructions par ek saath kaam hota hai, har ek alag stage par. Socho: factory line par cars, ek paint ho rahi hai jabki agla weld ho raha hai.
  • Speculation / out-of-order — machine ka guess karna ki branch kidhar jayegi, ya baad ka kaam pehle karna, time bachane ke liye. Socho: ek chef kal ka dish prep karta hai jabki aaj ka abhi bhi ban raha hai — lekin galat guess hone par usse phenk dene ke liye ready.

Inhe yahan master karne ki zaroorat nahi (dekho Pipelining and Hazards aur Out-of-Order Execution and the Reorder Buffer); tumhe bas yeh jaanna hai ki yeh woh gears hain jo invisible rehne chahiye.


4. Arrows padhna: notation "instruction kya karta hai" ke liye

Parent har instruction ko arrows aur function ke saath describe karta hai. Aao har symbol earn karein.

Cases brace

Branch instruction yeh use karta hai:


5. Sequential (in-order) execution


6. Exception vocabulary

Ab topic ka doosra half: kya hota hai jab ek instruction finish nahi ho sakti.

Figure — Instruction-level semantics and exceptions

Do aur distinctions jinhe parent test karta hai:

Exception ke teen families (fault / trap / abort) parent mein fully cover hain — lekin ab tumhare paas har woh word hai jinse woh bane hain.


Prerequisite map

Instruction = one to-do line

State snapshot

Registers R1 R2

Memory lockers

Program Counter PC

Flags lights

Architectural state = visible

Pipeline and speculation

Microarchitectural state = hidden

Sequential in-order model

Commit stamps in order

Precise exceptions

Vector and Handler and EPC

Instruction-level semantics and exceptions

Left par sab kuch right par ek idea ko feed karta hai: visible state ko sequential dikhao, exceptions ke through bhi.


Equipment checklist

Right side cover karo aur khud ko test karo. Agar koi bhi answer fuzzy lage, parent note se pehle woh section dobara padho.

Instruction kya hota hai?
Ek single order — CPU ke samajh ka kaam ka sabse chhota unit; to-do list ki ek line.
State kya hoti hai?
Machine abhi hold kar rahi hai, har value ka ek complete snapshot.
Architectural state ke chaar pieces batao.
Registers, memory, PC, aur status flags.
PC kya hold karta hai?
Agle instruction ka address jo run hona hai — to-do list par ungli.
PC often 4 se kyun badhta hai?
Har instruction 4 bytes lamba hota hai, isliye agla wala 4 addresses aage hota hai.
ka kya matlab hai?
Value ko place mein daalo (right ko left mein copy karo).
ko plain words mein padho.
Ek instruction run karna purane snapshot ko naye snapshot mein badal deta hai.
Architectural vs microarchitectural state?
Architectural = visible parts jinhe ISA promise karta hai (registers, PC, flags, memory); microarchitectural = hidden gears (pipeline, caches, predictors) jinhe tum rely nahi kar sakte.
Commit / retire ka kya matlab hai?
Woh moment jab instruction ka result visible architectural state mein stamp ho jata hai.
Sequential execution — mental picture?
Dominoes ek-ek karke girte hain; agla kabhi nahi girta jab tak current fully nahi gir jaata.
Exception kya hota hai?
Normal flow se ek forced jump kyunki ek instruction ko mid-execution mein koi problem mili.
Handler vs vector vs EPC?
Handler = OS rescue routine; vector = woh fixed address jahan woh rehta hai; EPC = wapas kahan jaana hai uska saved PC bookmark.
Synchronous vs asynchronous?
Synchronous (exception) instruction ke kaaran hota hai aur repeat hota hai; asynchronous (interrupt) external timing se hota hai aur nahi hota.
Precise exception ko ek line mein define karo.
Visible state bilkul waise dikhti hai jaise bad instruction se theek pehle ek clean stop — uske baad kuch bhi touch nahi.

Ready ho? Ab parent note topic plain English jaise lagega. In ideas ke aage kahan jaate hain yeh dekhne ke liye, ISA as a Hardware–Software Contract, Virtual Memory and Page Faults, aur System Calls and Privilege Levels dekho.