0% found this document useful (0 votes)
5 views

lect2-c1

شرح تفصيلي عن المعالجات الحديثة

Uploaded by

khkha415
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

lect2-c1

شرح تفصيلي عن المعالجات الحديثة

Uploaded by

khkha415
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬

2.1 Processor Organization


We will consider the processor organization of 8086 processor, which can see it diagram in
Figure -1-
١ ‫ ﻭﻜﻤﺎ ﻤﻭﻀﺢ ﻓﻲ ﺍﻟﺭﺴﻡ‬8086 ‫ﺴﻴﺘﻡ ﺍﻋﺘﻤﺎﺩ ﻫﻴﻜﻴﻠﺔ ﻤﻌﺎﻟﺞ‬

AH AL
General
purpose BH BL
register
CH CL Program control
DH DL
CS
SP
Pointer DS
Segment
Register BP
SS Register
Index SI
Register ES
DI
Bus Bus
Control
Logic

ALU : 1
Arithmetic and
logic unit 2
Instruction
3 Queue
CU:
Control unit 4
Flags Register

Instruction
Pointer

Fig -1- Execution Unit and Bus Interface Unit


8086 Processor Organization

٩
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
The organization of 8086 Processor is partitioned into two logical units
a. Bus Interface unit (BIU)
b. Execution Unit (EU)
:‫ ﺍﻟﻰ ﻭﺤﺩﺘﻴﻥ ﻤﻨﻁﻘﺘﻴﻥ ﻫﻤﺎ‬8086 ‫ﻴﺘﻡ ﺘﻘﺴﻴﻡ ﻫﻴﻜﻴﻠﺔ ﺍﻟﻤﻌﺎﻟﺞ‬

‫ ﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯ‬.‫ﺃ‬

‫ ﻭﺤﺩﺓ ﺍﻟﺘﻨﻔﻴﺫ‬.‫ﺏ‬

2.1.a. Bus Interface Unit (BIU)


The role of the BIU delivers instructions and data to the EU. The most important function of the
BIU is to manage the Bus control unit which response of making synchronization between the
CPU and the Device is connected to it, by reading it specification. And the other function of the
Bus Control Unit is specify which device is connected when more than one device is request an
service from CPU at the same time with respect to priority specified from the designer or the
user.
‫ ﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯ‬.‫ﺃ‬
‫ ﺍﻥ ﺍﻟﻭﻅﻴﻔﺔ ﺍﻟﺭﺌﻴﺴﻴﺔ ﻫﻭ ﺘﻨﻅﻴﻡ‬. ‫ﺍﻥ ﺍﻟﺩﻭﺭ ﺍﻟﺭﺌﻴﺴﻲ ﻟﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯ ﻫﻭ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯﺍﺕ ﻭﺍﻟﺒﻴﺎﻨﺎﺕ ﺍﻟﻰ ﻭﺤﺩﺓ ﺍﻟﺘﻨﻔﻴﺫ‬
‫ ﻤﻥ ﺨﻼل ﻗﺭﺍﺀﺓ‬،‫ ﻭﺍﻟﺘﻲ ﺘﻜﻭﻥ ﻤﺴﻭﺅﻟﺔ ﻋﻥ ﻋﻤل ﺘﺯﺍﻤﻥ ﺒﻴﻥ ﺍﻟﻤﻌﺎﻟﺞ ﻭﺍﻟﺠﻬﺎﺯ ﺍﻟﻤﺭﺒﻭﻁ ﻤﻌﻪ‬Bus‫ﻭﺤﺩﺓ ﺍﻟﺴﻴﻁﺭﺓ ﻋﻠﻰ ﺍﻟـ‬
‫ ﻫﻭ ﺘﺤﺩﻴﺩ ﺍﻱ ﺠﻬﺎﺯ ﻴﺭﺘﺒﻁ ﻋﻨﺩﻤﺎ ﻴﻁﻠﺏ‬Bus ‫ ﻭﺍﻟﻭﻅﻴﻔﺔ ﺍﻻﺨﺭﻯ ﻟﻭﺤﺩﺓ ﺍﻟﺴﻴﻁﺭﺓ ﻋﻠﻰ ﺍﻟـ‬.‫ﺍﻟﻤﻭﺍﺼﻔﺎﺕ ﺍﻟﺨﺎﺼﺔ ﺒﺎﻟﺠﻬﺎﺯ‬
.‫ﺍﻜﺜﺭ ﻤﻥ ﺠﻬﺎﺯ ﺨﺩﻤﺔ ﻓﻲ ﻨﻔﺱ ﺍﻟﻭﻗﺕ ﻤﻥ ﺨﻼل ﺍﻓﻀﻠﻴﺎﺕ ﺘﺤﺩﺩ ﻤﻥ ﻗﺒل ﺍﻟﻤﺼﻤﻡ ﺍﻭ ﺍﻟﻤﺴﺘﺨﺩﻡ‬
Another function of the BIU is to provide access to instructions. Because the instructions for a
program that is executing are in memory, the BIU must access instructions from memory and
place them in an instruction queue, which varies on size from 5 instructions to 7 instructions
depending on the processor. This feature enables the BIU to look ahead and prefetch
instructions so that there is always a queue of instructions ready to execute.
‫ ﻭﺒﺴﺒﺏ ﺍﻥ ﺍﻻﻴﻌﺎﺯﺍﺕ ﻟﺒﺭﻨﺎﻤﺞ ﻭﺍﻟﺫﻱ ﻴﺘﻡ ﺘﻨﻔﻴﺫﻩ ﻴﻜﻭﻥ‬.‫ﺍﻥ ﺍﻟﻭﻅﻴﻔﺔ ﺍﻻﺨﺭﻯ ﻟﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯ ﻫﻭ ﻋﻤل ﻤﻌﺎﻟﺠﺔ ﻟﻼﻴﻌﺎﺯﺍﺕ‬

‫ ﻭﺒﺎﻟﺘﺎﻟﻲ ﻴﺠﺏ ﺍﻥ ﺘﻘﻭﻡ ﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯ ﺒﺠﻠﺏ ﺍﻻﻴﻌﺎﺯﺍﺕ ﻤﻥ ﺍﻟﺫﺍﻜﺭﺓ ﻭﻭﻀﻌﻬﺎ ﻓﻲ ﻁﺎﺒﻭﺭ‬، ‫ﻤﻭﺠﻭﺩ ﻓﻲ ﺍﻟﺫﺍﻜﺭﺓ‬

‫ ﻭﻫﺫﻩ ﺍﻟﺨﺎﺼﻴﺔ ﺘﻤﻜﻥ ﻭﺤﺩﺓ‬.‫ ﺍﻴﻌﺎﺯﺍﺕ ﺒﺎﻻﻋﺘﻤﺎﺩ ﻋﻠﻰ ﻨﻭﻉ ﺍﻟﻤﻌﺎﻟﺞ‬٧ ‫ ﺍﻴﻌﺎﺯﺍﺕ ﺍﻟﻰ‬٥ ‫ﺍﻻﻴﻌﺎﺯﺍﺕ ﻭﺍﻟﺫﻱ ﻴﺘﺭﻭﺍﺡ ﻁﻭﻟﻪ ﺒﻴﻥ‬

١٠
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯﺍﺕ ﻤﻥ ﺘﺤﻀﻴﺭ ﻤﺠﻤﻭﻋﺔ ﺍﻴﻌﺎﺯﺍﺕ ﺠﺎﻫﺯﺓ ﻟﻠﺘﻨﻔﻴﺫ ﻭﻗﺩ ﺘﻡ ﺠﻠﺒﻬﺎ ﻤﺴﺒﻘﺎ ﻤﻥ ﺍﻟﺫﺍﻜﺭﺓ ﻭﺒﺎﻟﺘﺎﻟﻲ ﺘﻭﻓﻴﺭ ﻁﺎﺒﻭﺭ ﻤﻥ‬

.‫ﺍﻻﻴﻌﺎﺯﺍﺕ ﺍﻟﺠﺎﻫﺯﺓ ﻟﻠﺘﻨﻔﻴﺫ‬

Manage the segment register and controlling the process of addressing the memory is another
function of BIU. The segment register is considering the most important set of registers in 8086
CPU and we have four types of segments:
‫ ﺘﻌﺘﺒﺭ ﻤﺴﺠﻼﺕ‬. ‫ﺘﻨﻅﻴﻡ ﻤﺴﺠﻼﺕ ﺍﻟﺘﺠﺯﺌﺔ ﻭﺍﻟﺴﻴﻁﺭﺓ ﻋﻠﻰ ﻋﻤﻠﻴﺔ ﻋﻨﻭﻨﺔ ﺍﻟﺫﺍﻜﺭﺓ ﻫﻭ ﻭﻅﻴﻔﺔ ﺍﺨﺭﻯ ﻟﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻟﻤﻌﻠﻭﻤﺎﺕ‬

: ‫ ﻭﻫﻨﺎﻙ ﺍﺭﺒﻌﺔ ﺍﻨﻭﺍﻉ ﻤﻥ ﻤﺴﺠﻼﺕ ﺍﻟﺘﺠﺯﺌﺔ‬8086 ‫ﺍﻟﺘﺠﺯﺌﺔ ﻫﻲ ﺍﻫﻡ ﻤﺠﻤﻭﻋﺔ ﻤﺴﺠﻼﺕ ﻀﻤﻥ ﻤﺴﺠﻼﺕ ﺍﻟﻤﻌﺎﻟﺞ‬

