[go: up one dir, main page]

0% found this document useful (0 votes)
16 views12 pages

Assembly Language Basics

The document discusses addressing modes in the 8086 microprocessor, focusing on the MOV instruction which transfers data between registers and memory. It outlines three addressing modes: Register Addressing Mode, Immediate Addressing Mode, and Direct Addressing Mode, detailing their usage and restrictions. Examples illustrate how to use these modes effectively, emphasizing that the source value remains unchanged after the operation.

Uploaded by

harithbashar
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)
16 views12 pages

Assembly Language Basics

The document discusses addressing modes in the 8086 microprocessor, focusing on the MOV instruction which transfers data between registers and memory. It outlines three addressing modes: Register Addressing Mode, Immediate Addressing Mode, and Direct Addressing Mode, detailing their usage and restrictions. Examples illustrate how to use these modes effectively, emphasizing that the source value remains unchanged after the operation.

Uploaded by

harithbashar
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/ 12

Lecture 3: Addressing Modes

8086Mp has a group of instructions that are used by the programmer to specify the task
required to be done by the Mp. The language used for programming 8086Mp is called (Assembly
Language).

(MOV) instruction is the most used 8086Mp instruction, and it is used as follows:

MOV AX, BX
In this example: Source
Destination

- AX is the destination
- BX is the source
- The value of BX will be moved (copied) to AX
- The old value of AX will be removed and now AX=BX
- BX will not be changed

In all instructions:

- The source and destination MUST have the same length.


- The destination is called so because the result of the operation performed by the
instruction is always stored in the destination.
- The source is NOT changed by the instruction.

‫كٌٕ رنك يٍ خالل‬ٚٔ ,)‫اذٓا خالل انفصم األٔل‬ٛ‫رى ذؼهى اعاع‬ٛ‫ ع‬ٙ‫رى انرؼايم يغ انًؼانح يٍ خالل انهغح انخاصح تّ (ٔانر‬ٚ
.‫اخ يرُٕػح‬ٛ‫او تؼًه‬ٛ‫ًكٍ اعرخذايٓا نهق‬ٚ ٙ‫انُظش انٗ انًؼانح ػهٗ ا َّ يدًٕػح يٍ انغدالخ انر‬

‫رى‬ٛ‫ ٔع‬.)destination(‫) انٗ انـ‬source(‫ًح انـ‬ٛ‫ؼاص َقم أ َغخ ق‬ٚ‫) ْٕٔ ا‬MOV( ْٕ ً ‫ؼاص االتغظ ٔاالكثش اعرخذايا‬ٚ‫اال‬
.)Addressing Modes( ‫ؼاص نششذ االَٕاع انًخرهفح يٍ انؼَُٕح‬ٚ‫اعرخذاو ْزا اال‬

Addressing Modes
1) Register Addressing Mode

