Microprocessor and Microcontroller_ARPI_CA2_25 - Copy
Microprocessor and Microcontroller_ARPI_CA2_25 - Copy
Microcontroller
A Report submitted to Dr. B. C. Roy Engineering College, Durgapur for the partial fulfillment of the course
Microprocessor and Microcontroller-CA2
By Arpita Som
Semester:- 6th
Microcontroller;
MARCH 2025
1
Contents:
03
References 13
2
Q 1: Discuss Addressing Modes in 8086 with proper instruction
examples.
Addressing modes are important in assembly language programming as they define how data is
located and accessed by instructions. These modes describe how an instruction specifies its
operands, whether they are immediate values, memory addresses, or registers. They play an
important role in the processor to fetch or store data for an operation, allowing us to manage
read/write operations during program execution. Effective use of addressing modes makes
assembly language code more efficient and flexible, directly impacting performance.
What is Addressing Mode?
Addressing modes specify how an instruction identifies the data or operands. It operates
in assembly language. This field indicates whether the operand is a direct value, a memory
address, or stored in a register. Addressing modes are important during instruction execution, as
they define the form of an operand and the way data is accessed, making sure of proper data
handling at the machine level.
Register Mode: In this type of addressing mode both the operands are registers.
Example:
MOV AX, BX
XOR AX, DX
ADD AL, BL
Immediate Mode: In this type of addressing mode the source operand is 8-bit or 16-bit data. The
destination operand can never be immediate data.
3
Example:
Displacement or Direct Mode: In this type of addressing mode the effective address is directly
given in the instruction as displacement.
Example:
Register Indirect Mode: In this addressing mode, the effective address is in SI, DI or BX.
Based Indexed Mode: In this, the effective address is a sum of the base register and index
register.
Base register: BX, BP
Index register: SI, DI
Indexed Mode: In this type of addressing mode the effective address is the sum of the index
register and displacement.
4
Example:
Based Mode: In this, the effective address is the sum of the base register and displacement.
Example:
MOV AL, [BP+ 0100]
Based Indexed Displacement Mode: In this type of addressing mode the effective address is the
sum of the index register, base register and displacement.
Example:
MOV AL, [SI+BP+2000]
String Mode: This addressing mode is related to string instructions. In this, the values of SI and
DI are auto-incremented and decremented depending upon the value of the directional flag.
Example:
MOVS B
MOVS W
Example:
IN A, 45
OUT A, 50
5
Relative Mode: In this the effective address is calculated concerning the instruction pointer.
Example:
• By using different addressing modes, you can access data in registers or memory and as
immediate values which makes CPU instructions more versatile.
• The register-based and indexed mode make better use of memory, especially in the case
of loop operations/arrays.
• For example, modes such as register addressing will make the instructions run faster
because they read data directly from registers rather than memory.
Conclusion
Addressing modes specify how an instruction identifies the data or operands. They describe how
the data is discovered and employed as long as this system runs, which makes stuff much more
flexible along handy. You will be able to write better assembly code using memory and registers
smartly once you understand different addressing modes[1].
6
Q 2: Different types of Instructions in 8086, Define Directives and
use them in an 8086-assembly language program.
Ans:-
Microprocessor - 8086 Instruction Sets
These instructions are used to transfer the data from the source operand to the destination
operand. Following is the list of instructions under this group –
• MOV − Used to copy the byte or word from the provided source to the provided
destination.
• PPUSH − Used to put a word at the top of the stack.
• POP − Used to get a word from the top of the stack to the provided location.
• PUSHA − Used to put all the registers into the stack.
• POPA − Used to get words from the stack to all registers.
• XCHG − Used to exchange the data from two locations.
• XLAT − Used to translate a byte in AL using a table in the memory.
7
Instructions for input and output port transfer
• IN − Used to read a byte or word from the provided port to the accumulator.
• OUT − Used to send out a byte or word from the accumulator to the provided port.
• LAHF − Used to load AH with the low byte of the flag register.
• SAHF − Used to store AH register to low byte of the flag register.
• PUSHF − Used to copy the flag register at the top of the stack.
• POPF − Used to copy a word at the top of the stack to the flag register.
Arithmetic Instructions
These instructions are used to perform arithmetic operations like addition, subtraction,
multiplication, division, etc.
Following is the list of instructions under this group –
8
Instruction to perform multiplication
• DIV − Used to divide the unsigned word by byte or unsigned double word by word.
• IDIV − Used to divide the signed word by byte or signed double word by word.
• AAD − Used to adjust ASCII codes after division.
• CBW − Used to fill the upper byte of the word with the copies of sign bit of the
lower byte.
• CWD − Used to fill the upper word of the double word with the sign bit of the
lower word.
These instructions are used to perform operations where data bits are involved, i.e. operations
like logical, shift, etc.
Following is the list of instructions under this group −
Instructions to perform logical operation
• SHL/SAL − Used to shift bits of a byte/word towards the left and put zero(S) in
LSBs.
• SHR − Used to shift bits of a byte/word towards the right and put zero(S) in MSBs.
• SAR − Used to shift bits of a byte/word towards the right and copy the old MSB
9
into the new MSB.
• ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to
Carry Flag [CF].
• ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to
Carry Flag [CF].
• RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to
MSB.
• RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to
LSB.
String Instructions
The string is a group of bytes/words and their memory is always allocated in a sequential
order.
• CALL − Used to call a procedure and save their return address to the stack.
• RET − Used to return from the procedure to the main program.
• JMP − Used to jump to the provided address to proceed to the next instruction.
These instructions are used to control the processor action by setting/resetting the flag values.
Following are the instructions under this group −
• STC − Used to set carry flag CF to 1
• CLC − Used to clear/reset carry flag CF to 0
• CMC − Used to put complement at the state of carry flag CF.
• STD − Used to set the direction flag DF to 1
• CLD − Used to clear/reset the direction flag DF to 0
• STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.
• CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.
11
Iteration Control Instructions
These instructions are used to execute the given instructions for number of times. Following
is the list of instructions under this group −
• LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX
=0
• LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 &
CX = 0
• LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0
& CX = 0
• JCXZ − Used to jump to the provided address if CX = 0
Interrupt Instructions
These instructions are used to call the interrupt during program execution.
• INT − Used to interrupt the program during execution and calling service specified.
• INTO − Used to interrupt the program during execution if OF = 1
• IRET − Used to return from interrupt service to the main program
12
References:
[1] GeeksforGeeks. (2024, December 11). *Addressing modes 8086 microprocessor*. Retrieved from
https://www.geeksforgeeks.org/addressing-modes-8086-microprocessor/
13