1. Code segment register


‫ﺸﺭﻴﺤﺔ ﻭﻤﺴﺠل ﺘﺠﺯﺌﺔ ﺍﻟﺒﺭﻨﺎﻤﺞ‬

2. Data segment register


‫ﺸﺭﻴﺤﺔ ﻭﻤﺴﺠل ﺘﺠﺯﺌﺔ ﺍﻟﺒﻴﺎﻨﺎﺕ‬

3. Stack segment register


‫ﺸﺭﻴﺤﺔ ﻭﻤﺴﺠل ﺘﺠﺯﺌﺔ ﺍﻟﻤﻜﺩﺱ‬

4. Extra segment register


‫ﺸﺭﻴﺤﺔ ﻭﻤﺴﺠل ﺘﺠﺯﺌﺔ ﺍﻻﻀﺎﻓﻲ‬

Let us first define the segment as a special area defined in a program that begins on paragraph
boundary, that is, at a location evenly divisible by 16, or hex 10. Although a segment may be
located, almost anywhere in memory and in real mode (executing one program in one time) the
size of segment is 64 KB and the size of the space it takes in memory is equal to the space
required for the program execution. In addition, we note that there is another mode of operating
is called protected mode (executing more than one program in one time) which can process
working in it.
‫ﻓﻲ ﺍﻟﺒﺩﺍﻴﺔ ﻟﻨﻌﺭﻑ ﺍﻟﻤﻘﻁﻊ ﻭﺍﻟﺫﻱ ﻫﻭ ﻋﺒﺎﺭﺓ ﻋﻥ ﻤﻨﻁﻘﺔ ﺨﺎﺼﺔ ﻤﻌﺭﻓﺔ ﻤﻥ ﻓﺒل ﺍﻟﺒﺭﻨﺎﻤﺞ ﻭﺍﻟﺘﻲ ﺘﺒﺩﺍ ﺒﻤﺎ ﻴﻌﺭﻑ ﺒﺎل‬

‫ ﻭﻴﻤﻜﻥ‬. ‫ ﻓﻲ ﺍﻟﻨﻅﺎﻡ ﺍﻟﺴﺎﺩﺱ ﺍﻟﻌﺸﺭﻱ‬10 ‫ ﺍﻭ‬16 ‫ ﻭﻫﻭﻋﻨﻭﺍﻥ ﻤﻭﻗﻊ ﻓﻲ ﺍﻟﺫﺍﻜﺭﺓ ﻴﻘﺒل ﺍﻟﻘﺴﻤﺔ ﻋﻠﻰ‬Paragraph boundary

١١
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫( )ﺘﻨﻔﻴﺫ ﻨﺭﻨﺎﻤﺞ ﻭﺍﺤﺩ ﻓﻲ ﻭﻗﺕ ﻭﺍﺤﺩ ﻓﺎﻥ‬real mode) ‫ﺍﻴﻥ ﻴﻜﻭﻥ ﺍﻟﻤﻘﻁﻊ ﻓﻲ ﺍﻱ ﻤﻜﺎﻥ ﺒﺎﻟﺫﺍﻜﺭﺓ ﻭﻓﻲ ﻨﻤﻁ ﺍﻟﺘﺸﻐﻴل ﺍﻟﻤﻌﺎﻟﺞ‬

‫ ﻭﺴﻴﻜﻭﻥ ﺤﺠﻡ ﺍﻟﻤﺎﺨﻭﺫ ﻤﻥ ﺍﻟﺫﺍﻜﺭﺓ‬64KB ‫ﺤﺠﻡ ﺍﻟﻤﻘﻁﻊ ﺴﻴﻜﻭﻥ‬

Let us exam the four types of segment and begin with


1. Code segment
The code segment contains the machine instructions that are to execute. Typically, the first
execute instruction is at start of this segment, and the operating system links to that location to
begin program execution. As the name implies, the code segment (CS) register addresses the
code segment. If your code area requires more than 64KB, your program may need to define
more than one code segment.
‫ ﻋﻤﻠﻴﺎ ﺍﻥ ﺍﻻﻴﻌﺎﺯ ﺍﻟﺘﻨﻔﻴﺫﻱ ﺍﻻﻭل ﺴﻴﻜﻭﻥ ﻓﻲ ﺒﺩﺍﻴﺔ ﺍﻟﻤﻘﻁﻊ‬. ‫ ﻴﺤﺘﻭﻱ ﺍﻴﻌﺎﺯﺍﺕ ﺍﻻﻟﺔ ﺍﻟﺘﻲ ﺴﻴﺘﻡ ﺘﻨﻔﻴﺫﻫﺎ‬Code‫ﺍﻥ ﻤﻘﻁﻊ ﺍﻟـ‬

‫ ﻭﺴﻴﻜﻭﻥ ﻫﻨﺎﻙ ﻤﺴﺠل ﺒﻨﻔﺱ ﺍﻻﺴﻡ‬.‫ﻭﺴﻴﺭﺘﺒﻁ ﻨﻅﺎﻡ ﺍﻟﺘﺸﻐﻴل ﻤﻊ ﻫﺫﺍ ﺍﻟﻤﻭﻗﻊ ﺍﻟﻤﺨﺯﻭﻥ ﺒﻪ ﺍﻻﻴﻌﺎﺯ ﺍﻻﻭل ﻟﻴﺘﻡ ﺘﻨﻔﻴﺫ ﺍﻟﺒﺭﻨﺎﻤﺞ‬

. Code‫ ﻓﻴﺘﻡ ﺘﻌﺭﻴﻑ ﺍﻜﺜﺭ ﻤﻥ ﻤﻘﻁﻊ ﻟﻠـ‬64KB ‫ ﻭﺍﺫﺍ ﻜﺎﻥ ﺤﺠﻡ ﺍﻟﺒﺭﻨﺎﻤﺞ ﺍﻜﺒﺭ ﻤﻥ‬.‫ﻴﺤﺘﻔﻅ ﺒﻌﻨﻭﺍﻥ ﺒﺩﺍﻴﺔ ﺍﻟﻤﻘﻁﻊ‬

2. Data Segment
The data segment contains a program's defined data, constants, and work areas. The data
segment (DS) register addresses the data segment. If your data area requires more than 64KB,
your program need to defines more than one data segment.
‫ ﻭﻴﻌﻨﻭﻥ ﻤﺴﺠل ﺨﺎﺹ ﻟﻬﺫﺍ‬.‫ ﻤﻨﺎﻁﻕ ﺍﻟﻌﻤل‬، ‫ ﺍﻟﺜﻭﺍﺒﺕ‬، ‫ﻴﺤﺘﻭﻱ ﻤﻘﻁﻊ ﺍﻟﺒﻴﺎﻨﺎﺕ ﻋﻠﻰ ﺍﻟﺒﻴﺎﻨﺎﺕ ﺍﻟﻤﻌﺭﻓﺔ ﻤﻥ ﻗﺒل ﺍﻟﺒﺭﻨﺎﻤﺞ‬

.‫ ﻓﻴﺘﻡ ﺘﻭﻟﻴﺩ ﺍﻜﺜﺭ ﻤﻥ ﻤﻘﻁﻊ ﺒﻴﺎﻨﺎﺕ‬64KB ‫ ﻭﺍﺫﺍ ﻜﺎﻥ ﻤﻘﻁﻊ ﻴﺤﺘﺎﺝ ﺍﻜﺜﺭ ﻤﻥ‬. ‫ﺍﻟﻐﺭﺽ ﻤﻘﻁﻊ ﺍﻟﺒﻴﺎﻨﺎﺕ‬

3. Stack segment
In simple terms, the stack contains any data and addresses that you need to save temporarily
during an execute a subroutines related to the main program. The stack segment register
addresses the stack segment.
‫( ﻴﺤﺘﻔﻅ ﺒﺸﻜل ﻤﺅﻗﺕ ﺒﺎﻱ ﺒﻴﺎﻨﺎﺕ ﺍﻭ ﻋﻨﻭﺍﻨﻴﻥ ﻴﺤﺘﺎﺠﻬﺎ ﺍﻟﺒﺭﻨﺎﻤﺞ ﺍﻟﺭﺌﻴﺴﻲ ﺍﺜﻨﺎﺀ ﺘﻨﻔﻴﺫ‬Stack) ‫ ﺍﻥ ﺍﻟﻤﻜﺩﺱ‬،‫ﺒﻜﻠﻤﺎﺕ ﺒﺴﻴﻁﺔ‬

. Stack ‫ ﻭﻫﻨﺎﻙ ﻤﺴﺠل ﺨﺎﺹ ﻴﻌﻨﻭﻥ ﻤﻘﻁﻊ ﺍﻟـ‬.‫ﺒﺭﻨﺎﻤﺞ ﻓﺭﻋﻲ ﻤﺭﺘﺒﻁ ﺒﻪ‬

١٢
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
Segment Boundaries
The segment is begin with an address called paragraph boundary which mean an address begin
with digit 0 from the right side of 5 digits address .Therefore, it will be choose an location with
address starting with zero digit. Because of the length of any segment is 64KB, which equal to
65536 locations and when convert to hexa after subtract one of the number the result, is
FFFFH.
‫ ﻭﺍﻟﺫﻱ ﻴﻌﻨﻲ ﺍﻥ ﺍﻟﻌﻨﻭﺍﻥ ﻴﺒﺩﺍ ﺒﺭﻗﻡ ﺼﻔﺭ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﻤﻴﻥ ﻟﻌﻨﻭﺍﻥ ﻤﻥ‬paragraph boundary ‫ﻴﺒﺩﺍ ﺍﻟﻤﻘﻁﻊ ﺒﻌﻨﻭﺍﻥ ﻴﺴﻤﻰ‬