‫كَٕا تُفظ انطٕل‬ٚ ٌ‫دة ا‬ٚٔ )register( ‫) ػثاسج ػٍ عدم‬destination(‫) ٔانـ‬source(‫كٌٕ كم يٍ انـ‬ٚ ‫ ْزا انُٕع‬ٙ‫ف‬
.)‫تد‬66 ‫تد أٔ كالًْا‬8 ‫(ئيا كالًْا‬

MOV Register, Register


.‫ؼاصاخ‬ٚ‫ يدًٕػح يٍ االيثهح ػهٗ ْزا انُٕع يٍ اال‬ٙ‫ اندذٔل انران‬ٙ‫ف‬
‫ُْانك زاالخ ‪ًُٚ‬غ اعرخذايٓا ْٔ‪ ٙ‬انساالخ انران‪ٛ‬ح‪:‬‬

‫‪ -6‬أٌ ‪ٚ‬كٌٕ طٕل انـ(‪ٔ )source‬انـ(‪ )destination‬غ‪ٛ‬ش يرغا ٍٔ‪( ,‬كًا ف‪ ٙ‬انًثال قثم االخ‪ٛ‬ش يٍ اندذٔل انغاتق)‪.‬‬
‫‪ -2‬أٌ ‪ٚ‬كٌٕ كال انغده‪( ٍٛ‬أ٘ كم يٍ انـ(‪ٔ )source‬انـ(‪ ْٕ ))destination‬يٍ انـ(‪ )segment registers‬االستؼح‬
‫ْٔ‪( )CS, DS, ES, SS( ٙ‬كًا ف‪ ٙ‬انًثال ‪ 8‬يٍ اندذٔل انغاتق )‪ٔ ,‬انغثة أَٓا عدالخ خاصح ٔاعرخذايٓا ف‪ٙ‬‬
‫اال‪ٚ‬ؼاصاخ ‪ٚ‬كٌٕ تشكم يسذٔد فقظ‪ .‬أيا ارا كاٌ أزذ انغده‪ ٍٛ‬فقظ ْٕ يٍ انـ(‪ )segment registers‬فٓزا يًكٍ يا ػذا‬
‫زانح ٔازذج ْٔ‪ ٙ‬أٌ ‪ٚ‬كٌٕ انـ‪ ْٕ CS‬انـ(‪ )destination‬فٓزا ال ‪ٚ‬دٕص (كًا ف‪ ٙ‬انًثال األخ‪ٛ‬ش يٍ اندذٔل انغاتق)‬
‫ٔانغثة أَّ ‪ٚ‬سرٕ٘ ق‪ًٛ‬ح يًٓح ذًثم ػُٕاٌ انـ‪ segment‬انز٘ ‪ٚ‬سرٕ٘ ػهٗ اال‪ٚ‬ؼاصاخ ف‪ ٙ‬انزاكشج ٔف‪ ٙ‬زانح ذغ‪ٛٛ‬ش‬
‫ق‪ًٛ‬رّ ‪ٚ‬رى فقذاٌ انثشايح‪.‬‬

‫مالحظة‪ :‬خً‪ٛ‬غ انغدالخ ال‪ًٚ‬كٍ ذدضئرٓا ف‪ ٙ‬اال‪ٚ‬ؼاصاخ ٔاًَا ‪ٚ‬رى انرؼايم يؼٓا ػهٗ آَا ‪66‬تد دائًاً‪ ,‬يا ػذا ( ‪AX, BX,‬‬
‫‪ )CX, DX‬ز‪ٛ‬ث ‪ًٚ‬كٍ ذدضئح كم يُٓى انٗ خضئ‪ ٍٛ‬يٍ ‪8‬تد (‪.)AL, AH, BL, BH, CL, CH, DL, DH‬‬

‫‪2) Immediate Addressing Mode‬‬

‫‪MOV Register , NUMBER‬‬

