2. Prerequisite - Intro to parts of CPU
• Arithmetic and Logic Unit (ALU)
It performs all the arithmetic and
logical micro operations.
• Floating Point Unit (FPU)
It performs operations on floating
point numbers.
• Memory Unit (MU)
It stores the set of instructions.
• Control Unit (CU)
It supervises the sequence of
micro operations.
• Registers
Temporary storage area, which holds the
data during the execution of an
instruction.
CU
FPU
MU
REGISTERS
ALU
3. 8-bit 8-bit 8-bit
OP CODE OPERAND
.1 byte 1 to 2 byte
An opcode is a short of “operation code”
An opcode is a single instruction can be executed by the CPU. In
assembly language mnemonic form an opcode is a command such
as MOV or ADD or JMP.
Example:
MOV AX, 1000H ; MOV is the opcode.
; AX (register) is an operand.
Operands are manipulated by the opcode. In this example,
the operands are the register AX and the value 1000H.
Opcode and Operand in Microprocessor
8086/8088
4. Purpose of Addressing modes
1.) To give programming flexibility to the user
by providing such facilities as pointers to
memory, counters for loop control, indexing
of data and various other purposes.
2.) To reduce the number of bits in the addressing
field of the instructions.
5. To understand the various addressing modes:
• It is imperative that we understand the basic operation cycle of
the computer.
The control unit of a computer is designed to go through
an instruction cycle that is divided into 3 major parts:-
Fetch the instruction from memory
Decode the instruction and
Execute the instruction.
6. • The operation field of an instruction specifies the
operation to be performed.
• This operation must be executed on the data stored in
computer registers or the memory words.
• The way the operands are chosen during program
execution is dependent on the addressing mode of the
instruction
Contd..
7. Addressing Modes
• Microprocessor executes the instructions stored in memory
(RAM).
• It executes one instruction at a time.
• Each of the instruction contains operations and operands.
• Operation specifies the type of action to be performed.
• For example: ADD, SUB, MOV, INC, LOAD, STORE
• Operands are the data on which the operation is to be
performed. MOV B, A
ADD B
Here MOV is operation and (B & A) are
operands.
Here ADD is operation and (B) is
operand.
8. Addressing Modes
• Operand can be place either in one of the processor register or
in memory.
• There are different ways to get the operands.
• The way in which the operand is taken from register or memory
is named as addressing mode.
THE ADDRESSING MODE:
Specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually referenced.
9. Addressing Modes in Microprocessor
8086/8088
Types of Addressing Modes:
(1) Stack-Memory Addressing Modes
(2) Data Addressing Modes
(3) Program-Memory Addressing Modes
10. 1- Stack-Memory Addressing Modes in
Microprocessor 8086/8088
The stack plays an important role in all
microprocessors.
It holds data temporarily and stores return addresses for
procedures.
The stack memory is a LIFO (last-in, first-out) memory, which
describes the way that data are stored and removed from the stack.
Data are placed onto the stack with a PUSH instruction and
removed with a POP instruction.
The CALL instruction also uses the stack to hold the return address
for procedures and a RET (return) instruction to remove the return
address from the stack.
11.
12. 2. Data Addressing Modes
1. Immediate Addressing Mode
2. Direct Addressing Mode
3. Indirect Addressing Mode
4. Register Addressing Mode
5. Register Indirect Addressing Mode
6. Implied Addressing Mode
7. Auto increment or Auto decrement Addressing
Mode
8. Relative Addressing Mode
9. Indexed Addressing Mode
10. Base Register Addressing Mode
An addressing mode means the method by which an
operand can be specified in a register or a memory
location
13. 1.ImmediateAddressing
• Thesource data is coded directly into the
instruction.
– Theterm immediate means that the data immediately follows
the hexadecimal opcode inthe memory.
• Immediate data are constant data suchas anumber,
acharacter, or an arithmetic expression.
• Examples:
– MOVAX,100
– MOVBX,189CH
– MOVAH, 10110110B
– MOVAL,(2 +3)/5
14. Contd
• The operand is specified with in the instruction.
• Operand itself is provided in the instruction rather than its
address.
• In other words, an immediate-mode instruction has
an operand field rather than an address field.
• Move Immediate
MVI A , 15h A ←15h Here 15h is the immediate
operand
Add
Immediate
ADI 3Eh A ← A + 3Eh Here 3Eh is the immediate
operand
15. Immediate Addressing Mode
Example:
MOV AX, 2550H
MOV CX, 625
MOV BL, 40H
; move 2550H into AX
; load the decimal value 625 into
CX
; load 40H into BL
The data must first be moved to a general-purpose
register and then to the segment register.
Example:
MOV AX, 2550H
MOV DS, AX
MOV DS, 0123H ; illegal instruction!
17. Transfers the source, an immediate byte or word of data,
into the destination register or memory location
The source operand is a constant
The operand comes immediately after the opcode
For this reason, this addressing mode executes quickly
Immediate addressing mode can be used to load
information into any of the registers except the segment
registers and flag registers.
Concluding remarks of
Immediate Addressing Mode
18. Effective address:
• The effective address is defined to be the memory
address obtained from the computation dictated
by the given addressing mode.
• The effective address is the address of the
operand in a computational-type instruction.
Important note:
19. 3.Direct Addressing
• Theoperand is stored in amemory location, usuallyin data
segment.
Theinstruction takes the offsetaddress.
–Thisoffset addressmust be put in abracket [].
•
In this mode the effective address is equal to the
address part of the instruction. The operand resides in
memory and its address is given directly by the
address field of the instruction.
20. Contd.
• The instruction specifies the direct address of the operand.
• The memory address is specified where the actual operand
is.
Load Accumulator
LDA 2805h A ← [2805]
It loads the data from memory location 2805 toA.
Store Accumulator
STA 2803h [2803] ← A
It stores the data from A to memory location 2803.
21. Direct Addressing Mode
LDA 2805h A ← [2805]
It loads the data from memory location 2805 to
A.
Before After
2807
2806
2805 5C
2804
2803
2802
2801
2800
A 2807
2806
2805 5C
2804
2803
2802
2801
2800
A 5C
A ←
[2805]
A ←
5C
22. Direct Addressing Mode
STA 2803h [2803] ← A
It stores the data from A to memory location
2803.
Before After
2807
2806
2805
2804
2803
2802
2801
2800
A 9B 2807
2806
2805
2804
2803 9B
2802
2801
2800
A 9B
[2803] ←
A
[2803] ←
9B
23. Direct Addressing Mode
Moves a byte or word between a memory location and a register.
The data is in some memory location(s) and the address of
the data in memory comes immediately after the instruction
This address is the offset address
Example:
MOV AX, [2400] ; move contents of DS:2400H
into AX
The physical address is calculated by combining the contents of
offset location 2400 with DS (default segment)
24. Example:
Find the physical address of the memory location and its contents after the
execution of the following, assuming that DS
= 1512H.
AL, 3BH
[3518],AL
MOV
MOV
Solution:
First 3BH is copied into AL,
Then in line two, the contents of AL are moved to logical address DS:3518 which is
1512:3518.
Shifting DS left and adding it to the offset gives the physical address of 18638H
(15120H + 3518H = 18638H).
After the execution of the second instruction, the memory
.. with address 18638H will contain the value 3BH.
Direct Addressing Mode
25. Direct Addressing Mode
MOV AL, 3BH
MOV [3518], AL DS=1512H (segment address)
Offset address= 3518
Physical/effective address= 15120 + 3518= 18638
Before After
3500
3502
3504
3508
.
.
.
3518
AL 3B
3500
3502
3504
3508
.
.
.
3518 3B
AL 3B
AL← 3B [3518] ← AL
26. Question problem
1st instruc
500
Next Instruction
450
700
800
900
325
300
Address
200
201
202
Memory
399
400
500
600
702
PC 200
AC
800
PC = Program Counter
AC = Accumulator
• NOTE:
• Memory is having first instruction to load AC
• Mode will specify the addressing mode to get
operand.
• Address field of instruction is 500.
Find out the effective address of operand
and accumulator & operand value by
considering different addressing modes.
Load A ,500
Lda [500]
27. Example problem
Address Memory
200
201
1st instruc
500
Next Instruction
450
700
800
900
325
300
202
399
400
500
600
702
PC 200
AC
800
1. Immediate Addressing Mode
• As instruction contains immediate number
500.
Effective Address = nil
Operand = 500
AC 500
Instruction: Load A ,500
28. Example problem
Address
200
201
202
Memory
399
400
500
1st instruc
500
2nd Instruction
450
700
800
900
325
300
600
702
PC 202
AC
800
2. Direct Addressing
Mode
• Instruction contains the address 500.
• So effective address of operand is
500.
• The data stored at 500 is 800.
Effective Address = 500
Operand = 800
AC 800
Instruction: LdA [500]