‫ ﻭﺍﻟﺫﻱ ﻴﺴﺎﻭﻱ‬64KB ‫ ﻭﺒﺴﺒﺏ ﺍﻥ ﺤﺠﻡ ﺍﻟﻤﻘﻁﻊ ﻫﻭ‬.‫ ﻭﺒﺎﻟﺘﺎﻟﻲ ﻓﺎﻨﻪ ﺴﻴﺨﺘﺎﺭ ﻋﻨﻭﺍﻥ ﻤﻭﻗﻊ ﻴﺒﺩﺍﺀ ﺒﺎﻟﺭﻗﻡ ﺼﻔﺭ‬، ‫ﺨﻤﺴﺔ ﺍﺭﻗﺎﻡ‬

.FFFFH ‫ ﻤﻭﻗﻊ ﻭﻋﻨﺩﻤﺎ ﺘﺤﻭل ﺍﻟﻰ ﺍﻟﻨﻅﺎﻡ ﺍﻟﺴﺎﺩﺱ ﻋﺸﺭﻱ ﻤﻁﺭﻭﺡ ﻤﻨﻬﺎ ﻭﺍﺤﺩ ﻓﺎﻥ ﺍﻟﻨﺎﺘﺞ ﻤﺴﺎﻭﻱ ﺍﻟﻰ‬٦٥٥٣٦

The segment begins with address 0000H to FFFFH as the offset inside the segment. Therefore,
we will use a set of register to locate the staring address of segment and can define as:
A segment register is 16 bits long and provides for addressing an area of memory known as the
current segment, to reduce the complexity of processor register it store 4 digits instead of 5
digits and insert 0 digit from right of the address of segment register.
‫ ﻭﺒﺎﻟﺘﺎﻟﻲ ﺴﻴﺘﻡ ﺍﺴﺘﺨﺩﺍﻡ ﻤﺠﻤﻭﻋﺔ ﻤﻥ ﺍﻟﻤﺴﺠﻼﺕ‬.‫ ﻭﻜﻤﺎﻓﺔ ﺍﺯﺍﺤﺔ ﺩﺍﺨل ﺍﻟﻤﻘﻁﻊ‬FFFFH ‫ ﺍﻟﻰ‬0000H ‫ﻴﺒﺩﺍ ﺍﻟﻤﻘﻁﻊ ﺒﺎﻟﻌﻨﻭﺍﻥ‬

‫ ﻭﺍﻟﺘﻲ ﺘﺴﺘﺨﺩ ﻟﻌﻨﻭﻨﺔ ﻤﺴﺎﺤﺔ‬16bit ‫ ﺒﺎﻨﻪ ﻤﺴﺠل ﺒﻁﻭل‬:‫ﻭﺍﻟﺘﻲ ﺘﺤﺘﻔﻅ ﺒﻌﻨﻭﺍﻨﻴﻥ ﺍﻟﺒﺩﺍﻴﺔ ﻟﻠﻤﻘﺎﻁﻊ ﻭﻴﻤﻜﻥ ﺘﻌﺭﻴﻑ ﻤﺴﺠل ﺍﻟﻤﻘﻁﻊ‬

‫ ﻭﻤﻥ ﺍﺠل ﺘﻘﻠﻴل ﺘﻌﻘﻴﺩ ﻤﺴﺠل ﺍﻟﻤﻌﺎﻟﺞ ﻓﺎﻨﻪ ﻴﺨﺯﻥ ﺍﺭﺒﻌﺔ ﺍﺭﻗﺎﻡ ﺒﺩﻻ ﻤﻥ ﺨﻤﺴﺔ ﻤﻊ ﺍﻀﺎﻓﺔ‬، ‫ﻤﻥ ﺍﻟﺫﺍﻜﺭﺓ ﺘﺴﻤﻰ ﺍﻟﻤﻘﻁﻊ ﺍﻟﺤﺎﻟﻲ‬

.‫ﺼﻔﺭ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﻤﻴﻥ ﻋﻨﺩ ﺍﻟﺘﻌﺎﻤل ﻤﻊ ﺍﻟﻘﻴﻤﺔ ﺍﻟﻤﻭﺠﻭﺩﺓ ﻀﻤﻥ ﺍﻟﻤﺴﺠل‬

Let ' take an overview about segment registers:


‫ﻟﻨﻠﻘﻲ ﻨﻅﺭﺓ ﻋﻠﻰ ﺍﻨﻭﺍﻉ ﻤﺴﺠﻼﺕ ﺍﻟﻤﻘﻁﻊ‬

1. Code Segment register (CS): contains the starting address of a program's code segment. For
normal programming purpose, you need not reference the CS register.
‫ ﻭﻓﻲ ﺍﻟﺒﺭﻤﺠﺔ ﺍﻟﻌﺎﺩﻴﺔ ﻻﻴﺘﻡ ﺍﻻﺸﺎﺭﺓ ﺍﻟﻰ ﻫﺫﺍ‬. ‫ﻤﺴﺠل ﻤﻘﻁﻊ ﺍﻟﺒﺭﻨﺎﻤﺞ ﻭﻫﻭ ﻴﺤﻭﻱ ﻋﻠﻰ ﻋﻨﻭﺍﻥ ﺍﻟﺒﺩﺍﻴﺔ ﻟﻤﻘﻁﻊ ﺍﻟﺒﺭﻨﺎﻤﺞ‬

.‫ﺍﻟﻤﺴﺠل‬

١٣
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
2. Data Segment register (DS): contains the starting address of a program data segment.
Instructions use this address to locate data.
‫ﻤﺴﺠل ﻤﻘﻁﻊ ﺍﻟﺒﻴﺎﻨﺎﺕ ﻭﻫﻭ ﻴﺤﻭﻱ ﻋﻠﻰ ﻋﻨﻭﺍﻥ ﺍﻟﺒﺩﺍﻴﺔ ﻟﻤﻘﻁﻊ ﺍﻟﺒﻴﺎﻨﺎﺕ ﻭﺍﻻﻴﻌﺎﺯﺍﺕ ﺘﺴﺘﺨﺩﻡ ﻫﺫﺍ ﺍﻟﻌﻨﻭﺍﻥ ﻟﺘﺤﺩﻴﺩ ﻤﻭﻗﻊ‬

.‫ﺍﻟﺒﻴﺎﻨﺎﺕ‬

3. Stack Segment register (SS) Permits the implementation of a stack in memory, which a
program uses for temporary storage of address of a program's stack segment in the SS register.
For normal programming purpose, you need not directly reference the SS register.
‫ﻤﺴﺠل ﻤﻘﻁﻊ ﺍﻟﻤﻜﺩﺱ ﻭﺍﻟﺫﻱ ﻴﺴﻤﺢ ﺒﺎﺴﺘﺨﺩﺍﻡ ﺍﻟﻤﻜﺩﺱ ﻓﻲ ﺍﻟﺫﺍﻜﺭﺓ ﻭﺍﻟﺫﻱ ﻴﺴﺘﺨﺩﻡ ﻤﻥ ﻗﺒل ﺍﻟﺒﺭﻨﺎﻤﺞ ﻟﻠﺨﺯﻥ ﺍﻟﻤﺅﻗﺕ ﻭﻫﻭ‬

.‫ﻭﻓﻲ ﺍﻟﺒﺭﻤﺠﺔ ﺍﻟﻌﺎﺩﻴﺔ ﻻﻴﺘﻡ ﺍﻻﺸﺎﺭﺓ ﺍﻟﻰ ﻫﺫﺍ ﺍﻟﻤﺴﺠل‬.‫ﻴﺤﺘﻔﻅ ﺒﻌﻨﻭﺍﻥ ﺒﺩﺍﻴﺔ ﻤﻘﻁﻊ ﺍﻟﻤﻜﺩﺱ‬

4. Extra Segment register (ES): used by some string (character data) operations to handle
memory addressing. The ES (Extra segment) register is associated with DI (index register).
A program that requires the use of the ES may initialize with an appropriate segment address.
ES ‫ ﻭﺘﺭﺘﺒﻁ ﻤﺴﺠل‬.‫ﻤﺴﺠل ﺍﻟﻤﻘﻁﻊ ﺍﻻﻀﺎﻓﻲ ﻭﻫﻭ ﻴﺴﺘﺨﺩﻡ ﻤﻊ ﻋﻤﻠﻴﻼﺕ ﺍﻟﺴﻼﺴل ﺍﻟﺤﺭﻓﻴﺔ ﻋﻨﺩﻤﺎ ﺘﺴﺘﺨﺩﻡ ﻋﻨﻭﺍﻨﻴﻥ ﺍﻟﺫﺍﻜﺭﺓ‬

.‫ﻭﻫﻲ ﺘﻭﻟﺩ ﺍﻥ ﺍﺤﺘﺎﺝ ﺍﻟﺒﺭﻨﺎﻤﺞ ﺍﻟﺘﻌﺎﻤل ﻤﻊ ﺍﻟﺴﻼﺴل ﺍﻟﺤﺭﻓﻴﺔ‬. DI ‫ﻤﻊ ﻤﺴﺠل ﺍﻟﻔﻬﺭﺴﺔ‬

5. FS AND GS registers Additional extra segment registers on the 80386 and later processors.

