5.1.2 · D3 · HinglishInstruction Set Architecture (ISA)

Worked examplesInstruction formats and encoding

3,700 words17 min read↑ Read in English

5.1.2 · D3 · Hardware › Instruction Set Architecture (ISA) › Instruction formats and encoding

Shuru karne se pehle, teen words ko plain language mein dobara anchor karte hain jis par puri page tiki hai:

Do prerequisites jin par hum depend karte hain aur inhe kahan revise karein: Registers and the Register File (kyun ek register number sirf ek chota integer hai) aur Two's Complement and Sign Extension (bits mein negative numbers kaise rehte hain).


Scenario matrix

Har encoding question jo tum kabhi bhi dekhoge woh in cells mein se ek hogi. Neeche ke worked examples us cell ke saath tagged hain jo woh cover karte hain, aur milke woh saari cells hit karte hain.

# Cell (case class) Tricky kyun hai Example
A Simple positive R-type bas registers pack karo Ex 1
B Positive immediate (I-type) immediate ek block mein hota hai Ex 2
C Negative immediate top bit = sign, sign-extend karna zaroori Ex 3
D Zero / degenerate input register 0, immediate 0 Ex 4
E Maximum / limiting value ek field mein sabse bada immediate Ex 5
F Split immediate (S-type) bits do holes mein bikhar jaate hain Ex 6
G Reordered + scaled (B-type) immediate 2 bytes ke units mein Ex 7
H Decode direction (bits → meaning) poora process reverse karo Ex 8
I Field-width word problem requirements se bit counts choose karo Ex 9
J Exam twist (opcode-budget trap) zyada opcode ≠ zyada room Ex 10

R-type field order jo hum baar baar use karenge (parent note se) woh "phone number" 7-5-5-3-5-7 hai — neeche diye figure mein picture dekho; math line sirf unhi fences ko naam deti hai:

Figure — Instruction formats and encoding

Worked examples

Cell A — simple positive R-type


Cell B — positive immediate (I-type)


Cell C — negative immediate (sign-extension case)

Figure — Instruction formats and encoding

Cell D — zero / degenerate input


Cell E — maximum / limiting value


Cell F — split immediate (S-type store)

Neeche wala figure dekho. Top row plain 12-bit value 12 dikhata hai; coloured arrows uske do slices ko S-type template mein le jaate hain. Notice karo ki green slice () aur orange slice () non-adjacent holes mein jaate hain, jabki rs1 aur rs2 (blue) exactly wahin rehte hain jahan R-type ne unhe rakha tha — woh unchanged register wiring hi poore split ki wajah hai.

Figure — Instruction formats and encoding

Cell G — reordered + scaled (B-type branch)


Cell H — decode direction (bits → meaning)


Cell I — field-width word problem


Cell J — exam twist (opcode-budget trap)


Recall Poore matrix par quick self-test

Kaun si cell mein stored value ko use karne se pehle 2 se multiply kiya jaata hai? ::: Cell G (B-type branch, 2 bytes se scaled). S-type apna immediate split kyun karta hai? ::: Taaki rs1 aur rs2 apni normal positions par rahein aur register-read wiring kabhi na bade. 12-bit signed immediate ki sabse badi value? ::: ; sabse choti hai. B-type immediate ka sign bit kaun sa hai? ::: , top bit, word ke bilkul top par place hota hai taaki ek sign-extend wire sabhi formats ko serve kare. add x0,x0,x0 encode karo — kya word all zeros hai? ::: Nahi — opcode bits 0110011 abhi bhi set hain (0x00000033). Decoder pehle kaun sa field padhta hai? ::: Opcode, lowest 7 bits mein.


Yeh bhi dekho: Addressing Modes (immediate kaise memory address banta hai) aur Pipelining (kyun fixed-width fields decode ko itna fast banate hain ki overlap ho sake).