Micro Assighnment
Micro Assighnment
Submitted: Amnuale
SubmitionDate: 10/05/2017 EC
1 .List various Instructions of 8086 and write how they are working.
Introduction:
In this article, we will examine some of the key instructions of the 8086
microprocessor, explain their working, and provide insight into how they contribute to
the functionality of the system.
These instructions are used to move data between registers, memory, and I/O ports.
MOV: This is the most commonly used data transfer instruction. It moves data from a
source operand to a destination operand.
Example: MOV AX, 30H (Moves the hexadecimal value 30 into the AX register).
PUSH: This instruction places the content of a register or memory location onto the
stack.Example: PUSH AX (Pushes the content of the AX register onto the stack).
POP: This instruction removes the content from the stack and places it into a register
or memory location.Example: POP AX (Pops the top value from the stack into the
AX register).
2. Arithmetic Instructions:
ADD: This instruction adds two operands and stores the result in the destination
operand.Example: ADD AX, BX (Adds the value in BX to AX).
SUB: This subtracts the second operand from the first operand.Example: SUB AX,
BX (Subtracts BX from AX).
3. Logical Instructions:
AND: This performs a bitwise AND operation between two operands.Example: AND
AX, BX (Performs an AND operation between AX and BX).
XOR: This performs a bitwise XOR operation between two operands.Example: XOR
AX, BX (Performs an XOR operation between AX and BX).
OT: This performs a bitwise NOT operation (inverts the bits) on the operand.Example:
NOT AX (Inverts the bits of AX).
4. Branch Instructions:
CALL: This instruction calls a procedure by pushing the address of the next
instruction onto the stack and jumping to the target address.Example: CALL 3000H
(Calls a subroutine at address 3000H).
RET: This instruction returns control from a procedure by popping the return address
from the stack.Example: RET (Returns from a subroutine).
JZ: This instruction performs a jump if the zero flag is set.Example: JZ 5000H
(Jumps to 5000H if the zero flag is set).
5. Control Instructions:
HLT: This instruction halts the execution of the program.Example: HLT (Halts the
program).
CLC: This clears the carry flag.Example: CLC (Clears the carry flag).
STC: This sets the carry flag.Example: STC (Sets the carry flag).
Conclusion:
The 8086 microprocessor’s instruction set is a powerful and versatile feature that
allows for a wide range of operations to be performed. From moving data between
registers and memory to performing complex arithmetic and logic operations, the
8086 provides all the tools necessary for efficient programming. Additionally, the
microprocessor includes control and branching instructions that give programmers the
ability to manipulate the flow of execution, making it a flexible tool for software
development. By understanding these instructions, programmers can harness the full
potential of the 8086 and create more sophisticated and optimized applications.
Introduction:
Control instructions in the 8086 microprocessor play a crucial role in managing the
execution flow of a program. These instructions directly impact the operation of the
microprocessor, either by controlling its internal flags or halting execution. While not
as frequently used as data transfer or arithmetic instructions, control instructions are
essential for tasks such as managing program flow, handling interrupts, and
controlling flags.In this article, we will explore the various control instructions
available in the 8086 microprocessor, explaining their purpose and functionality.
The 8086 microprocessor includes several control instructions that manage its
operations:
HLT (Halt):
The HLT instruction halts the execution of the program. It stops the processor's
operation and typically requires a reset to resume program execution. This instruction
is often used at the end of a program or during an error state to stop further
execution.Example: HLT (Halts the program execution).
WAIT:
The WAIT instruction is used to pause the execution of the program until the
processor receives a signal indicating that the next operation can be performed. It is
typically used with external devices.Example: WAIT (Pauses execution until the
condition is met).
Conclusion:
Control instructions in the 8086 microprocessor are fundamental for managing the
execution flow, handling interrupts, and controlling processor flags. Instructions like
NOP, HLT, CLC, and STC enable fine control over the processor's behavior, ensuring
smooth execution of tasks and error management. While they are used less frequently
than other instruction types, control instructions are indispensable for managing the
internal state of the processor and program execution.
Introduction:
Addressing modes in the 8086 microprocessor define how the operands (data) of an
instruction are accessed and specified. These modes are crucial because they
determine how the processor retrieves data from memory or registers. The 8086
supports multiple addressing modes, offering flexibility in programming by allowing
different ways to access data, whether directly in registers, through memory, or using
displacement techniques.In this article, we will discuss the various addressing modes
available in the 8086 microprocessor, explaining their purpose and how they
function.The 8086 microprocessor supports several addressing modes that define how
operands are accessed:
Immediate Addressing Mode: In this mode, the operand is specified directly in the
instruction itself, rather than being stored in a register or memory location. The value
is constant and used immediately.Example: MOV AX, 5 (The value 5 is moved
directly into the AX register).
Direct Addressing Mode: In this mode, the operand is located at a specific memory
address, which is provided in the instruction.Example: MOV AX, [2000H] (The value
stored at memory address 2000H is moved into AX).
Indirect Addressing Mode: The operand is accessed via a register that holds the
memory address of the operand. The effective address is computed by adding an
optional displacement to the value in the register.Example: MOV AX, [BX] (The
value at the memory address stored in the BX register is moved into AX).
Indexed Addressing Mode: This mode uses an index register (like SI or DI)
combined with a displacement to access memory. It is often used for accessing array
elements.Example: MOV AX, [SI+10H] (The value at the memory address formed by
adding 10H to the value in SI is moved into AX).
Based Indexed Addressing Mode: This mode combines both base and index
registers with an optional displacement. It is used to access data with complex
addressing needs, such as multidimensional arrays.Example: MOV AX, [BX+SI+10H]
(The value at the memory address formed by adding 10H to the sum of BX and SI is
moved into AX).
Conclusion:
Addressing modes in the 8086 microprocessor provide different ways to access data,
offering flexibility and efficiency in program design. By supporting immediate,
register, direct, indirect, indexed, based, and combined addressing modes, the 8086
allows programmers to optimize data access and memory usage. Understanding these
addressing modes is key to writing effective assembly code and maximizing the
potential of the microprocessor.
Introduction:
The Intel 8086 microprocessor and the 8087 co-processor are key components in the
evolution of computer architecture, designed by Intel in the late 1970s and early
1980s. While the 8086 is a general-purpose microprocessor, the 8087 is a specialized
co-processor designed to assist the 8086 with advanced mathematical calculations,
particularly floating-point operations. The following sections will highlight the main
differences between these two processors, focusing on their functions, capabilities,
and roles in a computing system.
Functionality:
Intel 8087 Co-processor: The 8087, on the other hand, is a floating-point arithmetic
co-processor that supplements the 8086 by offloading complex mathematical
calculations, such as multiplication, division, square roots, and trigonometric
functions. It does not function as a standalone processor and cannot execute general-
purpose instructions. The 8087 enhances the 8086's computational power, especially
in applications requiring intensive floating-point arithmetic, such as scientific
computing and engineering applications.
Data Processing:
8086: The 8086 is limited to integer operations, processing 16-bit data at a time. Its
computational tasks involve fixed-point arithmetic, which is useful for many general
applications but inefficient for scientific computations that demand floating-point
precision.
8087: The 8087, in contrast, is optimized for floating-point arithmetic. It handles 32-
bit single-precision and 64-bit double-precision floating-point numbers, offering
significantly improved performance in mathematical tasks that require such
operations.
8086: As a stand-alone processor, the 8086 executes all the program instructions in a
system, handling both control and computational tasks. It was widely used in early
personal computers like the IBM PC.
8087: The 8087 works in tandem with the 8086, providing additional computational
support. It operates as a companion chip and communicates with the 8086 through a
dedicated bus. The 8087 was not essential for the operation of the system but
significantly boosted performance in applications that made use of its capabilities.
Performance:
8086: The 8086 is more efficient for general-purpose processing tasks, but its
performance diminishes when dealing with floating-point calculations.
Conclusion:
In conclusion, while both the 8086 microprocessor and the 8087 co-processor were
crucial in the development of computing technology, their roles differ significantly.
The 8086 is a versatile, general-purpose processor used for executing most computer
programs, whereas the 8087 serves as a dedicated assistant to the 8086, enhancing its
capability to handle complex floating-point calculations efficiently. By working
together, the two processors enabled more powerful and specialized computing,
particularly in applications that demanded high computational precision.
3. HOLD:
The HOLD pin is used to request control of the bus from the 8086. When another
device (like a DMA controller) wants to take control of the system bus, it asserts the
HOLD signal. The 8086 will then complete its current instruction and release control
of the bus once it acknowledges the request by asserting the HLDA (Hold
Acknowledge) signal. The Hold pin allows an external device to temporarily control
the system bus. The processor responds by issuing a hold acknowledge signal on the
HLDA pin.
The HOLD pin in the 8086 microprocessor is a control signal used for bus arbitration
in multiprocessor and peripheral systems. It allows an external device to request
control of the system bus, enabling it to perform operations such as reading or writing
data.
▎Functionality of the HOLD Pin
1. Bus Request: The HOLD pin is used by an external device (like a DMA controller
or another processor) to request control of the address and data buses from the 8086
microprocessor. When an external device wants to take control, it asserts the HOLD
signal (sets it high).
2. Bus Release: Upon receiving the HOLD signal, the 8086 microprocessor will
complete its current bus cycle and then relinquish control of the bus. The
microprocessor will then enter a state where it allows the requesting device to use the
bus for its operations.
3. Control Signal: The 8086 uses the HLDA (Hold Acknowledge) pin to acknowledge
the HOLD request. When the microprocessor is ready to release the bus, it sets HLDA
high, indicating to the requesting device that it can take control.
▎Examples of Usage
1. Direct Memory Access (DMA): In systems that use DMA controllers, the DMA
controller may need to transfer data directly between memory and an I/O device
without involving the CPU.
For instance, when a DMA operation is initiated, the DMA controller will assert the
HOLD pin to request control of the bus. The 8086 will finish its current instruction
and then release the bus.
Once the bus is released, the DMA controller can read data from memory or write
data to memory directly, bypassing the CPU.
2. Multiprocessor Systems:
In systems with multiple processors (like a dual-processor setup), one processor might
need to temporarily relinquish control of the bus for another processor to execute its
tasks.
For example, if Processor A is currently executing instructions but Processor B needs
to access shared memory, Processor B can assert HOLD. The 8086 will complete its
current operation and assert HLDA, allowing Processor B to take control of the bus
and perform its operations.
4. DEN (Data Enable):
The DEN pin is used to indicate when valid data is present on the data bus. It is an
output pin that becomes active when data is being transferred either to or from
memory or I/O devices. This signal helps external devices know when they should
read from or write to the data bus.
The DEN (Data Enable) pin in the 8086 microprocessor is a control signal used to
manage data transfer during read and write operations. It indicates when the data bus
is valid and can be used to read or write data.
▎Functionality of the DEN Pin
1. Data Transfer Control: The DEN pin is activated (set to high) during the data
transfer phase of a read or write operation. When DEN is high, it signals that the data
on the data bus is valid and can be read by an external device or written to memory.
2. Read and Write Operations: Read Operation: During a read operation, the 8086
activates the DEN pin to indicate that the data on the data bus can be read by the
requesting device (like memory or an I/O port).
Write Operation: In a write operation, the DEN pin is also activated to indicate that
the data being sent from the microprocessor to memory or an I/O device is valid.
▎Examples of Usage
1. Reading Data from Memory:
When the 8086 microprocessor needs to read data from memory, it places the address
of the memory location on the address bus and activates the DEN pin.For example, if
the microprocessor wants to read a byte of data from memory location 0x1234, it will
output this address on the address bus, assert the DEN pin, and then wait for the
memory to place the data on the data bus. Once the data is available, it can be read by
the microprocessor.
2. Writing Data to an I/O Device: When writing data to an I/O device, the 8086 places
the address of the I/O device on the address bus and the data to be sent on the data bus.
The DEN pin is asserted during this operation to indicate that the data on the data bus
is valid and should be written to the specified I/O port.
For example, if the microprocessor wants to send a byte of data 0xAB to an output
device at I/O port 0x01, it will output the port address on the address bus, place 0xAB
on the data bus, and assert DEN to signal that this data is valid for writing.
5. RESET
The RESET pin is used to initialize the microprocessor. When this pin is activated
(pulled low), it clears the internal registers and sets the program counter to a
predefined start address (typically 0xFFFF0). This effectively resets the
microprocessor, allowing it to start executing instructions from a known state.
The Reset pin resets the microprocessor if it is held high for at least four clocking
periods. When the microprocessor resets, it starts executing instructions at memory
location FFFFOH.
The RESET pin in the 8086 microprocessor is a control signal used to initialize the
microprocessor. When activated, it forces the microprocessor to terminate its current
operations and reset its internal state, including the program counter and other
registers.
▎Functionality of the RESET Pin
1. Initialization: The RESET pin, when asserted (typically by applying a high signal),
clears the internal registers and sets the program counter to a predefined address,
usually FFFF0h. This address corresponds to the start of the BIOS or firmware in a
typical system.
2. Interrupt Handling: The RESET pin can also be used to handle situations where the
system needs to recover from an error or fault condition. By resetting the
microprocessor, it can return to a known state.
3. Control Signal: The RESET pin is an active-high signal, meaning that it must be
driven high to trigger the reset condition.
▎Behavior Upon Reset
When the RESET pin is activated:
The 8086 microprocessor clears all internal registers.
The Instruction Pointer (IP) is set to 0000h, and the Code Segment (CS) is set to
FFFFh, directing the processor to start execution from address FFFF0h.
All flags in the FLAGS register are reset.
▎Examples of Usage
1. System Boot-Up: When a computer is powered on, the RESET pin is typically
asserted to ensure that the microprocessor starts in a known state. This initialization
process allows the BIOS to execute and perform hardware checks before loading the
operating system.
For instance, when you turn on your PC, the power-on reset circuit asserts the RESET
pin, causing the 8086 to begin execution from the BIOS at memory address FFFF0h.
2. Error Recovery:
In a scenario where a program causes an infinite loop or crashes due to an error, a
hardware reset button may be pressed. This action asserts the RESET pin, forcing the
microprocessor to stop executing the faulty program and return to its initial state.
For example, if a user encounters a non-responsive application, pressing the reset
button will clear all current operations and restart the system, allowing it to run
normally again.
3. Development and Debugging:
During development or debugging, engineers may use the RESET pin to quickly
restart the microprocessor without needing to power cycle the entire system. This
allows for rapid testing of changes in code or hardware configurations.
In Summary, These pins are essential for managing communication between the 8086
microprocessor and other components in a computer system, ensuring proper
synchronization and control during operations.
Historical Development
The journey of the 80x86 family began with the 8086 processor, which was Intel's
first 16-bit microprocessor. This processor introduced significant advancements over
its predecessors, including a 20-bit address bus, enabling access to 1 MB of memory.
The subsequent release of the 8088 processor, with its 8-bit external data bus, made it
a cost-effective option for personal computers, notably the IBM PC. These early
processors paved the way for widespread adoption of the x86 architecture.
Architectural Features
The 80x86 architecture is based on Complex Instruction Set Computing (CISC),
which allows for a wide range of instructions and addressing modes. Key features
include segmented memory, general-purpose registers, and support for real-mode and
protected-mode operations. The segmented memory model, while initially complex,
allowed the processors to address more memory than their 16-bit design would
otherwise permit.
Modern Developments
In recent years, the x86 architecture, derived from the 80x86 family, has continued to
dominate the computing landscape. Modern processors feature advanced technologies
such as multi-core architectures, hyper-threading, and integrated graphics. The
introduction of 64-bit extensions has further expanded the capabilities of the
architecture, allowing it to address vast amounts of memory.
Competitive Landscape
Despite its dominance, the 80x86 family has faced competition from other
architectures such as ARM and RISC-V. These architectures are known for their
energy efficiency and simplicity, making them popular in mobile devices and low-
power applications. However, the x86 architecture remains a preferred choice for
performance-intensive tasks.
Introduction:
Hardware Interrupts:
INT 2: Cascaded interrupt used for the 8259 Programmable Interrupt Controller
(PIC) for managing hardware interrupt requests.
Hardware interrupts are asynchronous, meaning that they can occur at any time during
the execution of a program.
Software Interrupts:
Software interrupts are initiated by software instructions rather than external hardware
devices. These interrupts are used to trigger specific system services or functions,
often to communicate with the operating system or to invoke system-level operations.
Software interrupts are usually intentionally invoked by the program to request
services such as input/output operations, system calls, or error handling.
INT 10h: Used for video-related services, such as changing screen modes or
displaying text and graphics.
INT 13h: Used for disk operations such as reading and writing sectors on disk
drives.
INT 20h: Terminates the program and returns control to the operating system.
Software interrupts are synchronous, meaning they are initiated during the normal
execution of a program and typically used for invoking system-level functions or error
handling.
Conclusion:
Examples of Directives:
.MODEL: Specifies the memory model (e.g., `.MODEL SMALL`).
.DATA: Declares the data segment where variables are stored.
.DATA
VAR1 DB 10 ; Declares a variable VAR1 with value 10
.CODE: Marks the beginning of the code segment.
EQU: Defines a constant value.
MAXIMUM EQU 100 ; MAXIMUM is now a constant with value 100
MACRO: Defines a reusable block of code.
PRINT MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
ENDM
In conclusion, directives are vital in 8086 programming for efficient code
organization, memory management, and readability. Their proper use ensures the
program is structured, maintainable, and easily understandable.
10 Explain the difference between immediate and indirect operand instructions.
What is Operand ?
Constants/Immediates
Load word and store word, lw and sw, also illustrate the use of constants in MIPS
instructions. These constants are called immediates, because their values are
immediately available from the instruction and do not require a register or memory
access. Add immediate, addi, is another common MIPS instruction that uses an
immediate operand. addi adds the immediate specified in the instruction to a value in
a register.
Example
Immediate Operands
High-Level Code
a = a + 4;
b = a − 12;
MIPS Assembly Code
# $s0 = a, $s1 = b
addi $s0, $s0, 4 # a = a + 4
addi $s1, $s0, −12 # b = a − 12
Constants/Immediates
Load word and store word, lw and sw, also illustrate the use of constants in MIPS
instructions. These constants are called immediates, because their values are
immediately available from the instruction and do not require a register or memory
access. Add immediate, addi, is another common MIPS instruction that uses an
immediate operand. addi adds the immediate specified in the instruction to a value in
a register.
Example
Immediate Operands
High-Level Code
a = a + 4;
b = a − 12;
MIPS Assembly Code
# $s0 = a, $s1 = b
addi $s0, $s0, 4 # a = a + 4
addi $s1, $s0, −12 # b = a − 12
Introduction:
a) Pass by Value:
In the pass by value mechanism, the actual value of the argument is passed to the
function or procedure. This means that a copy of the argument is created and used
within the function. Any changes made to the parameter inside the function do not
affect the original argument in the calling environment.
Example: If a function modifies a parameter, it only modifies the local copy, leaving
the original argument unchanged.
For example:
c
Copy
void addTen(int x) {
x = x + 10; // Modifies the copy of the argument
}
int main() {
int a = 5;
addTen(a);
// 'a' remains 5, as only the copy of 'a' was modified.
}
b) Pass by Reference:
In pass by reference, the address (or reference) of the argument is passed to the
function, not the actual value. This means that the function operates directly on the
argument in the calling environment. Any changes made to the parameter inside the
function will affect the original argument.
Example: When using pass by reference, changes made to the parameter will be
reflected in the original argument because the function works with the memory
location of the argument.
For example:
c
Copy
void addTen(int &x) {
x = x + 10; // Modifies the original argument directly
}
int main() {
int a = 5;
addTen(a);
// 'a' becomes 15, as the original variable is modified.
}
c) Pass by Value-Returned:
In pass by value-returned, the argument is passed by value to the function, and any
changes made to the parameter inside the function are not reflected in the original
variable. However, the function returns the modified value, which can then be
assigned back to the original variable.
Example: The function receives a copy of the argument, modifies it, and then returns
the modified value, which can be assigned to the original variable outside the function.
For example:
c
Copy
int addTen(int x) {
x = x + 10; // Modifies the copy of the argument
return x; // Returns the modified value
}
int main() {
int a = 5;
a = addTen(a); // 'a' is updated with the returned value, now 'a' is 15
}
d) Pass by Name:
Example: Each time the parameter is used in the function, the corresponding
argument is re-evaluated as an expression.
algol
Copy
procedure addTen(x) {
x = x + 10;
}
begin
a := 5;
addTen(a+2); // 'a+2' will be re-evaluated in the function
end;
Here, every use of x within the addTen function will result in a + 2 being evaluated,
instead of passing a simple value.
Conclusion:
Each parameter passing mechanism has its unique behavior and use case:
Pass by value ensures that the original argument remains unchanged by using a
copy.
Pass by reference allows the function to modify the original argument directly by
passing its reference.