Management OF Generated Segments


‫ﺘﻨﻅﻴﻡ ﺘﻭﻟﻴﺩ ﺍﻟﻤﻘﺎﻁﻊ‬

Example: Find the configuration of segments generated by two programs , first Program A deal
with arithmetic operations and has 800KB in its programming section and 600KB in its data
sections and 900 KB in stack sections while second Program B has 1048 KB code and 660KB
data and 2066 KB as stack memory. And Find the total number of segments generated.
‫ ﻓﻲ ﺠﺯﺀ‬800KB ‫ﺠﺩ ﻜﻴﻑ ﻴﺘﻡ ﺘﻨﻅﻴﻡ ﺍﻟﻤﻘﺎﻁﻊ ﺍﻟﻤﻭﻟﺩﺓ ﻤﻥ ﺨﻼل ﺒﺭﻨﺎﻤﺠﻴﻥ ﺍﻻﻭل ﻴﺘﻌﺎﻤل ﻤﻊ ﻋﻤﻠﻴﺎﺕ ﺭﻴﺎﻀﻴﺔ ﻭﻴﻤﺘﻠﻙ‬

660KB ‫ ﻭ‬Code ‫ ﻜـ‬1048 ‫ ﺒﻴﻨﻤﺎ ﻴﻤﺘﻠﻙ ﺍﻟﺒﺭﻨﺎﻤﺞ ﺍﻟﺜﺎﻨﻲ‬Stack ‫ ﻟﺠﺯﺀ‬900KB ‫ ﻟﺠﺯﺀ ﺍﻟﺒﻴﺎﻨﺎﺕ ﻭ‬600KB ‫ﺍﻟﺒﺭﻤﺠﺔ ﻭ‬

.‫ ﻭﺠﺩ ﻋﺩﺩ ﺍﻟﻤﻘﺎﻁﻊ ﺍﻟﻜﻠﻴﺔ ﺍﻟﻤﺘﻭﻟﺩﺓ ﻤﻥ ﻗﺒل ﺍﻟﺒﺭﻨﺎﻤﺠﻴﻥ‬. Stackٍ ‫ ﻜـ‬2066KB ‫ ﻭ‬Data ‫ﻜـ‬

١٤
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
Sol
The default size of any 64 KB and we have three types of segments
‫ ﻭﻟﺩﻴﻨﺎ ﺜﻼﺜﺔ ﺍﻨﻭﺍﻉ‬64KB ‫ﺍﻥ ﺍﻟﺤﺠﻡ ﺍﻻﺼﻠﻲ ﻟﻠﻤﻘﻁﻊ ﻫﻭ‬

Code segment , Data segment , Stack segment


Therefore the Program A has these segments
Number of segments = size of section / size of one segment
No. of code segments = 800KB / 64 KB= 12.5 =13 segments
No. of data segments = 600KB / 64 KB= 9.375 =10 segments
No. of stack segments = 900KB / 64 KB= 14.0625 =15 segments
And for Program B has these segments
No. of code segments = 1048KB / 64 KB= 16.375 =17 segments
No. of data segments = 660KB / 64 KB= 10.3125 =11 segments
No. of stack segments = 2066KB / 64 KB= 32.28125 =33 segments

2.1.b. Execution Unit (EU)


The role of the EU is to execute instructions, whereas the BIU delivers instructions and data to
the EU. The EU contains an arithmetic and logic unit (ALU), a control unit (CU), and a number
of registers. These features provide for execution of instruction and arithmetic and logical
operations.
‫ ﻭﺤﻴﺙ ﺍﻥ ﻭﺤﺩﺓ ﺠﻠﺏ ﺍﻻﻴﻌﺎﺯﺍﺕ ﺘﻘﻭﻡ ﺒﺠﻠﺏ ﺍﻻﻴﻌﺎﺯﺍﺕ ﻭﺍﻟﺒﻴﺎﻨﺎﺕ‬، ‫ﺍﻥ ﺍﻟﻬﺩﻑ ﺍﻟﺭﺌﻴﺴﻲ ﻤﻥ ﻭﺤﺩﺓ ﺍﻟﺘﻨﻔﻴﺫ ﻫﻭ ﺘﻨﻔﻴﺫ ﺍﻻﻴﻌﺎﺯﺍﺕ‬

، ‫ ﻭﺘﺤﺘﻭﻱ ﻫﺫﻩ ﺍﻟﻭﺤﺩﺓ ﻋﻠﻰ ﻭﺤﺩﺓ ﺍﻟﺤﺴﺎﺏ ﻭﺍﻟﻤﻨﻁﻕ ﻭﻭﺤﺩﺓ ﺍﻟﺴﻴﻁﺭﺓ ﻭﻋﺩﺩ ﻤﻥ ﺍﻟﻤﺴﺠﻼﺕ‬.‫ﻤﻥ ﺍﻟﺫﺍﻜﺭﺓ ﺍﻟﻰ ﻭﺤﺩﺓ ﺍﻟﺘﻨﻔﻴﺫ‬

. ‫ﻭﻫﺫﻩ ﺍﻟﻤﻜﻭﻨﺎﺕ ﺘﻭﻓﺭ ﺍﻤﻜﺎﻨﻴﺔ ﺘﻨﻔﻴﺫ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ ﻭﺍﻟﻤﻨﻁﻘﻴﺔ‬

We can classify the components of EU to :


1. Pointers Registers
‫ﻤﺴﺠﻼﺕ ﺍﻟﺘﺎﺸﻴﺭ‬

The Three pointer registers are the IP, SP, and BP.
.IP,SP,BP ‫ﻫﻨﺎﻙ ﺜﻼﺜﺔ ﺍﻨﻭﺍﻉ ﻤﻥ ﻤﺴﺠﻼﺕ ﺍﻟﺘﺎﺸﻴﺭ ﻭﻫﻲ‬
١٥
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
Instruction Pointer (IP) register
The 16-bit IP register contains the offset address of the next instruction that is to execute. The
IP is associated with CS register in that The IP indicates the current instruction within the
currently executing code segment. You do not normally reference the IP register in program,
but you can change its value when using the DEBUG program to test a program. The 80386
and later processors have an extended 32-bit IP called the EIP.

‫ ﺤﻴﺙ ﻴﺘﻭﻟﺩ‬CS ‫ ﻤﻊ ﻤﺴﺠل‬IP ‫ ﻭﺒﺎﺭﺘﺒﺎﻁ ﻤﺴﺠل‬، ‫ ﻋﻠﻰ ﻋﻨﻭﺍﻥ ﺍﻻﺯﺍﺤﺔ ﻟﻼﻴﻌﺎﺯ ﺍﻟﺘﺎﻟﻲ ﻓﻲ ﺍﻟﺘﻨﻔﻴﺫ‬IP 16-bit ‫ﻴﺤﺘﻭﻱ ﻤﺴﺠل‬

‫ ﺒﺸﻜل ﺍﻋﺘﻴﺎﺩﻱ ﻤﻥ ﻗﺒل‬IP ‫ ﻭﻻﻴﻤﻜﻥ ﺍﻟﺘﺤﻜﻡ ﺒﻘﻴﻤﺔ ﻤﺴﺠل‬.‫ﻋﻨﻭﺍﻥ ﺍﻻﻴﻌﺎﺯ ﺍﻟﺤﺎﻟﻲ ﻀﻤﻥ ﻤﻘﻁﻊ ﺍﻟﺒﺭﻨﺎﻤﺞ ﺍﻟﺫﻱ ﻴﻨﻔﺫ ﺤﺎﻟﻴﺎ‬

‫ ﻭﺍﻟﺫﻱ ﻴﻘﻭﻡ ﺒﺘﺩﻗﻴﻕ ﺍﻟﺒﺭﻨﺎﻤﺞ ﻤﻥ ﺍﻻﺨﻁﺎﺀ ﺤﻴﺙ‬DEBUG ‫ ﻭﻟﻜﻥ ﻴﻤﻜﻥ ﺘﻐﻴﻴﺭ ﻗﻴﻤﺘﻪ ﻓﻲ ﺤﺎﻟﺔ ﺍﺴﺘﺨﺩﺍﻡ ﺒﺭﻨﺎﻤﺞ‬،‫ﺍﻟﻤﺴﺘﺨﺩﻡ‬

‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ ﺍﻟﺘﻲ ﺒﻌﺩﻫﺎ ﺘﺤﺘﻭﻱ ﻋﻠﻰ‬80386 ‫ ﻭﻤﻌﺎﻟﺠﺎﺕ‬.IP ‫ﻴﻤﻜﻨﻨﺎ ﻤﻥ ﺠﻌل ﺍﻟﺒﺭﻨﺎﻤﺞ ﻴﻨﻔﺫ ﺨﻁﻭﺓ ﺨﻁﻭﺓ ﻭﺍﻟﺘﺤﻜﻡ ﺒﺎﻟﻤﺴﺠل‬

.EIP ‫ ﻭﻴﺴﻤﻰ‬32-bit ‫ﻤﺴﺠل ﻤﻭﺴﻊ ﺒﻁﻭل‬

Stack Pointer (SP) register


