Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

ECE401- Microprocessor

Programming System
Sec 03
‫ معلش‬#
Microprocessor
Addressing Mode
It refers to the way the data needed by an instruction is specified.
1.Immediate Addressing Mode
• Source operand is an immediate data (value).
• Destination operand is a register or memory location.
• Ex:- Mov CX,34A6h Mov AL,87h
CX=34A6h AX=--87h
CL=0A6h AL=87h
CH=34h AH=--h
CX AX
0011 0100 1010 0110 ‫ معلش‬# ---- ---- 1000 0111
Microprocessor
Addressing Mode
1.Immediate Addressing Mode
• Ex:- Mov BL,8C2h Mov AH,CON1
Invalid Valid if CON1 is 8-bits
8ch>size of BL
Ex:- Mov BX,OFFSET VAL3
Move the address of memory in which have the value of VAL3
BX=2B56H
Label Address content
BL=56H
VAL3 2B56h 56h
BH=2BH
You can’t move data to segment registers directly.
‫ معلش‬#
Microprocessor
Addressing Mode
2.Register Addressing Mode
• Source operand is a register .
• Destination operand is a register.
• Ex:- Mov AL,BH Mov AL,DX
Move the data in BH to AL Invalid
Size of source (DX) is greater
than destination (AL)
In register addressing mode, source and destination must have the
same size.
‫ معلش‬#
Microprocessor
Addressing Mode
3.Direct Addressing Mode
• One of the operands (source & destination) is the content of the memory location
specified by value.
• Ex:- Mov AL,[1008h]
Move the content of memory location pointed to by DS:1008h into register AL.
AL=44h
• Ex:- Mov CX,[1009h]
Move the content of memory location pointed to by DS:1009h and DS:100Ah
into register CX.
CX=3F5Ch
CL=5CH
CH=3FH

‫ معلش‬#
Microprocessor
Addressing Mode
3.Direct Addressing Mode
• Ex:- Mov [100Bh],AL

Move the content of register AL to memory location pointed to by


DS:100Bh.
AL=44h
Microprocessor
Addressing Mode
3.Direct Addressing Mode
• Ex:- Find the physical address of the memory location and its
content after the execution of the following operation. Assume
DS=1512H
• Mov AL,99H
• Mov [3518h],AL
Physical address of DS:3518 = 1512*10H+3518H=18638H
The memory location 18638H will contain the value 99H
Microprocessor
Addressing Mode
4.Register indirect Addressing Mode
• SI, DI and BX registers are used as the pointers to hold the offset addresses
• Ex:- Mov AL,[BX]
Moves into AL the contents of the memory location pointed
to by DS:BX.
• Ex:- Mov [SI],AL
Moves the contents of AH into AL the memory location
pointed to by DS:SI.
Microprocessor
Addressing Mode
4.Register indirect Addressing Mode
• Ex:- Find the physical address of the memory location and its
content after the execution of the following operation. Assume
DS=1512H and SI=1234H
• Mov AL,99H
• Mov [SI],AL
Physical address of DS:SI = 1512*10H+1234H=16354H .
The memory location 16354H will contain the value 99H.
Microprocessor
Addressing Mode
5. Based relative addressing mode
• BX and BP are known as the base registers. In this mode base registers as well as a
displacement value are used to calculate the effective address.
• Ex:- MOV CX,[BX]+10 MOV CX,[BX+10]
Moves into CX the contents of the memory location pointed
to by DS:BX+10 and DS:BX+11.
The content of the low address will go into CL and the high
address contents will go into CH.
BX+10 is the effective address.

‫ معلش‬#
Microprocessor
Addressing Mode
5. Based relative addressing mode
• Ex:- Find the physical address of the memory location and its content after the
execution of the following operation. Assume DS=1512H and SI=1234H
• Mov AL,99H
• MOV [BX+10],AL OR MOV [BX]+10,AL
Physical address of DS:BX+10 = 1512*10H+1234H+10H=16364H .
The memory location 16364H will contain the value 99H.

‫ معلش‬#
Microprocessor
Addressing Mode
6. Indexed relative addressing mode
• SI and DI holds the offset address.
• Ex:- MOV DX,[SI]+5
Moves into DX the contents of the memory location pointed
to by DS:SI+5 and DS:SI+6.
The content of the low address will go into DL and the high
address contents will go into DH.
SI+5 is the effective address.