‫ال ٔ‪ٚ‬كٌٕ تُفظ طٕل انـ(‪ )destination‬ئيا ‪8‬تد أٔ ‪66‬تد‪ٚٔ .‬ؼطٗ‬ ‫ف‪ْ ٙ‬زا انُٕع ‪ٚ‬كٌٕ انـ(‪ )source‬سقًا ً ٔن‪ٛ‬ظ عد ً‬
‫انشقى ئيا تانُظاو انغادط ػشش٘ (‪ٔ )Hexadecimal‬رنك تأٌ ‪ٚ‬كرة ف‪ ٙ‬آخشِ انسشف ‪( H‬كًا ف‪ ٙ‬انًثال ‪ 2‬يٍ اندذٔل ادَاِ)‪,‬‬
‫أٔ تانُظاو انثُائ‪ٔ )Binary( ٙ‬رنك تاٌ ‪ٚ‬كرة ف‪ ٙ‬آخشِ انسشف ‪( B‬كًا ف‪ ٙ‬انًثال األخ‪ٛ‬ش يٍ اندذٔل ادَاِ)‪ ,‬أٔ تانُظاو انؼشش٘‬
‫(‪ٔ )decimal‬رنك تاٌ ال ‪ٚ‬كرة ف‪ ٙ‬آخشِ ا٘ ش‪ٙ‬ء (كًا ف‪ ٙ‬األيثهح ‪ 4ٔ 3ٔ 6‬يٍ اندذٔل ادَاِ)‪ .‬أيا ارا كاٌ سيضا ً ٔن‪ٛ‬ظ سقًا ً‬
‫ف‪ٛ‬رى ٔضؼّ داخم ػالير‪ُْٔ (‘ ‘) ٙ‬ا ‪ٚ‬رى اخز ق‪ًٛ‬ح انـ(‪ ) ASCII‬انخاصح تٓزا انشيض (ْٔ‪ ٙ‬ػثاسج ػٍ سقى طٕنّ ‪8‬تد ‪ٚ‬قاتم‬
‫انشيض انًؼطٗ ت‪ ٍٛ‬ػالير‪ ٙ‬االقرثاط) ٔ‪ٚ‬رى اػطاؤِ نهـ‪ٔ destination‬انز٘ ‪ٚ‬دة اٌ ‪ٚ‬كٌٕ عدالً تطٕل ‪8‬تد (كًا ف‪ ٙ‬انًثال ‪5‬‬
‫يٍ اندذٔل ادَاِ)‪ٔ .‬ارا ذى ٔضغ سيض‪ ٍٚ‬داخم ػالير‪ ٙ‬االقرثاط يؼُاِ ع‪ٛ‬رى أخز ‪66‬تد (‪8‬تد نكم سيض) ٔٔضؼٓا ف‪ٙ‬‬
‫انـ‪ destination‬انز٘ ‪ٚ‬دة اٌ ‪ٚ‬كٌٕ عدالً تطٕل ‪66‬تد (كًا ف‪ ٙ‬انًثال ‪ 6‬يٍ اندذٔل أدَاِ)‪.‬‬
Examples: MOV AL, 15H (AL=15H)

MOV BX, 6F0AH (BX=6F0AH) or (BL=0AH and BH=6FH)

MOV CX, 1 H (CX=1H) or (CL=01H and CH=00H)

MOV 1FH, AL

MOV 47H, DH NOT ALLOWED  (Destination CAN NOT be a number!)

MOV 55, DX

‫ ٔكزنك انسال ارا‬.‫ح‬ٛ‫ش يُطق‬ٛ‫ح غ‬ٛ‫ ػًه‬ٙٓ‫ ف‬,ّٛ‫ح انُقم ذرى ان‬ٛ‫ سقًا ً الٌ ػًه‬destination‫كٌٕ انـ‬ٚ ٌ‫ًكٍ ا‬ٚ ‫َالزظ أَّ ال‬
.‫دٕص‬ٚ ‫ضا ً ال‬ٚ‫ ػثاسج ػٍ اسقاو فٓزا ا‬destination‫ ٔانـ‬source‫كاٌ كم يٍ انـ‬

MOV DS, 100H NOT ALLOWED 


It is NOT allowed to use immediate addressing mode with segment registers (CS, DS, ES,
SS). In order to put 100H in DS, we can do the following:

MOV AX, 100H

MOV DS, AX ALLOWED 


ٖ‫ ٔاًَا َقٕو تاعرخذاو ازذ انغدالخ االخش‬,‫ االستؼح‬segment registers‫ؼاصاخ يغ انـ‬ٚ‫ًكٍ اعرخذاو ْزا انُٕع يٍ اال‬ٚ ‫ال‬
‫ش‬ٛٛ‫ًكٍ اعرخذايٓا نرغ‬ٚ ‫قح‬ٚ‫) ْٔزِ انطش‬register addressing mode( ‫ًح تاعرخذاو انـُٕع االٔل‬ٛ‫ نُقم انق‬ٙ‫كًخضٌ ٔعط‬
.ً‫ كًا ركش عاتقا‬CS‫ يا ػذا انـ‬segment registers‫ًح ا٘ يٍ انـ‬ٛ‫ق‬

3) Direct Addressing Mode

MOV destination , [ NUMBER ]

MOV [ NUMBER ], source


‫رى اعرخذاو اقٕاط يشتؼح نهٕصٕل‬ٚ ‫ث‬ٛ‫ ز‬,destination‫ أٔ كـ‬source‫رى انرؼايم يغ انزاكشج ٔاعرخذايٓا كـ‬ٚ ‫ ْزا انُٕع‬ٙ‫ف‬
.‫غاػذَا ػهٗ انٕصٕل انٗ انؼُٕاٌ انًطهٕب‬ٛ‫ٍ ْزِ االقٕاط ن‬ٛ‫رى ٔضغ سقى يات‬ٚٔ ‫انٗ انزاكشج‬