The 16-bit SP register provides an offset value, which when associated with the SS register,
refers to the current word being processed in the stack. The 80386 and later processors have an
extended 32-bit stack pointer, the ESP register. The system automatically handles these
registers.
‫ ﺘﻤﺘﻠﻙ ﻤﻌﺎﻟﺠﺎﺕ‬.stack ‫ ﻟﺘﻌﻨﻭﻥ ﺍﻟﻜﻠﻤﺔ ﺍﻟﺤﺎﻟﻴﺔ ﺍﻟﻤﻭﺠﻭﺩﺓ ﻓﻲ‬SS ‫ ﺍﻻﺯﺍﺤﺔ ﻭﺍﻟﺘﻲ ﺘﺭﺒﻁ ﻤﻊ ﻤﺴﺠل‬16 – bit SP ‫ﻴﻘﺩﻡ ﻤﺴﺠل‬
‫ ﻭﺍﻟﻨﻅﺎﻡ‬.ESP ‫ ﻭﺍﻟﻤﻌﺭﻭﻑ‬stack pointer ‫ ﺒﺕ ﺍﻱ ﻤﺴﺠل ﻤﻭﺴﻊ ﻤﻥ ﻨﻭﻋﻴﺔ‬32‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ ﺍﻟﺘﻲ ﺒﻌﺩﻫﺎ ﻤﺴﺠل ﺏ‬80386
.‫ﺍﻟﻴﺎ ﻴﺘﻌﺎﻤل ﻤﻊ ﻫﺫﻩ ﺍﻟﻤﺴﺠﻼﺕ‬

Base Pointer (BP) register


The 16 – bit BP facilitates referencing parameters, which are data and addresses that a program
passes via the stack. The processor combines the address in the SS with the offset in the BP.
The 80386 and later processors have an extended 32-bit BP called the EBP register

١٦
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫ ﺍﻥ ﺍﻟﻤﻌﺎﻟﺞ‬.stack ‫ ﻭﻫﻲ ﻤﺠﻤﻭﻋﺔ ﺍﻟﺒﻴﺎﻨﺎﺕ ﻭﺍﻟﻌﻨﻭﺍﻨﻴﻥ ﻭﺍﻟﻤﺭﺭﺓ ﺍﻟﻰ‬،‫ ﻴﺅﺸﺭ ﺍﻟﻤﻌﺎﻤﻼﺕ‬16 bit ‫ ﺫﻭ‬BP ‫ﻴﺴﺘﺨﺩﻡ ﻤﺴﺠل‬
‫ ﻭﺍﻟﺘﻲ ﺒﻌﺩﻫﺎ ﺘﻤﺘﻠﻙ ﺍﻟﻨﻭﻉ ﺍﻟﻤﻭﺴﻊ‬80386 ‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ‬.BP ‫ ﻤﻊ ﺍﻻﺯﺍﺤﺔ ﺍﻟﻤﻭﺠﻭﺩ ﻓﻲ‬SS ‫ﻴﺠﻤﻊ ﺒﻴﻥ ﺍﻟﻌﻨﻭﺍﻥ ﻓﻲ ﺍﻟﻤﺴﺠل‬
.EBP ‫ ﺒﺕ ﻭﺍﻟﻤﺴﻤﻰ‬32 ‫ﻤﻥ ﻫﺫﺍ ﺍﻟﻤﺴﺠل ﺫﻭ‬

2.Addressing Using Pointer Registers and Segment Registers


We have rules for determine the final address of information founded in Memory and we have
four different kinds of as:
1. Final address for CODE: value in CS with digit 0 from right + IP
1. Final address for DATA: value in DS with digit 0 from right + Address in the instruction
1. Final address for WORD in Stack: value in SS with digit 0 from right + SP
1. Final address for PARAMETER in Stack: value in SS with digit 0 from right + BP
EX1 Find the final address for these information's:
1. CODE if you know that CS=1FE4 and IP=BB6A
2. DATA if you know that DS=5586210 and the address in the instruction is 42378
3. WORD in Stack if you know that SS=1101101111001102 and SP=567816 and found the Final
address for PARAMETER if BP=3698510.
SOL:
1. Final address for CODE: CS0 + IP
1FE40
+ BB6A
2B9AA
2. Final address for Data : DS0+Address in the instruction
The DS is in the decimal system and we must convert it to the hexadecimal as fllow
16 55862
16 3491 6
16 218 3
16 13 A
16 0 D

١٧
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
Therefore the value of DS=DA36
And the of the address in the instruction is in Octal and we must converted into Hexadecimal
4 2 3 7
100 010 011 111
8 9 F
Therefore, the value of address in the instruction is 089F

And the final of address of Data is:


DA360
+ 089F
DABFF

3. Final address of WORD in the Stack: SS0 + SP


The value of SS in the binary Form and we must converted into Hexadecimal form
0110110111100110
6 D E 6

Therefore, the value of SS=6DE6


6DE60
+ 5678
734D8

And final address for PARAMETER is SS0+BP


BP= 3698510 907916
6DE60
+ 9079
76ED9

١٨
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
3.General – Purpose Registers
The AX, BX, CX and DX general – purpose registers are the workhorses of the system. They
are unique in that you can address them as one word or as a 1- byte portion. The leftmost byte is
the "high" portion and the rightmost byte is the "low" portion. For example, the AX register
consists of an AH (high) and an AL (low) portion, and you can reference any portion by its
name. The 80386 and later processors support all the general – purpose registers, plus 32-bit
extended versions of them: the EAX, EBX, ECX, and EDX.
‫ ﻭﻫﻲ ﺍﻟﻤﺴﺠﻼﺕ‬. ‫ ﻤﺴﺠﻼﺕ ﺍﻻﺴﺘﺨﺩﺍﻡ ﺍﻟﻌﺎﻤﺔ ﻭﻤﻨﺎﻁﻕ ﺍﻟﻌﻤل ﻓﻲ ﺍﻟﻨﻅﺎﻡ‬AX, BX, CX and DX ‫ﺘﻌﺘﺒﺭ ﺍﻟﻤﺴﺠﻼﺕ‬

‫ ﺍﻟﺘﻲ ﻴﻤﻜﻥ ﺍﻥ ﺘﻘﺴﻡ ﺍﻟﻰ ﺠﺯﺌﻴﻥ ﻜل ﻤﻨﻬﺎ ﺒﺤﺠﻡ ﺒﺎﻴﺕ ﻭﺍﺤﺩ ﻭﻴﺴﻤﻰ ﺍﻟﺠﺯﺀ‬8086 ‫ﺍﻟﻭﺤﻴﺩﺓ ﻀﻤﻥ ﻤﺠﻤﻭﻋﺔ ﻤﺴﺠﻼﺕ ﻤﻌﺎﻟﺞ‬

‫ ﻭﺠﺯﺀ‬AH(high) ‫ ﻜﻤﺜﺎل ﻓﺎﻨﻪ ﻴﺘﻜﻭﻥ ﻤﻥ‬AX ‫ ﻭﻟﻭ ﺍﺨﺫﻨﺎ ﻤﺴﺠل‬. low ‫ ﻭﺍﻟﺠﺯﺀ ﺍﻟﻰ ﺍﻟﻴﻤﻴﻥ ﺒﺎل‬high‫ﺍﻟﻰ ﺍﻟﻴﺴﺎﺭ ﺒﺎﻟـ‬

‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ ﺍﻟﺘﻲ ﺒﻌﺩﻫﺎ ﺘﺩﻋﻡ ﻜل ﺍﻨﻭﺍﻉ‬80386 ‫ ﻭﺍﻟﻤﻌﺎﻟﺞ‬.‫ ﻭﻴﺘﻡ ﺍﻻﺸﺎﺭﺓ ﺍﻟﻰ ﺍﻱ ﺠﺯﺀ ﻤﻥ ﺨﻼل ﺍﺴﻤﻪ‬AL(low) ‫ﺍﺨﺭ ﻫﻭ‬

.EAX, EBX, ECX, and EDX ‫ ﺍﻟﻤﻭﺴﻌﺔ ﻤﻥ ﻫﺫﻩ ﺍﻟﻤﺴﺠﻼﺕ ﻭﻫﻲ‬32-bit ‫ﻤﺴﺠﻼﺕ ﺍﻻﺴﺘﺨﺩﺍﻡ ﺍﻟﻌﺎﻡ ﺍﻀﺎﻓﺔ ﻨﺴﺦ‬

The following assembler instructions move zeros to the AX, BH, and ECX registers,
respectively:
‫ ﻋﻠﻰ ﺍﻟﺘﻭﺍﻟﻲ‬AX, BH, and ECX ‫ﻭﺍﻴﻌﺎﺯﺍﺕ ﺍﻴﺴﻤﺒﻠﻲ ﺍﻟﺘﺎﻟﻴﺔ ﺘﻨﻘل ﺍﻟﺼﻔﺭ ﺍﻟﻰ ﻤﺴﺠﻼﺕ‬

MOV AX,00
MOV BH,00
MOV ECX,00
AX register
The AX register, the primary accumulator, is used for operations involving input / output and
most arithmetic. For example, the multiply, divide, and translate instructions assume the use of
the AX. Also, some instructions generate more efficient code if they reference the AX rather
than another register.

AX
AH AL
EAX

١٩
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫ﻴﻌﺘﺒﺭ ﺍﻟﻤﺴﺠل ‪ AX‬ﻫﻭ ﺍﻟﻤﺭﻜﻡ ﺍﻻﺴﺎﺴﻲ ﻭﻫﻭ ﻴﺴﺘﺨﺩﻡ ﻟﻌﻤﻠﻴﺎﺕ ﺍﻻﺩﺨﺎل ﻭﺍﻻﺨﺭﺍﺝ ﻭﻤﻌﻅﻡ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ‪ .‬ﻭﻜﻤﺜﺎل ﻋﻠﻰ‬

