Chapter 4 Central Processing Unit ملخص by Eng Emad Mahdy
Chapter 4 Central Processing Unit ملخص by Eng Emad Mahdy
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Chapter 4 content
8-1 Introduction
8-2 General Register Organization
▪ bus system
▪ Control Word
▪ ALU
▪ Examples
8-3 Stack Organization
▪ Register Stack Organization
▪ Memory stack organization
▪ Reverse Polish Notation
8-4 Instruction Formats
▪ Processor Organization
▪ Three, Two, One, Zero Address Instructions
▪ Three-Address Instructions
▪ Two-Address Instructions
▪ One-Address Instructions
▪ Zero-Address Instructions
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
8-1 Introduction
Registers
Storage
Components
Flags
Arithmetic
CPU
Processing
ALU Logical
Components
Transfer
BUS Shift/Rotate
Components
Control
Control Unit
Components
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
In Basic Computer, there is only one general purpose register, the Accumulator (AC) but in modern CPUs, there are many general-purpose registers.
يوجد عدد اكبر من سجالت األغراض، ولكن في المعالجات الحديثةAccumulator (AC) وهو، يوجد سجل واحد فقط لألغراض العامة، Basic Computer في ال
.العامة
It is advantageous to have many registers because Transfer between registers within the processor are relatively fast and Going “off the processor” to access memory is much slower.
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
𝐄𝐱𝐚𝐦𝐩𝐥𝐞: 𝐑𝟏 𝐑𝟐 + 𝐑𝟑
Control Word
3 3 3 5
SELA SELB SELD OPR
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Initially:
SP = 0,
EMPTY = 1,
FULL = 0
PUSH POP
𝐒𝐏 ← 𝐒𝐏 + 𝟏 𝐃𝐑 ← 𝐌[𝐒𝐏]
𝐌[𝐒𝐏] ← 𝐃𝐑 𝐒𝐏 ← 𝐒𝐏 − 𝟏
𝐈𝐟 (𝐒𝐏 = 𝟎) 𝐭𝐡𝐞𝐧 (𝐅𝐔𝐋𝐋 ← 𝟏) 𝐈𝐟 (𝐒𝐏 = 𝟎) 𝐭𝐡𝐞𝐧 (𝐄𝐌𝐏𝐓𝐘 ← 𝟏)
𝐄𝐌𝐏𝐓𝐘 ← 𝟎 𝐅𝐔𝐋𝐋 ← 𝟎
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
PUSH POP
𝐒𝐏 𝐒𝐏 − 𝟏 𝐃𝐑 𝐌[𝐒𝐏]
𝐌[𝐒𝐏] 𝐃𝐑 𝐒𝐏 𝐒𝐏 + 𝟏
❖ Most computers do not provide hardware to check stack overflow (full stack) or underflow (empty stack) → must be done in software
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Arithmetic Expressions: A + B
Infix notation 𝐀 + 𝐁
Prefix or Polish notation +𝐀𝐁
Postfix or reverse Polish notation 𝐀𝐁 +
Example:
(𝟑 ∗ 𝟒) + (𝟓 ∗ 𝟔) → 𝟑 𝟒 ∗ 𝟓 𝟔 ∗ +
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Processor organization
Any of the registers can be used as the source or Accumulator is the only general-purpose register For example, an OR instruction will pop the two top
destination for computer operations elements from the stack, do a logical OR on them, and push
the result on the stack
❖ Instruction Fields
The number of address fields in the instruction format depends on the internal organization of CPU
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
على التركيب الداخلي للمعالج instruction يعتمد عدد حقول العنوان في ال
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Addressing Modes: Specifies a rule for interpreting or modifying the address field of the instruction (before the operand is actually referenced)
Implied Mode Implied Mode: Address of the operands are specified implicitly in the
definition of the instruction No EA
AC=
• No need to specify address in the instruction
Immediate Mode No EA
Immediate Mode: Instead of specifying the address of the operand, operand
itself is specified AC=immediate filed in instruction
Register Mode No EA
Register Mode: Address specified in the instruction is the register address AC = R
• Saving instruction bits since register address is shorter than the memory address
• Slower to acquire an operand than both the register addressing or memory
addressing
Autoincrement EA=R
Autoincrement or Autodecrement Mode: When the address in the register is
Mode used to access memory, the value in the register is incremented or
AC = [R]
R=R+1
decremented by 1 automatically
The auto-decrement mode R1 is decremented before the execution of the instruction. R=R-1
Autodecrement EA=R
Mode AC = [R]
Direct Address Mode : Instruction specifies the memory address which can
Direct Address be used directly to access the memory EA= Address filed in instruction
Mode AC = [EA]
• Faster than the other memory addressing modes
• Too many bits are needed to specify the address for a large physical memory space
Addressing Mode
• When the abbreviated address is used large physical memory can be addressed with a
relatively small number of bits
• Slow to acquire an operand because of an additional memory access
Relative
Relative Addressing Mode e: The Address fields of an instruction specifies the
Addressing Modes part of the address (abbreviated address) which can be used along with a
3 different Relative Addressing Modes depending on R;
designated register to calculate the address of the operand PC Relative R = PC EA = PC + IR(address)
Addressing Mode
• Address field of the instruction is short Indexed Addressing R = IX, EA = IX + IR(address)
• Large physical memory can be accessed with a small number of address bits Mode 𝑤ℎ𝑒𝑟𝑒 𝐼𝑋: 𝐼𝑛𝑑𝑒𝑥 𝑅𝑒𝑔𝑖𝑠𝑡𝑒𝑟
Base Register R = BAR, EA = BAR + IR(address)
Addressing Mode 𝑤ℎ𝑒𝑟𝑒 𝐵𝐴𝑅: 𝐵𝑎𝑠𝑒 𝐴𝑑𝑑𝑟𝑒𝑠𝑠 𝑅𝑒𝑔𝑖𝑠𝑡𝑒𝑟
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
1. Implied Mode
R=R+1
EA= R
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
R=R+1
EA= R
ADD X I
8. Indirect Addressing Mode AC = [EA]
EA= [ 𝐀𝐝𝐝𝐫𝐞𝐬𝐬 ]
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
𝐄𝐀 = 𝐑 + 𝐀𝐝𝐝𝐫𝐞𝐬𝐬
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com
Instructions
https://www.youtube.com/@eng.emadmahdy
https://si-manual.com