Example 1:

MOV AL , [1234H]

In this example, an 8-bit value is taken from a memory location and copied to AL.

How can the Mp calculate the physical address and go to the correct memory location? The
physical address is calculated from (segment : offset). The number given in the instruction
inside square brackets is the offset. When the offset is a number, then the segment is always DS.
The Mp will take the offset from the instruction which is 1234H and adds it with DS value after
multiplying DS by 16 to find the physical
. address. Let DS=1000H, then:
.
.
66H 1000H:1235H

5FH 1000H:1234H
AL B0H 1000H:1233H
.
.
.

(After execution: AL=5FH)

:‫ّ يٍ انزاكشج‬ٛ‫ انًطهٕب انزْاب ان‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح زغاب انؼُٕاٌ انف‬ٛ‫ف‬ٛ‫ك‬

ٙ‫ كًا ف‬,66 ٙ‫ تؼذ ضشتّ ف‬DS‫ًح انـ‬ٛ‫ ثى ذدًغ يغ ق‬offset‫ث ذًثم انـ‬ٛ‫ٍ االقٕاط انًشتؼح ز‬ٛ‫ًح انًٕخٕدج ت‬ٛ‫رى اعرخذاو انق‬ٚ
.‫انًثال انغاتق‬

Example 2:

MOV AX, [51FFH]

In this example, 16-bits will be moved from the memory to AX. The memory PA will be
calculated in the same way as in example 1. This time two bytes are required to be copied from
the memory to AX, so that: the first byte (lower byte) of AX (which is AL) will be taken from
the specified memory location and the second byte (higher byte) of AX (which is AH) will be
taken from the next memory location. Let DS=2000H, then:
.
.
.

D9H 2000H:5200H
AH 33H 2000H:51FFH
AL 1FH 2000H:51FEH
.
.
.

After execution: AX=D933H.

.‫ انغإال‬ٙ‫ يدشد يثال ٔذؼطٗ ف‬ْٙ ‫ انزاكشج ُْا‬ٙ‫ى انًخضَٔح ف‬ٛ‫ انق‬:‫مالحظة‬

Note: in the two previous examples, the memory location was the source so that it is not
changed; only the destination is changed.

Example 3:

MOV [13A9H], DX

In this example, two bytes will be copied from DX to the memory location at offset=13A9H
in DS. Let DS=4000H and DX=8F10H, then:

.
.
.
4000H:13ABH
DH
8FH 4000H:13AAH
DL
10H 4000H:13A9H
.
.
.

(after execution DX is not changed, only two memory locations are changed)

MOV [4F00H], [651BH] NOT ALLOWED (memory to memory is not allowed) 


MOV [3A88H], 5H This is allowed BUT: the length of the moved data is not clear (16-bit or
8-bits), therefore we need to specify this length using either (byte ptr) or (word ptr), as follows:

MOV byte ptr[3A88H], 5H One memory location at DS:3A88H will be given the value 05H

MOV word ptr[3A88H],5H Two memory locations will be changed as follows:

DS:3A88H will be given the value (05H)

DS:3A89H will be given the value (00H)

MOV 5H, [3A88H] NOT ALLOWED (destination can NOT be a number) 

MOV DS, [3000H] NOT ALLOWED (segment registers can NOT be used with memory) 

4) Indirect Addressing Mode