‫ﻫﺫﻩ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﻀﺭﺏ ‪ ،‬ﺍﻟﻘﺴﻤﺔ ‪ ،‬ﻭﺍﻴﻌﺎﺯﺍﺕ ﺍﻟﻨﻘل ﺘﻔﺘﺭﺽ ﺍﺴﺘﺨﺩﺍﻡ ‪ .AX‬ﺒﻌﺽ ﺍﻻﻴﻌﺎﺯﺍﺕ ﺘﻭﻟﺩ ‪ code‬ﺍﻜﺜﺭ ﻜﻔﺎﺀﺓ ﺍﺫﺍ ﻜﺎﻥ‬

‫ﺍﻟﺘﻌﺎﻤل ﻤﻊ ‪ AX‬ﺒﺩﻻ ﻤﻥ ﻤﺴﺠﻼﺕ ﺍﺨﺭﻯ‪.‬‬

‫‪BX register‬‬
‫‪The BX is known as the base register since it is the only general – purpose register that can be‬‬
‫‪used as an index to extend addressing. Another common purpose of the BX is for computations.‬‬

‫‪BX‬‬
‫‪BH‬‬ ‫‪BL‬‬
‫‪EBX‬‬

‫ﻴﺴﻤﻰ ﻤﺴﺠل ‪ BX‬ﺒﻤﺴﺠل ﺍﻟﻘﺎﻋﺩﺓ ﺤﻴﺙ ﺍﻨﻪ ﺍﻟﻤﺴﺠل ﺍﻟﻭﺤﻴﺩ ﺍﻟﺫﻱ ﻴﻤﻜﻥ ﺍﻥ ﻴﺴﺘﺨﺩﻡ ﻜﻤﺅﺸﺭ ﻀﻤﻥ ﺍﻟﻌﻨﻭﻨﺔ ﺍﻟﻤﻭﺴﻌﺔ‪.‬‬

‫ﻭﺍﻟﻭﻅﻴﻔﺔ ﺍﻟﻌﺎﻤﺔ ﺍﻻﺨﺭﻯ ﻫﻲ ﺍﻟﺤﺴﺎﺒﺎﺕ‪.‬‬

‫‪CX register‬‬
‫‪The CX is known as the count register. It may contain a value to control the number of times a‬‬
‫‪loop is repeated or a value to shift bits left or right. The CX may also be used for many‬‬
‫‪computations.‬‬

‫‪CX‬‬
‫‪CH‬‬ ‫‪CL‬‬
‫‪ECX‬‬

‫ﻴﻌﺭﻑ ﺍﻟﻤﺴﺠل ‪ CX‬ﺒﺎﻨﻪ ﻤﺴﺠل ﺍﻟﻌﺩﺍﺩ ‪ .‬ﻭﻫﻭ ﻗﺩ ﻴﺤﺘﻭﻱ ﻋﻠﻰ ﻗﻴﻤﺔ ﺘﺴﻴﻁﺭ ﻋﻠﻰ ﻋﺩﺩ ﻤﺭﺍﺕ ﺘﻜﺭﺍﺭ ﺘﻨﻔﻴﺫ ﺤﻠﻘﺔ ﺘﻜﺭﺍﺭﻴﺔ ﺍﻭ‬

‫ﻗﻴﻤﺔ ﺘﺯﺤﻴﻑ ﺒﺘﺘﺎﺕ ﺍﻟﻰ ﺍﻟﻴﻤﻴﻥ ﺍﻭ ﺍﻟﻴﺴﺎﺭ ‪ ،‬ﻭﻴﻤﻜﻥ ﺍﻥ ﻴﺴﺘﺨﺩﻡ ﻓﻲ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ‪.‬‬

‫‪٢٠‬‬
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
DX register
The DX is known as the data register. Some input / output operations require its use, and
multiply and divide operations that involve large values assume the use of the DX and AX
together as a pair.

DX
DH DL
EDX

‫ ﻭﺘﺴﺘﺨﺩﻡ ﻓﻲ ﺒﻌﺽ ﻋﻤﻠﻴﺎﺕ ﺍﻻﺩﺨﺎل ﻭﺍﻻﺨﺭﺍﺝ ﻭﻜﺫﻟﻙ ﻓﻲ ﻋﻤﻠﻴﺎﺕ ﺍﻟﻀﺭﺏ‬، ‫ ﺒﺎﻨﻪ ﻤﺴﺠل ﺍﻟﺒﻴﺎﻨﺎﺕ‬DX ‫ﻴﻌﺭﻑ ﻤﺴﺠل‬

.‫ ﻜﻤﺴﺠﻠﻴﻥ ﻤﺯﺩﻭﺠﻴﻥ‬DX ‫ ﻭ‬AX ‫ﻭﺍﻟﻘﺴﻤﺔ ﻻﻋﺩﺍﺩ ﻜﺒﻴﺭﺓ ﺤﻴﺙ ﻴﺘﻡ ﺍﺴﺘﺨﺩﺍﻡ ﻜل ﻤﻥ ﺍﻟﻤﺴﺠﻠﻴﻥ‬

You may use any of these general – purpose registers for addition and subtraction of 8 - bit,
16 – bit, or 32 – bit values.
‫ ﺒﺕ‬١٦‫ ﺒﺕ ﻭ‬٨ ‫ﻭﻴﻤﻜﻥ ﺍﻥ ﻴﺴﺘﺨﺩﻡ ﺍﻱ ﻤﻥ ﻫﺫﻩ ﺍﻟﻤﺴﺠﻼﺕ ﺫﺍﺕ ﺍﻻﺴﺘﺨﺩﺍﻡ ﺍﻟﻌﺎﻡ ﻓﻲ ﻋﻤﻠﻴﺎﺕ ﺍﻟﺠﻤﻊ ﻭﺍﻟﻁﺭﺡ ﻭﺒﺎﺤﺠﺎﻡ ﺒﻴﺎﻨﺎﺕ‬

.‫ ﺒﺕ‬٣٢‫ﻭ‬

4.Index Registers
The SI and DI registers are available for indexed addressing and for use in addition and
subtraction.
.‫ﺘﺴﺨﺩﻡ ﻤﺴﺠﻼﺕ ﺍﻟﻔﻬﺭﺴﺔ ﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﻌﻨﻭﻨﺔ ﺍﻟﻤﻔﻬﺭﺴﺔ ﻭﻜﺫﻟﻙ ﻓﻲ ﻋﻤﻠﻴﺎﺕ ﺍﻟﺠﻤﻊ ﻭﺍﻟﻁﺭﺡ‬

SI register
The 16 – bit source index register is required for some string (character) operations. In this
context, the SI is associated with the DS register, The 80386and later processors support a 32 –
bit extended register, the ESI.
‫ ﻤﻊ‬SI ‫ ﻭﻓﻲ ﻫﺫﻩ ﺍﻟﺤﺎﻟﺔ ﻴﺭﺘﺒﻁ ﻤﺴﺠل‬.‫ ﺒﺕ ﻴﺴﺘﺨﺩﻡ ﻤﻊ ﺒﻌﺽ ﻋﻤﻠﻴﺎﺕ ﺍﻟﺴﻼﺴل ﺍﻟﺤﺭﻓﻴﺔ‬١٦ ‫ﺍﻥ ﻤﺴﺠل ﻓﻬﺭﺴﺔ ﺍﻟﻤﺼﺩﺭ ﺫﻭ‬

.ESI ‫ﺒﺕ ﻭﺒﺎﺴﻡ‬٣٢ ‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ ﺍﻟﺘﻲ ﺒﻌﺩﻩ ﺘﺩﻋﻡ ﺍﻟﻨﻭﻉ ﺍﻟﻤﻭﺴﻊ ﻤﻥ ﻫﺫ ﺍﻟﻤﺴﺠل ﻭﺒﻁﻭل‬80386 ‫ ﻭﻤﻌﺎﻟﺞ‬، DS ‫ﻤﺴﺠل‬

٢١
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
DI register
The 16 – bit destination index register is required for some string (character) operations. In this
context, the DI is associated with the ES register, The 80386and later processors support a 32 –
bit extended register, the EDI.
‫ ﻤﻊ‬DI ‫ ﻭﻓﻲ ﻫﺫﻩ ﺍﻟﺤﺎﻟﺔ ﻴﺭﺘﺒﻁ ﻤﺴﺠل‬.‫ ﺒﺕ ﻴﺴﺘﺨﺩﻡ ﻤﻊ ﺒﻌﺽ ﻋﻤﻠﻴﺎﺕ ﺍﻟﺴﻼﺴل ﺍﻟﺤﺭﻓﻴﺔ‬١٦ ‫ﺍﻥ ﻤﺴﺠل ﻓﻬﺭﺴﺔ ﺍﻟﻤﺴﺘﻘﺭﺫﻭ‬

.EDI ‫ﺒﺕ ﻭﺒﺎﺴﻡ‬٣٢ ‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ ﺍﻟﺘﻲ ﺒﻌﺩﻩ ﺘﺩﻋﻡ ﺍﻟﻨﻭﻉ ﺍﻟﻤﻭﺴﻊ ﻤﻥ ﻫﺫ ﺍﻟﻤﺴﺠل ﻭﺒﻁﻭل‬80386 ‫ ﻭﻤﻌﺎﻟﺞ‬، ES ‫ﻤﺴﺠل‬