‫ معلش‬#
Microprocessor
Addressing Mode
6. Indexed relative addressing mode
• Ex:- MOV CL,[DI]+10
Moves into CL the contents of the memory location pointed
to by DS:DI+10.
The content of the low address will go into DL and the high
address contents will go into DH.
DI+10 is the effective address.

‫ معلش‬#
Microprocessor
Addressing Mode
6. Indexed relative addressing mode
• Ex:-Find the physical address of the memory location and its
content after the execution of the following operation.
Assume DS=1512H and DI=1234H
• Mov AL,99H
• MOV [DI]+10 , AL OR MOV [DI+10],AL
Physical address of DS:DI+10 =
1512*10H+1234H+10H=16374H .
The memory location 16364H will contain the value
99H.
‫ معلش‬#
Microprocessor
Addressing Mode
7. Based Indexed addressing mode
• One base register and one index register are used.
• Ex:- MOV CL,[BX][DI]+8
MOV CL,[DI+BX+8]
Moves into CL the contents of the memory location pointed
to by DS:BX+DI+8.
BX+DI+5 is the effective address.

‫ معلش‬#
Microprocessor
Addressing Mode
7. Based Indexed addressing mode
• Ex:-Find the physical address of the memory location and its content after the
execution of the following operation. Assume DS=1512H , BX=1234H
• and DI=02
• Mov AL,99H
• MOV [BX][DI]+8 , AL OR MOV [BX+DI+8],AL
Physical address of DS:BX+DI+10 = 1512*10H+1234H+02H+10H=16366H .
The memory location 16366H will contain the value 99H.

‫ معلش‬#
Microprocessor
Segmentation
• A segment is an area of memory that includes up to 64K bytes and
begins an address evenly divisible by 16 (such an address ends in 0H).
• The complete 1Mbytes memory can be divided into 16 segments.
• Capacity of each segment equal 1M/16=64Kbytes.
• Assembly Language Program consists of three segments:
1. code segment : contains the program code (instructions)
2. data segment : used to store data to be processed by the program
3. stack segment: used to store information temporarily.

‫ معلش‬#
Microprocessor
Segmentation
• A segment is an area of memory that includes up to 64K bytes and
begins an address evenly divisible by 16 (such an address ends in 0H).
• The complete 1Mbytes memory can be divided into 16 segments.
• Capacity of each segment equal 1M/16=64Kbytes.
• Assembly Language Program consists of three segments:
1. code segment : contains the program code (instructions)
2. data segment : used to store data to be processed by the program
3. stack segment: used to store information temporarily.

‫ معلش‬#
Microprocessor
Segmentation

‫ معلش‬#
Microprocessor
Segmentation
• Each segment can be represented by segment registers that used in
Microprocessor.
1. Code segment :- Code Segment Register [CS]
2. Stack segment :- Code Segment Register [SS]
3. Dara segment :- Code Segment Register [DS]
4. Extra segment :- Code Segment Register [ES]
• Four segment registers are 16-bits.

‫ معلش‬#
Microprocessor
Segmentation
Logical Address and Physical Address
• Logical Address consists of segment address and offset address.
Segment Register : Offset Address
CS:IP(instruction pointer)
DS:BX(Base register)
DS:SI(source index)
DS:DI(destination index)
• Physical Address is the 20‐bit address that actually put on the address bus.
Physical Address =segment address *10h + offset address

‫ معلش‬#
Microprocessor
Segmentation
If CS=24F6H and IP=634AH, determine:
a) The logical address
b) The offset address
c) The physical address
d) The lower range of the code segment
e) The upper range of the code segment

‫ معلش‬#
Microprocessor
Segmentation
If CS=24F6H and IP=634AH, determine:
a) The logical address = CS:IP
24F6H:634AH
b)The offset address = IP =634AH
c)The physical address = CS*10H+IP
= 24F6H*10H+634AH = 2B2AAH
d)The lower range of the code segment = CS*10H+0000H
=24F6H*10H+0000H=24F60H
e)The upper range of the code segment= CS*10H+FFFFH
= 24F6H*10H+FFFFH=34F5FH
‫ معلش‬#
Quiz in the next week

Thanks
‫ معلش‬#

You might also like