‫ نًٕقغ انزاكشج‬offset‫ًرّ ذًثم انـ‬ٛ‫) ق‬register( ‫ظ تشكم سقى ٔاًَا تشكم عدم‬ٛ‫ ن‬offset‫رى اػطاء انـ‬ٚ ‫ ْزا انُٕع‬ٙ‫ف‬
.‫ٍ اقٕاط يشتؼح‬ٛ‫ٕضغ ْزا انغدم ت‬ٚ ‫ث‬ٛ‫ ز‬,‫انًطهٕب‬

MOV Destination, [Register ]

MOV [Register ], Source

Examples: MOV AX, [BX]


MOV [DI], AL
MOV [BP], BX
MOV DX, [SI]
)segment-offset combinations(‫ خذٔل انـ‬ٙ‫ يٕخٕدج ف‬ْٙٔ offset‫ًكٍ اٌ ذغرخذو كـ‬ٚ ‫ُْانك عدالخ يسذدج‬
ّ‫ًكٍ اعرخذاي‬ٛ‫) ف‬SP( ‫ أيا‬,)BP, BX, SI, DI( ْٙ ‫ ٔزغة ْزا اندذٔل فاٌ ْزِ انغدالخ‬.ٗ‫ انًساضشج االٔن‬ٙ‫انًؼطٗ ف‬
‫ؼاصاخ التشكم عدم ٔالتشكم‬ٚ‫ اال‬ٙ‫ًكٍ اعرخذايّ تشكم يثاشش يطهقا ً ف‬ٚ‫ ال‬IP‫ ٔعدم انـ‬,‫ظ كًإشش انٗ انزاكشج‬ٛ‫كغدم فقظ ٔن‬
.‫يإشش‬

‫ يإشش‬ْٙٔ ‫ح‬َٛ‫ح ثا‬ًٛ‫ أٔ ُْانك ذغ‬offset‫ّ اعى انـ‬ٛ‫طهق ػه‬ٚ ‫ش ػهٗ انزاكشج‬ٛ‫ نهرأش‬register ‫ ػُذ اعرخذاو انغدم‬:‫مالحظة‬
.)pointer(

:‫ّ يٍ انزاكشج‬ٛ‫ انًطهٕب انزْاب ان‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح زغاب انؼُٕاٌ انف‬ٛ‫ف‬ٛ‫ك‬

‫ تؼذ‬segment‫ًح انـ‬ٛ‫ ثى ذدًغ يغ ق‬offset‫ث ذًثم انـ‬ٛ‫ٍ االقٕاط انًشتؼح ز‬ٛ‫ًح انغدم انًٕخٕد ت‬ٛ‫رى اعرخذاو ق‬ٚ
ٙ‫) انًؼطٗ ف‬segment-offset combinations(‫ يٍ خالل انشخٕع انٗ خذٔل انـ‬segment‫رى يؼشفح انـ‬ٚ .66 ٙ‫ضشتّ ف‬
‫ ٔارا كاٌ انًإشش انًغرخذو‬DS ْٕ segment‫كٌٕ انـ‬ٛ‫ فغ‬DI ٔ‫ أ‬SI ٔ‫ أ‬BX ْٕ ‫ فارا كاٌ انًإشش انًغرخذو‬,ٗ‫انًساضشج االٔن‬
.SS ْٕ segment‫كٌٕ انـ‬ٛ‫ فغ‬BP ْٕ
Example: Let BX=1000H, DS=100H. Find the value of AX after executing the following
instruction (note that the memory is given in the question): MOV AX, [BX]
.
.
.
77H 02003H

A7H 02002H

34H 02001H

12H 02000H
.
.
.

Solution: the Physical Address = DS * 16 + BX

PA = 0 1 0 0 0

1000 +

02000H

⸫ After execution, AX= 3412H

‫ انغإال‬ٙ‫ زال ذى اػطائّ ف‬ٙ‫ ٔنكٍ ف‬,‫ر‬ٛ‫ كالًْا صس‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ أٔ انف‬ٙ‫ش انؼُٕاٌ ػهٗ انزاكشج تانشكم انًُطق‬ٛ‫ًكٍ ذأش‬ٚ :‫مالحظة‬
ٍ‫ نُصم نهًٕقغ أ انًٕاقغ انًطهٕتح ي‬ٙ‫ يٍ انؼُٕاٌ انًُطق‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح فُسراج انٗ زغاب انؼُٕاٌ انف‬ٛ‫ائ‬ٚ‫ض‬ٛ‫قح انؼَُٕح انف‬ٚ‫تطش‬
.‫انزاكشج‬

:‫ الحاالت التالية غير مسموح بها‬:‫مالحظة‬

MOV [1000] , [DI]

MOV [BX], [DI] NOT ALLOWED (no memory to memory operation) 

MOV [100H], [200H]

MOV DS, [DI] NOT ALLOWED (segment registers can NOT be used with memory) 

.Indirect Addressing Mode‫ يدًٕػح يٍ االيثهح انًرُٕػح ػهٗ انـ‬ٙ‫ اندذٔل انران‬ٙ‫ف‬
5) Register Relative Addressing Mode