Flags Register
Nine of the bits of the flags register are common to all 8086 – family processors to indicate the
current status of the computer and the results of processing. Many instructions involving
comparisons and arithmetic change the status of the flags, which some instructions may test to
determine subsequent action.
‫ ﻭﺍﻟﻜﺜﻴﺭ ﻤﻥ‬، ‫ ﻭﺍﻟﺘﻲ ﺘﺒﻴﻥ ﺍﻟﺤﺎﻟﺔ ﺍﻟﺤﺎﻟﻴﺔ ﻟﻠﻤﻌﺎﻟﺠﺔ‬8086 ‫ ﻫﻲ ﻤﺸﺘﺭﻜﺔ ﻟﻜل ﻋﺎﺌﻠﺔ ﻤﻌﺎﻟﺞ‬flags ‫ﺘﺴﻌﺔ ﻤﻥ ﺍﻟﺒﺘﺘﺎﺕ ﻟﻤﺴﺠل‬

‫ ﻭﺍﻟﻨﻭﻉ ﺍﻻﺨﺭ ﻴﺩﻗﻕ ﻗﻴﻤﺘﻬﺎ ﻟﻴﺤﺩﺩ ﻋﻠﻰ ﺍﺴﺎﺱ ﺍﻟﺘﺩﻗﻴﻕ ﺍﺠﺭﺍﺀ ﻋﻤﻠﻴﺔ‬flags ‫ﺍﻻﻴﻌﺎﺯﺍﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ ﻭﺍﻴﻌﺎﺯﺍﺕ ﺍﻟﻤﻘﺎﺭﻨﺔ ﺘﻐﻴﺭ ﺤﺎﻟﺔ‬

.‫ﻤﻌﻴﻨﺔ‬

The following briefly describes the common flag bits:


‫ﺴﻴﺘﻡ ﺸﺭﺡ ﻫﺫﻩ ﺍﻟﺒﺘﺎﺕ ﺍﻻﻥ‬

1. OF(overflow). Indicates overflow of a high – order (leftmost) bit following arithmetic, or


indicates a carry into and out of the high order (leftmost) sign bit following a signed arithmetic
operation . JO and JNO test this flag.
‫ﻴﺒﻴﻥ ﺤﺎﻟﺔ ﻭﺠﻭﺩ ﺒﺘﻴﻥ ﺍﻀﺎﻓﻴﻴﻥ ﺒﻌﺩ ﺍﺨﺭ ﺒﺕ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﺴﺎﺭ ﺍﻭ ﻭﺠﻭﺩ ﺒﺘﻴﻥ ﺍﻀﺎﻓﻴﻴﻴﻥ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﺴﺎﺭ ﺒﻌﺩ ﺒﺕ ﺍﻻﺸﺎﺭﺓ ﻓﻲ‬

.flag ‫ ﻴﺩﻗﻘﺎﻥ ﻫﺫﺍ‬JO and JNO ‫ ﻭﺍﻻﻴﻌﺎﺯﻴﻥ‬. ‫ﺤﺎﻟﺔ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ ﺒﺎﺭﻗﺎﻡ ﻤﻊ ﺍﺸﺎﺭﺍﺕ‬

2. DF(direction). Determine left or right direction for moving or comparing string (character)
data. When the flag is 0, the string operation performs left – to – right data transfer, when the
flag is 1, the string operation performs right – to – left data transfer.

٢٢
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫ﻴﺤﺩﺩ ﺍﺘﺠﺎﻩ ﺍﻟﻴﻤﻴﻥ ﺍﻭﺍﻟﻴﺴﺎﺭ ﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﻨﻘل ﺍﻭﺍﻟﻤﻘﺎﺭﻨﺔ ﻟﺒﻴﺎﻨﺎﺕ ﺴﻼﺴل ﺤﺭﻓﻴﺔ ‪ .‬ﻋﻨﺩﻤﺎ ﻴﻜﻭﻥ ﻗﻴﻤﺔ ‪ flag‬ﻫﻭ ﺼﻔﺭ‪ ،‬ﻓﺎﻥ ﻋﻤﻠﻴﺔ‬

‫ﺍﻟﺴﻠﺴﻠﺔ ﺍﻟﺤﺭﻓﻴﺔ ﺴﻭﻑ ﺘﻨﻘل ﺍﻟﺒﻴﺎﻨﺎﺕ ﻤﻥ ﺍﻟﻴﺴﺎﺭ ﺍﻟﻰ ﺍﻟﻴﻤﻴﻥ ‪ ،‬ﻋﻨﺩﻤﺎ ﻴﻜﻭﻥ ﻗﻴﻤﺔ ‪ flag‬ﻫﻭ ﻭﺍﺤﺩ‪ ،‬ﻓﺎﻥ ﻋﻤﻠﻴﺔ ﺍﻟﺴﻠﺴﻠﺔ ﺍﻟﺤﺭﻓﻴﺔ‬

‫ﺴﻭﻑ ﺘﻨﻘل ﺍﻟﺒﻴﺎﻨﺎﺕ ﻤﻥ ﺍﻟﻴﻤﻴﻥ ﺍﻟﻰ ﺍﻟﻴﺴﺎﺭ‪.‬‬

‫‪3. IF(interrupt). Indicates that all external interrupts, such as keyboard entry, are to be‬‬
‫‪processed or ignored. Which mean all interrupts are disables when 0, and enables when 1.‬‬
‫ﻴﺒﻴﻥ ﺍﻥ ﻜﺎﻨﺕ ﻜل ﻋﻤﻠﻴﺎﺕ ﺍﻟﻤﻘﺎﻁﻌﺔ ﺍﻟﺨﺎﺭﺠﻴﺔ ﻤﺜل ﺍﺩﺨﺎل ﻤﻥ ﻗﺒل ﻟﻭﺤﺔ ﺍﻟﻤﻔﺎﺘﻴﺢ ﺴﻭﻑ ﻴﺘﻡ ﺍﻟﺘﻌﺎﻤل ﻤﻌﻬﺎ ﺍﻭ ﺍﻫﻤﺎﻟﻬﺎ ‪ ،‬ﻭﻫﺫﺍ‬

‫ﻴﻌﻨﻲ ﻓﺎﻥ ﻜل ﺍﻟﻤﻘﺎﻁﻌﺎﺕ ﺴﻭﻑ ﻴﺘﻡ ﺍﻫﻤﺎﻟﻬﺎ ﻋﻨﺩﻤﺎ ﺘﻜﻭﻥ ﻗﻴﻤﺔ ﻫﺫﺍ ‪ flag‬ﺘﺴﺎﻭﻱ ﺼﻔﺭ‪ .‬ﻭﻋﻨﺩﻤﺎ ﺘﻜﻭﻥ ﻗﻴﻤﺔ ‪ flag‬ﺘﺴﺎﻭﻱ‬

‫ﻭﺍﺤﺩ ﻓﺎﻥ ﻜل ﺍﻟﻤﻘﺎﻁﻌﺎﺕ ﺴﻭﻑ ﻴﺘﻡ ﺍﻟﺘﻌﺎﻤل ﻤﻌﻬﺎ‪.‬‬

‫‪4. TF(trap). Permits operation of the processor in single – step mode. Debugger programs such‬‬
‫‪as DEBUG set the trap flag so that you can step through execution a single instruction at a time‬‬
‫‪to examine the effect on registers and memory.‬‬
‫ﺘﺴﻤﺢ ﺒﺘﺤﻭﻴل ﻋﻤل ﺍﻟﻤﻌﺎﻟﺞ ﺍﻟﻰ ﺤﺎﻟﺔ ﺍﻟﺨﻁﻭﺓ ﺍﻟﺨﻁﻭﺓ ‪ .‬ﻭﺒﺭﺍﻤﺞ ﺍﻟﺘﺼﺤﻴﺢ ﻤﺜل ﺒﺭﻨﺎﻤﺞ ‪ DEBUG‬ﻴﺤﻭل ﻗﻴﻤﺔ ﻫﺫﺍ ‪flag‬‬

‫ﺍﻟﻰ ﻭﺍﺤﺩ ﺤﻴﺙ ﻴﺴﻤﺢ ﺒﺘﺤﻭﻴل ﺘﻨﻔﻴﺫ ﺍﻟﺒﺭﻨﺎﻤﺞ ﻤﻥ ﺘﻨﻔﻴﺫ ﺒﺭﻨﺎﻤﺞ ﻤﺘﻜﺎﻤل ﺍﻟﻰ ﺘﻨﻔﻴﺫ ﺍﻴﻌﺎﺯ ﻭﺍﺤﺩ ﻓﻲ ﻜل ﻤﺭﺓ ﻭﺫﻟﻙ ﻟﻔﺤﺹ ﺘﺎﺜﻴﺭ‬

‫ﺘﻨﻔﻴﺫ ﺍﻻﻴﻌﺎﺯ ﻋﻠﻰ ﺍﻟﻤﺴﺠﻼﺕ ﻭﺍﻟﺫﺍﻜﺭﺓ‪.‬‬

