MP U1_merged
MP U1_merged
MICROPROCESSOR UNIT 1:
Q.1) Explain following instructions in microprocessor 80386:
i) MOV ii) PUSH iii) POP iv) CBW v) MOVSX
Ans:
1. MOV (Move Instruction)
• Purpose: Transfers data from one location to another.
• Syntax: MOV destination, source
• Operands:
o Destination: Register, memory location
o Source: Register, memory location, immediate value
Example:
MOV AX, BX ; Moves the content of BX into AX
MOV AL, 05H ; Moves immediate value 05H into AL
MOV [SI], DX ; Moves the content of DX into the memory location pointed by SI
December 1, 2024 1
2
December 1, 2024 2
3
i) Immediate addressing mode ii) Register addressing mode iii) Register Indirect
addressing mode.
Ans:
Addressing Modes in 80386 Processor with Examples
The 80386 microprocessor supports various addressing modes to access data from
memory and registers efficiently. Below are three important addressing modes with
explanations and examples.
December 1, 2024 3
4
• Usage:
Used when a fixed value needs to be loaded into a register or memory.
December 1, 2024 4
5
December 1, 2024 5
6
December 1, 2024 6
7
December 1, 2024 7
8
• Usage:
o Used when accessing fixed memory locations.
o Useful for accessing global variables or constants.
December 1, 2024 8
9
MOV AX, [EBX + ESI * 4 + 20H] ; Access memory at EBX + (ESI * 4) + 20H
Example:
MOV EBX, 1000H ; Base address
MOV ESI, 2 ; Index
MOV AX, [EBX + ESI * 4 + 10H] ; Access element at computed address
• Usage:
o Used for 2D arrays, complex data structures, and efficient indexing.
o Helps in dynamic memory access in programs.
Summary
These modes help in efficient memory access and complex data manipulations in
the 80386
December 1, 2024 9
1
The architecture of the 80386 can be divided into the following main units:
i) Index addressing mode ii) Direct addressing mode iii) Based index mode
The 80386 supports various addressing modes to access memory efficiently. Below are
the descriptions and examples of the requested addressing modes:
In this mode, an index register (SI or DI) is used to determine the memory
location.
The effective address is calculated as:
Effective Address=Base Address+Index Register\text{Effective Address} =
\text{Base Address} + \text{Index
Register}Effective Address=Base Address+Index Register
Used for accessing arrays or tables.
Example:
MOV EAX, [ARRAY + ESI]
Here, ARRAY is the base address, and ESI acts as the index.
The processor adds ESI to ARRAY to get the actual memory address.
Example:
MOV AL, [1000H]
Uses both a base register (BX, BP) and an index register (SI, DI) to determine the
memory location.
The effective address is calculated as:
Effective Address=Base Register+Index Register\text{Effective Address} =
\text{Base Register} + \text{Index
Register}Effective Address=Base Register+Index Register
Used for accessing complex data structures like arrays of records.
Example:
MOV EAX, [EBX + ESI]
Here, EBX acts as the base register, and ESI is the index register.
The memory location accessed is the sum of EBX and ESI.
These instructions transfer data between registers, memory, and immediate values.
Moves data between registers or MOV EAX, EBX (Move EBX value
MOV
memory to EAX)
Exchanges values between two XCHG EAX, ECX (Swap EAX and
XCHG
operands ECX)
PUSH Pushes data onto the stack PUSH EAX (Store EAX on stack)
These instructions handle pushing and popping data from the stack.
PUSH Pushes data onto the stack PUSH ECX (Save ECX on stack)
Removes data from the POP EDX (Retrieve last pushed value into
POP
stack EDX)
IN Reads data from an I/O port IN AL, 60H (Read from port 60H into AL)
OUT Writes data to an I/O port OUT 70H, AL (Send AL to port 70H)
1. Real Mode
Description:
Key Features:
2. Protected Mode
Description:
Key Features:
Description:
Key Features:
These 32-bit registers are used for data storage, arithmetic operations, and
addressing. They can also be accessed as 16-bit and 8-bit registers for backward
compatibility.
MOV EBP,
EBP (Base Pointer Register) Points to stack frame in function calls
ESP
2. Segment Registers
The 80386 uses segmentation for memory management. Segment registers store the base
address of memory segments.
CS (Code Segment) Points to the segment containing the program code MOV CS, AX
SS (Stack Segment) Points to the segment where stack operations occur MOV SS, AX