.‫ داخم االقٕاط انًشتؼح‬offset‫رى اعرخذاو عدم يغ سقى الػطاء انـ‬ٚ ‫ ْزا انُٕع‬ٙ‫ف‬

MOV Destination, [Register + Displacement]

MOV [Register + Displacement], Source

where the displacement is any 16-bit number.

:‫ّ يٍ انزاكشج‬ٛ‫ انًطهٕب انزْاب ان‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح زغاب انؼُٕاٌ انف‬ٛ‫ف‬ٛ‫ك‬

.66 ٙ‫ تؼذ ضشتّ ف‬segment‫رى خًؼّ يغ انـ‬ٚ ٙ‫ ٔتانران‬offset‫ٍ ْٕ انـ‬ٛ‫ٍ انًشتؼ‬ٛ‫ٍ انقٕع‬ٛ‫رى اػرثاس كم يا يٕخٕد ت‬ٚ
segment-offset (‫ٍ يٍ خالل انشخٕع انٗ خذٔل انـ‬ٛ‫ٍ انقٕع‬ٛ‫ يٍ َٕع انغدم انًغرخذو ت‬segment‫ًكٍ يؼشفح انـ‬ٚٔ
ٌ‫ ٔارا كا‬DS ْٕ segment‫ فانـ‬SI ٔ‫ أ‬DI ٔ‫ أ‬BX ْٕ )offset( ‫ فارا كاٌ انغدم انًغرخذو كًإشش‬,)combinations
.SS ْٕ segment‫ فانـ‬BP ْٕ )offset( ‫انغدم انًغرخذو كًإشش‬

Example: Let BX=100H, DS=200H, find the value of AX after executing the following
instruction (the memory is given in the question): MOV AX, [BX+1000H]

9AH 03102H

70H 03101H

11H 03100H

F5H 030FFH
Solution:

PA= DS * 16 + BX + 1000H

PA = 2 0 0 0

0100

1000 +

03100H

⸫ After execution, AX = 7011 H

:‫ يثال‬,ٍ‫ضا ً يًك‬ٚ‫ خاسج االقٕاط انًشتؼح ْٔزا ا‬displacement‫رى ٔضغ انـ‬ٚ ‫ تؼض انًصادس‬ٙ‫ ف‬:‫مالحظة‬

MOV [BX]+1234H , AL

:ٙ‫ كانران‬,‫تد‬66 ‫تد أو‬8 ْٙ ‫ح ْم‬ٛ‫ذ طٕل انؼًه‬ٚ‫دة ذسذ‬ٛ‫ زانح اعرخذاو ْزا انُٕع يٍ انؼَُٕح يغ سقى ف‬ٙ‫ ف‬:‫مالحظة‬

MOV byte ptr[BX+20H], 4AH One memory location at (DS:BX+20H) will be given the
value 4AH.

MOV word ptr[BX+20H],5A12H Two memory locations will be changed as follows:

(DS: BX+20H) will be given the value (12H)

(DS:BX+26H) will be given the value (5AH)

MOV byte ptr[BX+20H],5A12H NOT ALLOWED (can you know why?) 

6) Base-Plus-Index Addressing Mode (or Base-Indexed Addressing Mode)

:offset‫) إلػطاء انـ‬DI ٔ‫ أ‬SI ( ‫خش‬ٜ‫) ٔا‬BX ٔ‫ أ‬BP( ‫ٍ أزذًْا‬ٛ‫رى اعرخذاو عده‬ٚ ‫ ْزا انُٕع‬ٙ‫ف‬

MOV destination , [ Base Register + Index Register ]

MOV [ Base Register + Index Register ] , source

where:

Base Registers are: BX and BP

Index Registers are: SI and DI


:‫ّ يٍ انزاكشج‬ٛ‫ انًطهٕب انزْاب ان‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح زغاب انؼُٕاٌ انف‬ٛ‫ف‬ٛ‫ك‬

BP‫ ارا ذى اعرخذاو انـ‬ْٙٔ ‫ يا ػذا زانح ٔازذج‬, PA‫ ػُذ زغاب انـ‬segment‫ كـ‬DS‫رى اعرخذاو انـ‬ٚ ‫ كم انساالخ‬ٙ‫ف‬
.‫ أيثهح ػهٗ ْزا انُٕع‬ٙ‫ اندذٔل انران‬ٙ‫ ف‬.PA‫ ػُذ زغاب انـ‬segment‫ ْٕ انـ‬SS‫ؼرثش انـ‬ٚ ‫فؼُذْا‬

Example: Let BX=AF00H


SI = 1FABH
DS=8000H
SP=F43EH
SS=15FFH
Give the memory locations that will be changed after executing the following instruction:

MOV [BX+SI], SP

Solution:

PA= 8CEABH (can you verify this?)

F4H 8CEACH

3EH 8CEABH

Note: if the instruction is modified to: MOV [BP + SI], SP

then the PA is calculated using SS instead of DS.


7) Base Relative-Plus-Index Addressing Mode

‫ تاإلضافح‬,offset‫) إلػطاء انـ‬DI ٔ‫ أ‬SI ( ‫خش‬ٜ‫) ٔا‬BX ٔ‫ أ‬BP( ‫ٍ أزذًْا‬ٛ‫رى اعرخذاو عده‬ٚ ‫ ْزا انُٕع يٍ انؼَُٕح‬ٙ‫ف‬
.ٍٛ‫ٍ انغاتق‬ٛ‫ أ٘ أٌ ْزا انُٕع ْٕ زاصم ديح انُٕػ‬,‫ًٓا‬ٛ‫ضاف ان‬ٚ ‫انٗ سقى‬

MOV destination , [ Base Register + Index Register + displacement]

MOV [ Base Register + Index Register + displacement] , source

where:

Base Registers are: BX and BP

Index Registers are: SI and DI

Displacement is any 16-bit number

:‫ّ يٍ انزاكشج‬ٛ‫ انًطهٕب انزْاب ان‬ٙ‫ائ‬ٚ‫ض‬ٛ‫ح زغاب انؼُٕاٌ انف‬ٛ‫ف‬ٛ‫ك‬

BP‫ ارا ذى اعرخذاو انـ‬ْٙٔ ‫ يا ػذا زانح ٔازذج‬, PA‫ ػُذ زغاب انـ‬segment‫ كـ‬DS‫رى اعرخذاو انـ‬ٚ ‫ كم انساالخ‬ٙ‫ف‬
‫ًح‬ٛ‫ ق‬ْٙٔ ‫ انزاكشج‬ٙ‫ٍ قٕع‬ٛ‫ًح يا يٕخٕد ت‬ٛ‫ ق‬ٙٓ‫ ف‬offset‫ًح انـ‬ٛ‫ أيا ق‬.PA‫ ػُذ زغاب انـ‬segment‫ كـ‬SS‫غرخذو انـ‬ٚ ‫فؼُذْا‬
.)displacement( ‫ًح انشقى‬ٛ‫ صائذا ً ق‬Base Register‫ًح انـ‬ٛ‫ صائذا ً ق‬Index Register‫انـ‬

Example:

Let DS= 1000H, SS= 50FFH, ES= 9A00H, BX= 20H, SI= 10H, find the value of AX after
executing the following instruction (the memory is given in the question):

MOV AX, [BX + SI + 100H]

67H 10133H

7BH 10132H

ACH 10131H

DH 10130H

81H 1012FH

Solution:

PA= DS * 16 + (BX + SI + 100H) = 10130 H

⸫ AX = AC0DH
Note: if the instruction is modified to: MOV AX, [BP + SI + 100H]

then the PA is calculated using SS instead of DS as the segment.

*****
Notice that all the tables and some examples are from the reference book (The Intel
Microprocessors)- chapter 3.

Best Regards
Dr. Zainab Alomari

You might also like