‫= ‪5. SF(sign). Contains the resulting sign of an arithmetic operation (0 = positive and 1‬‬
‫‪negative) or ( the first bit from left from unsigned number). JG(Jump if Greater) and JL (Jump‬‬
‫‪if Less) test this flag.‬‬
‫ﻴﺤﺘﻭﻱ ﻫﺫﺍ ‪ flag‬ﻋﻠﻰ ﻗﻴﻤﺔ ﺍﻻﺸﺎﺭﺓ ﻟﻨﺎﺘﺞ ﻋﻤﻠﻴﺔ ﺭﻴﺎﻀﻴﺔ ﺤﻴﺙ ﻴﻤﺜل) ﺼﻔﺭ ﺍﻻﺸﺎﺭﺓ ﺍﻟﻤﻭﺠﺒﺔ ﻭﺍﻟﻭﺍﺤﺩ ﺘﻤﺜل ﺍﻻﺸﺎﺭﺓ ﺍﻟﺴﺎﻟﺒﺔ(‬

‫ﺍﻭ ﺍﻭل ﺒﺕ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﺴﺎﺭ ﻓﻲ ﺤﺎﻟﺔ ﻜﻭﻨﻬﺎ ﻋﻤﻠﻴﺔ ﺭﻴﺎﻀﻴﺔ ﻭﻟﻜﻥ ﻻﺭﻗﺎﻡ ﺒﺩﻭﻥ ﺍﺸﺎﺭﺍﺕ ‪ .‬ﻭﺘﺴﺘﺨﺩﻡ ﺍﻻﻴﻌﺎﺯﻴﻥ ‪ JG‬ﺍﻗﻔﺯ ﺍﺫﺍ‬

‫ﺍﻜﺒﺭ ﻭ ‪ JL‬ﺍﻗﻔﺯ ﺍﺫﺍ ﺍﻗل ﻟﺘﺩﻗﻴﻕ ‪.flag‬‬

‫= ‪6. ZF (zero). Indicates the result of an arithmetic or comparison operation (0 = nonzero and 1‬‬
‫‪zero result ). JE ( Jump if Equal) and JZ( Jump if Zero) test this flag.‬‬

‫‪٢٣‬‬
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
‫ ﻫﻭ ﺼﻔﺭ ﻋﻨﺩﻤﺎ‬flag ‫ ﻭﺘﺼﺒﺢ ﻗﻴﻤﺔ‬.‫ ﻫﻭ ﻭﺍﺤﺩ‬flag ‫ﻴﺒﻴﻥ ﺍﻥ ﻜﺎﻥ ﺍﻟﻨﺎﺘﺞ ﻟﻌﻤﻠﻴﺔ ﺭﻴﺎﻀﻴﺔ ﺍﻭ ﻤﻘﺎﺭﻨﺔ ﻫﻭ ﺼﻔﺭ ﻓﺘﺼﺒﺢ ﻗﻴﻤﺔ‬

‫ ﺍﻗﻔﺯ ﺍﺫﺍ ﻜﺎﻥ ﻫﻨﺎﻙ ﺼﻔﺭ ﺘﺩﻗﻕ‬JZ ‫ ﺍﻗﻔﺯ ﺍﺫﺍ ﻜﺎﻥ ﻫﻨﺎﻙ ﺘﺴﺎﻭﻱ ﻭ‬JE ‫ ﻭﺍﻻﻴﻌﺎﺯﻴﻥ‬، ‫ﻴﻜﻭﻥ ﻗﻴﻤﺔ ﺍﻟﻨﺎﺘﺞ ﺍﻱ ﻋﺩﺩ ﻏﻴﺭ ﺍﻟﺼﻔﺭ‬

.flag ‫ﻫﺫﺍ‬

7. AF( auxiliary carry). Contains a carry out of bit 3 on 8 – bit data, for specialized arithmetic.
It concerned with arithmetic on ASCII and BCD packed fields.
‫ ﺒﺘﺎﺕ‬٨ ‫ ﺨﻼل ﻋﻤﻠﻴﺔ ﺭﻴﺎﻀﻴﺔ ﻟﺒﻴﺎﻨﺎﺕ ﺒﻁﻭل‬bit 3 ‫ ﻤﻥ ﺍﻭل ﺍﺭﺒﻊ ﺒﺘﺎﺕ ﻤﻥ‬carry ‫ ﺍﻟﺫﻱ ﻴﻭﻟﺩ ﻋﻨﺩﻤﺎ ﻴﻌﺒﺭ‬carry ‫ﺘﺎﺨﺫ ﻗﻴﻤﺔ‬

.BCD ‫ ﻭ‬ASCII ‫ﻭﻀﻤﻥ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ ﺍﻟﺨﺎﺼﺔ ﻭﻫﻲ ﻤﺨﺘﺼﺔ ﺒﺎﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺘﻲ ﺘﺠﺭﻯ ﻋﻠﻰ‬

8. PF (parity).Indicates even or odd parity of a low – order ( rightmost) 8 – bit data operation.
JPO( Jump if parity Odd) and JPE(Jump if parity Even) test this flag.
‫ ﺍﻗﻔﺯ ﺍﺫﺍ ﻜﺎﻥ‬JPO ‫ ﻭﺍﻻﻴﻌﺎﺯﻴﻥ‬. ‫ ﺒﺘﺎﺕ ﻭﻓﻘﻁ ﻟﻠﺠﻬﺔ ﺍﻟﻴﻤﻨﻰ‬٨ ‫ ﻟﻌﻤﻠﻴﺎﺕ ﺭﻴﺎﻀﻴﺔ ﻤﻥ‬even or odd parity ‫ﻴﺒﻴﻥ ﺤﺎﻟﺔ‬

.flag ‫ ﻫﻭ ﺯﻭﺠﻲ ﻴﺩﻗﻕ ﻫﺫﺍ‬parity ‫ ﺍﻗﻔﺯ ﺍﺫﺍ ﻜﺎﻥ‬JPE ‫ ﻫﻭ ﻓﺭﺩﻱ ﻭ‬parity

9. CF (carry). Contains carries from a high – order (leftmost) bit following an arithmetic
operation; also, contains the contents of the last bit of a shift or rotate operation. JC and JNC
test this flag.
‫ﻫﻲ ﺤﺎﻟﺔ ﺍﻟﺒﺕ ﺍﻻﻀﺎﻓﻲ ﺒﻌﺩ ﺍﺨﺭ ﺒﺕ ﻤﻥ ﺠﻬﺔ ﺍﻟﻴﺴﺎﺭ ﺍﻭ ﺍﻟﺒﺕ ﺍﻟﻨـﺎﺘﺞ ﻤﻥ ﻋﻤﻠﻴﺔ ﺘﺯﺤـﻴـﻑ ﺍﻭ ﺩﻭﺭﺍﻥ ﻭﺍﻻﻴﻌــﺎﺯﻴﻥ‬

.flag ‫ ﺘﺩﻗﻕ ﻫﺫﺍ‬JC and JNC

The flags are in the flags register in the following locations ( which you need memorize):

Flag O D I T S Z A P C

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Bit no.

The flags most relevant to assembly programming are OF, SF, ZF, CF for comparison and
arithmetic operations, and DF for the direction of string operations. The 80286 and later
processors have some flags used for internal purposes, concerned primarily with protected

٢٤
‫ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ‬ ‫ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ‬ ‫ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ‬
mode. The 80386 and later processors have a 32 – bit extended flags register known as
Eflags.
‫ ﻭ‬، ‫ ﻭﺍﻟﺘﻲ ﺘﺴﺘﺨﺩﻡ ﻓﻲ ﺍﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺭﻴﺎﻀﻴﺔ ﻭﻋﻤﻠﻴﺎﺕ ﺍﻟﻤﻘﺎﺭﻨﺔ‬OF, SF, ZF, CF ‫ ﺍﻟﻤﺴﺘﺨﺩﻤﺔ ﻫﻲ‬flags ‫ﺍﻥ ﺍﻻﻜﺜﺭ‬

‫ ﻓﻤﺎ‬80286 ‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ‬، ‫ ﻴﺴﺘﺨﺩﻡ ﻟﺘﺤﺩﻴﺩ ﺍﻻﺘﺠﺎﻫﺎﺕ ﻓﻲ ﻋﻤﻠﻴﺎﺕ ﺍﻟﺘﻌﺎﻤل ﻤﻊ ﺍﻟﺴﻼﺴل ﺍﻟﺤﺭﻓﻴﺔ‬DF flag ‫ﻜﺫﻟﻙ ﻓﺎﻥ‬

80386 ‫ ﻭﺍﻟﻤﻌﺎﻟﺠﺎﺕ‬، protected ‫ ﻭﺨﺎﺼﺔ ﻋﻨﺩﻤﺎ ﺘﻌﻤل ﻓﻲ ﺤﺎﻟﺔ‬، ‫ ﺘﺴﺘﺨﺩﻡ ﻓﻲ ﺍﻏﺭﺍﺽ ﺩﺍﺨﻠﻴﺔ‬flags ‫ﺒﻌﺩﻫﺎ ﺘﻤﺘﻠﻙ‬

.Eflags ‫ ﻭﺒﺎﺴﻡ‬32-bit ‫ ﺍﻟﻤﻭﺴﻊ ﻭﺒﻁﻭل‬flag ‫ﻓﻤﺎ ﺒﻌﺩﻫﺎ ﻤﺴﺠل‬

Question Show the effect of below operations on these flags DF,IF,TF,SF,CF,SF,AC,ZF,PF


1. an arithmetic operation as add AH+BH and store result in AL with these numbers
4E
8A +

2. a program deal with four subroutine one of them is Arabic program for bank customer.
SOL:
1. 1
4E 0100 1110
8A 1000 1010 +
1101 1000
DF , IF , TF not effected
ZF=0
SF=1
CF=0
AC=1
PF=1
2. ZF,SF,CF,AC,PF not effected
DF=1
IF=1
TF=0

٢٥

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy