Instruction Set Architecture (ISA)

الفصل السادس: تصميم التعليمات وأنماط العنونة

الهدف: فهم Endianness، أنواع المعالجات (Stack/Accumulator/GPR)، وأنماط العنونة.
1

Byte Ordering (Endianness)

كيف نخزن الرقم السداسي عشر 0x12345678 في الذاكرة؟

Big Endian (الأكثر أهمية أولاً)

MSB at Lowest Address (مثل قراءتنا الطبيعية)

Addr 00
12
Addr 01
34
Addr 02
56
Addr 03
78

Little Endian (الأقل أهمية أولاً)

LSB at Lowest Address (معكوسة)

Addr 00
78
Addr 01
56
Addr 02
34
Addr 03
12
2

Architecture Types

0-Operand

Stack Architecture

العمليات تتم ضمنياً في الـ Stack.

  • PUSH X
  • PUSH Y
  • ADD (Implicit pop X, Y)
  • POP Z

Postfix: XY+

1-Operand

Accumulator (AC)

أحد المعاملات دائماً في الـ AC.

  • LOAD X
  • ADD Y (AC = AC + Y)
  • STORE Z

MARIE Example

2/3-Operand

GPR (Register)

الأكثر شيوعاً (Intel/MIPS).

  • LOAD R1, X
  • LOAD R2, Y
  • ADD R3, R1, R2

Flexible & Fast

3

Addressing Modes (أنماط العنونة)

مثال الاختبار الشهير: التعليمة هي LOAD 800. ماذا سيتم تحميله في الـ AC؟

Registers
R1 = 0x800
PC = ...
Memory
Mem[800] = 900
Mem[900] = 1000
Mem[1000] = 500
Mem[1600] = 700
Mode Logic (How it works) Value Loaded
Immediate Operand IS the data. 800
Direct Operand is the address (Mem[800]). 900
Indirect Pointer: Mem[Mem[800]] -> Mem[900]. 1000
Indexed Mem[Operand + R1] -> Mem[800+800]. 700
4

Instruction Pipelining

تقسيم تنفيذ التعليمة إلى مراحل لزيادة الـ Throughput.

Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Fetch
Decode
Exec
Store
Fetch
Decode
Exec
Store
Fetch
Decode
Exec
Store

لاحظ كيف تعمل التعليمات بشكل متوازي (Parallel) في دورات مختلفة.

EXAM VAULT (خزنة الاختبار)
CALCULATION / مسألة ذكية

Expanding Opcodes

لديك تعليمة 16-بت. العنوان (Address) يأخذ 4 بتات.
إذا كان لديك 15 تعليمة من نوع 3-Address، كم يتبقى لتعليمات 2-Address؟

Total Patterns (4-bit opcode) = 16
Used for 3-Addr = 15
Left = 1 pattern (1111)
This 1 pattern opens up 4 bits of the next operand
Available for 2-Addr = $1 \times 2^4 = 16$ instructions
CONVERSION / تحويل

Infix to Postfix

حول المعادلة: $(2+3) - 6/3$
1. الأقواس أولاً: $(23+) - 6/3$
2. القسمة ثانياً: $(23+) - (63/)$
3. الطرح أخيراً: $23+63/-$

→ السابق (Ch 5) الفصل التالي (Ch 7) ←