Lecture2 Logical and Physical Addressing 2
Lecture2 Logical and Physical Addressing 2
Logical Addressing
8086Mp has a 1 MByte memory locations; each size of each location is 8-bits. In order to
reach any location in this memory, we need to know the logical address of that location.
8086Mp memory is logically divided into segments. The size of each segment is 64 Kbyte.
A programmer can reach the 8086Mp memory only by using logical addressing. Logical
Address is written as follows: (Segment : Offset)
The segment part of the address is fixed for all the memory locations that are in this segment
(which is 1000 H in the below example), while the offset value changes from 0000 H to FFFF
H for each segment.
Offset is like a pointer that points to a specific location inside the segment.
The segment value can only be stored in one of the segment registers while the offset is stored
in one of the offset registers associated with that segment (go back to the segment-offset
combinations table given in the previous lecture).
ٙركٌٕ انؼُٕاٌ انًُطمٚ .حٛرؼايم يؼ ٓا اال يٍ خالل انؼَُٕح انًُطمٚٔ صم انٗ ا٘ يٕلغ يٍ انزاكشجٚ ًٌكٍ نهًثشيج اٚال
داخم ْزاٙؤشش انٗ يٕلغ يذذد فٚ ً٘ح انًؤشش انزٛذًم لٚ َٙ ) ٔانثاSegment(ذًم ػُٕاٌ انـٚ االٔل,ًٍٛيٍ لغ
ًحٛذرٕ٘ لٚ ٘كٌٕ طٕل انغجم انزٚ ٌرطهة اٚ يٍ انًٕالغ ٔرنك64 Kbyte ٗذرٕ٘ ػهٚ Segment كم.Segmentانـ
.ً الدماٙأذٛ) كًا عCS, DS, ES, SS( ادذ انغجالخ االستؼحٙ فsegmentًح انـٛرى خضٌ لٚ .16-bit ٘ٔغاٚ segmentانـ
ًحٛ فارا كاَد ل.ُّخش يٕلغ يٜ )FFFF H( ٗ انsegment) الٔل يٕلغ يٍ انـ0000 H( ٍ ذرشأح يًٙٓح انًؤشش فٛأيا ل
ٌ) ٔانؼُٕا6A00 H : 0000 H( ْٕ segment الٔل يٕلغ يٍ انـٙ فإٌ انؼُٕاٌ انًُطم6A00 H ً ذغأ٘ يثالsegmentانـ
.)6A00 H : FFFF H( ْٕ segment الخش يٕلغ يٍ انـٙانًُطم
ٙ (الٌ انذجى انكه64 Kbyte ٌٕكٚ انٕادذsegment فًؼُاِ اٌ دجى انـ16-bit ٘ٔغاٚ ّ( طٕنoffset) تًا أٌ انًؤشش
.)64Kbyte ٘ٔغاٚ ْٕٔ 61 نألط2 ْٕ تد61 ًكٍ ػَُٕرّ تاعرخذاوٚ ٘انز
حٍٛ انًُطمٚٔش انؼُاٛ ٔلذ ذى ذأش,)ٕظخ يمطؼا ً يٍ انزاكشج (انًذذد تانهٌٕ االصسق انفاذخٚ ٙ انشعى انرانٙانًثال انًؼطٗ ف
داخم يٕلغ انزاكشجٙكرة فٚ غاس أيا ياٍٛ أٔ انًٛٛ انٗ جاَة انزاكشج ػهٗ انٙائٚضٛ أ انفٙرى كراتح انؼُٕاٌ عٕا ًء انًُطمٚ .ّٛػه
.8-bits ّكٌٕ طٕنٚٔ ً ظ ػُٕاَاٛ) ٔنdataؼرثش يذرٕٖ انًٕلغ (أ٘ انـٛف
ٙ االعفم ٔاخش يٕلغ يُٓا ْٕ انًٕجٕد فٙ ػُذ سعى انزاكشج َمٕو تاػرثاس أل يٕلغ يُٓا ْٕ انًٕجٕد ف: 1مالحظة
ػهًا ً اٌ تؼط انًصادس. انًذاظشج انغاتمحٙ انًؼطٗ ف6 سلىٙ انكراب انًُٓجٙمح انًغرخذيح فٚ يغ انطشٙ ٔرنك نهًش.ٗاالػه
.ذغرخذو ػكظ رنك
ّؼشفٚ فرشض اٌ انطانةٚ ٘ ٔانز,حٛائٚضٛح ٔانفٍٛ انًُطمٚٔ كرات ح انؼُاٙرى اعرخذاو انُظاو انغادط ػشش فٚ :2 مالحظة
.ذٛتشكم ج
ٗرى انرطشق انٚ ٌجادِ تؼذ اٚح اٛفٛفٓى كٛش نهزاكشج تشكم ػالياخ اعرفٓاو الٌ انطانة عٛ ذى كراتح انًٕلغ االخ:3 مالحظة
.حٛائٚضٛانؼَُٕح انف
8-bits
?H:?H
...
1000 H : FFFF H
...
1000 H : F000 H
64 Kbyte Segment
Logical Addresses
1000 H : 0000 H
0000 H : 0000 H
Physical Addressing (PA): (Some references call it: effective address (EA))
In order to access any location in the 1 Mbyte memory, the Mp must generate a 20-bit
memory address, which is called a Physical Address (PA). Physical address is calculated from
the logical address as follows:
where multiplying the segment by 16 is simply achieved by shifting it to the left and adding a
zero to the lower digit.
1 ْٕ ٍٙ تد (الٌ دجى انزاكشج انكهٚركٌٕ يٍ سلى طٕنّ ػششٚ ٘ ٔانزٙمٛ ْٕ انؼُٕاٌ انذمٙائٚضٛانؼُٕاٌ انف
ٔرنك تاظافح صفش,ٙ انًطهٕب انرؼايم يؼّ يٍ خالل انؼُٕاٌ انًُطمٙائٚضٛمٕو انًؼانج تذغاب انؼُٕاٌ انفٚٔ .)MByte
ٕ٘ذرٚ فانًفشٔض اٌ َذصم ػهٗ سلى.offset ًح انًؤششٛ) ثى انجًغ يغ ل61 ٙؼادل ظشب فٚ ٘ (ٔانزsegmentانٗ انـ
) الٔل00000 H( ٍٛ تٙائٚضًٛح انؼُٕاٌ انفٛ) ٔذرشأح ل1 hexa digit (الٌ كم استؼح تد ذًثم5 hexa digits ٗػه
.) الخش ػُٕاٌ يُٓاFFFFF H) ٗ ان,ػُٕاٌ يٍ انزاكشج
Solution:
The logical address of the next location is stored in (CS: IP), so that DS and ES will not be
required to calculate the PA of the next instruction.
َالدظ.)CS: IP( ٙ انؼُٕاٌ انًُطمٙزِ فٛمٕو ترُفٛ انز٘ عٙؼاص انرانٚز ا٘ تشَايج تخضٌ ػُٕاٌ االٛمٕو انًؼانج ػُذ ذُفٚ
. يؼطاج نغشض انرأكذ يٍ فٓى انطانة نهًٕظٕعْٙٔ انذمٙش داخهح فٛ انغؤال غٙى انغجالخ االخشٖ انًٕجٕدج فٛأٌ ل
PA= 1 0 0 0 0
2000 +
12000H
Example: If a segment register value is (2100H), what are the starting and ending physical
addresses of this segment?
Solution:
- For the starting address, the offset value is (0000 H), so PA is:
PA= 2 1 0 0 0
0000 +
21000H
- For the ending address, the offset value is (FFFF H), so PA is:
PA= 2 1 0 0 0
FFFF +
30FFFH
Example: If SS =A022 H, DI =F019 H, BP =2E60 H, IP =1111 H, find the PA of the stack.
Solution:
The stack is addressed using the logical address (SS: BP) or (SS: SP). The value of SP is not
given in the question, so that BP is used, so PA is:
َؼهى, انًذاظشج انغاتمحٙ ٔيٍ خالل انشجٕع انٗ انجذٔل انًؼطٗ فSS انـٙ يخضٌٔ فstack انخاص تانـsegment انـ
.BP انغؤال فُغرخذوٙش يؼطاج فٛ غSP ًحٛ ٔتًا اٌ ل. فمطBP ٔ SP ْٙ ّتاٌ انًؤششاخ انًغرخذيح يؼ
PA= A 0 2 2 0
2E60 +
A3080H
Example: Find a logical address that can take you to the location (255AF H) of the memory.
Solution: There are many logical addresses that lead to the given PA:
ذُٚا ً أ٘ أٌ ُْانك انؼذٛغأ٘ سلًا ً يؼٚ ٍ داصم جًؼًٓاًٛجاد سلٚ يشاتٓح الْٙ ٙائٚضٛ يٍ انفٙجاد انؼُٕاٌ انًُطمٚح اٛػًه
ٔجًؼّ يغsegment يٍ خالل ٔظغ صفش انٗ ػُٕاٌ انـٙ انؼُٕاٌ انًُطمٍٙ فًٛجة انرأكذ يٍ صذح انشلٚ ٍ ٔنك,يٍ انذهٕل
.ٗ انًؼطٙائٚضٛطاتك انؼُٕاٌ انفٚ ٌجة اٚ ٘ انزٙائٚضٛ ف ُذصم ػُذْا ػهٗ انؼُٕاٌ انفoffsetانـ
255A H: 000F H
or
2000 H: 55AF H
or
2500 H: 05AF H
(and many other combinations)
Best Regards
Dr. Zainab Alomari