CS305 MPMC - Module-2
CS305 MPMC - Module-2
06/09/2024
2
06/09/2024
3
06/09/2024
8086 µP – Addressing Modes
Addressing modes help us to understand the types of operands and the way
they are accessed while executing an instruction.
5
Assembler
Control
06/09/2024
Physical address calculation 6
06/09/202
4
7
06/09/202
4
8
Instruction addressing in 8086 Microprocessor
06/09/202
4
Types of addressing mode in 8086
1. Immediate addressing
2. Direct addressing
3. Register addressing
5. Based Addressing
6. Indexed addressing
In this type of mode, immediate data is part of instruction and appears in the
form of successive byte or bytes
10 ABH
MOV AX,10ABH
AX
2: Direct addressing mode
In this type of addressing mode a 16-bit memory address is directly specified in the instruction as a
part of it.
Memory
22 5000
MOV AX,[5000H] 33 5001
5002
AX
3: Register addressing mode
In this type of addressing mode, the data is stored in the register and it can be a 8-bit or 16-bit
register. All the registers, except IP, may be used in this mode.
MOV AL,BLH 10 AB BX
MOV AX,BXH
BH BL
FF 33 AX
AH AL
4: Register Indirect addressing mode
Memory
MOV AX,[BX] 22 5000
AX
33 5001
5002
50 00 BX
Question
MOV [7000H],CX
CX 43 56
5: Based addressing mode
Memory
22 5000
AX
33 5001
MOV AX,[SI] 5002
50 00 SI
7: Based Indexed addressing mode
7: Based indexed addressing mode
12 3000
AX
MOV AX, [BX + SI] 34 3001
3002
10 00 + 20 00 = 3000H
Final
BX SI Index
Address
8: Relative Based Indexed addressing mode
8: Relative Based Indexed addressing mode
12 3050
MOV AX, [BX+SI+50H] AX
34 3051
3052
50H + 10 00 20 00 = 3050H
Final
BX SI Index
Address
9: Direct IO port addressing mode
In this, the instruction itself will specify the data to be operated by the
instruction
ProgramSlide
Assembler Directives 5
*Assembler convert assembly language code into machine code that the computer can then read
and execute
25 06/09/2024
List of Assembler directives for 8086 µP assembly language Programming
26 06/09/2024
List of Assembler directives for 8086 µP assembly language Programming
27 06/09/2024
28
Classification of 8086 µP Instructions
2. Arithmetic Instructions
3. Logical Instructions
09/06/2024
1. Data transfer/copying Instructions
1. ADD AX, BX
2. SUB AX, CX
3. MUL BX
4. DIV BL
5. INC CL
6. DEC CX
7. CMP DL, CH
30 06/09/2024
3. Logical Instructions
31 06/09/2024
Sl Instruction Explanation Symbolic Representation
No.
1 SHL Content of the register is
shifted left, the MSD is
shifted to the carry flag
while the LSD is filled
with zero
2 SHR Content of the register is
shifted right, the LSD is
shifted to the carry flag
while the MSD is filled
with zero
32 06/09/2024
Sl Instruction Explanation Symbolic Representation
No.
3 ROL The content of the
register is rotated left,
while the MSD is
moved to both the
LSD and the carry
flag
4 ROR The content of the
register is rotated
right, while the LSD
is moved to both the
MSD and the carry
flag
33 06/09/2024
Sl Instruction Explanation Symbolic Representation
No.
5 RCL The content of the
register is rotated left,
the carry flag is
moved to the LSD,
while the MSD is
moved to the carry
flag
6 RCR The content of the
register is rotated
right, the carry flag is
moved to the MSD,
while the LSD is
moved to the carry
flag
34 06/09/2024
ProgramSlide
4. Control transfer Instructions 5
Sl Instruction Explanation
No.
3 JCXZ Jump if CX = 0
36 06/09/2024
4. Control transfer Instructions
CALL Instructions
CALL instruction transfer control to a subprogram or subroutine or a
procedure after saving the return address in the stack memory
Syntax: CALL label Example: CALL 4020
RET Instructions
Every procedure or subroutine ends with an RET instruction. The execution of the
RET instruction will pop the content of top of stack to the IP. Thus the program control
returns back to main program
Examples: RET
37 06/09/2024
4. Control transfer Instructions
LOOP Instructions
These are used to execute a group of instructions a number of times as specified by a
count value stored in the CX register. The content of the CX register is decremented by
one after each execution.
Syntax: LOOP label Example: LOOP 4020
Software Interrupts
The INT instructions are called software interrupts. The INT instruction is used to
call a procedure or subroutine on interrupt basis.
Example: INT 3 - Interrupt program execution
IRET – Interrupt return
38 06/09/2024
5. Processor Control Instructions
This group includes instructions to set or clear the carry flag, the direction flag,
and the interrupt flag. It also includes the instructions which controls the processor
operation.
Mnemonics used :
Sl Instruction Explanation
No.
1 CLC The carry flag is reset to zero
2 CMC The carry flag is complemented
3 STC The carry flag is set to one
4 HLT Halt program execution
It is used to terminate a program
5 WAIT Causes the processor to enter into an
idle state
6 NOP No operation is performed
39 06/09/2024
8086 Microprocessor Stack- LIFO (Last In First Out)data segment
Transfer
40 06/09/2024
Assembly Language Programming -2: 16-bit Addition
41 06/09/2024
42 06/09/2024
Assembly Language Programming -2: 16-bit Subtraction
43 06/09/2024
44 06/09/2024
Assembly Language Programming -3: Sum of elements in an array
45 06/09/2024
46 06/09/2024
Assembly Language Programming -4: Search for smallest data
47 06/09/2024
48 06/09/2024
Assembly Language Programming - 5: Search for largest data
49 06/09/2024
50 06/09/2024
8086 Microprocessor Stack- LIFO (Last In First Out)data segment
Stack is a portion of RAM memory defined by the user for temporary storage and retrieval of
data while executing a program
Stack Pointer (SP) is an internal register to hold the address of the stack
PUSH & POP - To store/retrieve data from the stack
Instructions – PUSH,POP,RST n, CALL,RET
The content of the SP is automatically decremented/incremented after every write/read into
stack – LIFO
Order of retrieving (POPing) should be opposte to that of storing(PUSHing)
51 06/09/2024
Example
52 06/09/2024
Physical address computation
54 06/09/2024
Subroutine(Procedure)
55 06/09/2024
Macro
A group of instructions written within brackets and identified by a name.
A macro is written when a repeated group of instructions is too short or not appropriate to
be written as a subroutine
Assembler directives : MACRO – beginning of a macro
ENDM- end of a macro
Whenever the macro is called in the program, the assembler will insert the defined group
of instructions in place of the call
The process of replacing the macro with the instructions it represent is called expanding
the macro
56 06/09/2024
57 06/09/2024
58 06/09/2024