0% found this document useful (0 votes)
29 views17 pages

8086 Questions DSE

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views17 pages

8086 Questions DSE

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Vivekanand Education Society's Institute of

Technology
An Autonomous Institute Affiliated to University of Mumbai

1. Give the advantages of memory segmentation of 8086 microprocessors. (5 marks)


Ans: Advantages of the Segmentation
The main advantages of segmentation are as follows:
o It provides a powerful memory management mechanism.
o Data related or stack related operations can be performed in different segments.
o Code related operation can be done in separate code segments.
o It allows to processes to easily share data.
o It allows to extend the address ability of the processor, i.e. segmentation allows the use
of 16 bit registers to give an addressing capability of 1 Megabytes. Without
segmentation, it would require 20 bit registers.
o It is possible to enhance the memory size of code data or stack segments beyond 64 KB
by allotting more than one segment for each area.

2. Explain all Registers ( 10 M )


Ans:
1. Sign Flag: It occupies the seventh bit of the flag register, which is also known as the most
significant bit. It helps the programmer to know whether the number stored in the
accumulator is positive or negative. If the sign flag is set, it means that number stored in
the accumulator is negative, and if reset, then the number is positive.
2. Zero Flag:: It occupies the sixth bit of the flag register. It is set, when the operation
performed in the ALU results in zero(all 8 bits are zero), otherwise it is reset. It helps in
determining if two numbers are equal or not.
3. Auxiliary Carry Flag: It occupies the fourth bit of the flag register. In an arithmetic
operation, when a carry flag is generated by the third bit and passed on to the fourth bit,
then Auxiliary Carry flag is set. If not flag is reset. This flag is used internally for
BCD(Binary-Coded decimal Number) operations. Note – This is the only flag register in
8085 which is not accessible by user.
4. Parity Flag: It occupies the second bit of the flag register. This flag tests for number of
1’s in the accumulator. If the accumulator holds even number of 1’s, then this flag is set
and it is said to even parity. On the other hand if the number of 1’s is odd, then it is reset
and it is said to be odd parity.
5. Carry Flag: It occupies the zeroth bit of the flag register. If the arithmetic operation
results in a carry(if result is more than 8 bit), then Carry Flag is set; otherwise it is reset.

3. Differentiate Procedure and macro with example. (5 marks)

Serial Macro Procedure


No.
1 A macro is a series of programmable Procedures are designed for a
patterns, translating a specific sequence of large set of instructions to
input into a preset sequence of output. execute a specific task.
2 A macro is employed for a small batch of A procedure is employed for a
instructions. larger batch of instructions.
3 More memory is required in the case of a Less memory is required in the
macro. case of a procedure.
4 In a macro, the CALL and RET instructions In a procedure, CALL and RET
are not necessary. instructions are necessary.
5 The execution time in a macro is lesser than The execution time in a
that in a procedure. procedure is more than that in a
macro.
6 In a macro, the machine code is constructed In a procedure, the machine code
multiple times. is created just once.

7 A macro parameter is passed as a part of a In a procedure, parameters are


statement that calls the macro. passed in registers or memory
locations of the stack.

4. Explain the minimum mode configuration of 8086 microprocessors. (10 marks)

The Minimum Mode of the 8086 microprocessor is designed for systems wherein the processor
shares the gadget bus with different devices and does not act as the bus controller. This mode is
commonly utilized in single-processor systems or while the device calls for fewer assets and a
much less complex configuration.
Key features of the Minimum Mode encompass:

1. Bus Controller: In Minimum Mode, the microprocessor relies on an outside bus controller,
which includes the 8284 clock generator, to address bus control indicators and bus arbitration.
The bus controller coordinates the activities of various devices linked to the machine bus.
2. Single Processor: The Minimum Mode is generally used in unmarried-processor structures
wherein the microprocessor is the number one processing unit and does not require the
complexities related to multiprocessor structures.
3. Limited Address and Data Lines: In Minimum Mode, most effective 16 address traces and
16 facts lines of the 8086 microprocessor are utilized, proscribing the reminiscence
addressing skills and I/O options compared to the Maximum Mode.
4. Reduced Complexity: The Minimum Mode configuration simplifies the machine design
with the aid of offloading bus manager obligations to an external bus controller, decreasing
the overall complexity and price of the gadget.

5. Write a program to find the largest number from an array. (5 marks)

2000 LXI H 2050 H←20, L←50


2003 MOV C, M C←M
2004 DCR C C←C-01
2005 INX H HL←HL+0001
2006 MOV A, M A←M
2007 INX H. HL←HL+0001
2008 CMP M A-M
2009 JNC 200D If Carry Flag=0, goto 200D
200C MOV A, M A←M
200D DCR C C←C-1
200E JNZ 2007 If Zero Flag=0, goto 2007
2011 STA 3050 A→3050
2014 HLT

6. Explain different addressing modes of 8086 microprocessor. (10 marks)


The 8086 microprocessor uses several addressing modes to access data and instructions. Each
mode provides different ways to specify the operands for instructions. Here are the primary
addressing modes of the 8086 microprocessor:

1. Immediate Addressing Mode


In this mode, the operand is specified directly in the instruction. The value is part of the
instruction itself. For eg MOV AX, 5H; Move the immediate value 5h into register AX

2. Register Addressing Mode

The operand is located in a register, which is specified in the instruction for eg : MOV BX, AX ;
Move the value from AX to BX

3. Direct Addressing Mode

The effective address of the operand is given explicitly in the instruction. This mode accesses a
specific memory address. MOV AX, [1234h]; Move the value from memory address 1234h into
AX

4. Indirect Addressing Mode

The address of the operand is held in a register (or a memory location). The effective address is
determined by the contents of the register. MOV AX, [BX]; Move the value from the memory
address pointed to by BX into AX

5. Based Addressing Mode

This mode uses a base register (such as BX or BP) along with a displacement to compute the
effective address. MOV AX, [BX + 5]; Move the value from memory address (BX + 5) into AX

6. Indexed Addressing Mode

In this mode, an index register (such as SI or DI) is used along with a displacement to calculate
the effective address. MOV AX, [SI + 10] ; Move the value from memory address (SI + 10) into
AX

7. Register Indirect Addressing Mode

The operand's address is given in a register. It can use segment registers in conjunction with other
registers. MOV AX, [DI] ; Move the value from the address contained in DI into AX

8. Relative Addressing Mode

This mode computes the effective address by adding a displacement to the address of the next
instruction. It is commonly used for control flow instructions. JMP label ; Jump to a label, where
the address is calculated relative to the current instruction

9. String Addressing Mode


Used specifically for string operations, it utilizes SI and DI registers to point to the source and
destination of string data. MOVSB ; Move byte from address in DS:SI to ES:DI

Each addressing mode provides flexibility in how operands are accessed and manipulated in the
8086 microprocessor. Understanding these modes is crucial for effective assembly programming
and optimizing performance.

7. Draw and explain memory read and memory write machine cycle timing diagrams in maximum
mode of 8086.(10 marks)

8. Explain the following:i) Types of interrupts (5 marks)


9. Explain the internal hardware architecture of 8086 microprocessor with neat diagram?

10. Explain Data transfer, arithmetic and branch instructions ?


11. Write an 8086 ALP to find the spum of numbers in the array of 10 elements?.

12. Write a note about stack, procedures and macros?.

13. Define interrupt and their two classes? Write in detail about interrupt service routine?.

Ans: An interrupt is a mechanism that allows the 8086 microprocessor to pause its current
execution to handle a specific event, typically triggered by hardware or software. After
processing the interrupt, the CPU can return to its original task. This mechanism enables efficient
multitasking and responsive system performance.

Interrupts can be classified into two main categories:

Hardware Interrupts: These are signals generated by hardware devices, indicating that they
require the CPU's attention

Software Interrupts: These interrupts are generated by programs or the operating system itself.

An Interrupt Service Routine (ISR) is a critical component of computer architecture that allows
the CPU to respond promptly to events requiring immediate attention. It is a specialized function
that handles the execution of code in response to an interrupt signal, effectively enabling
multitasking and real-time processing in a system.

An interrupt is a signal that tells the CPU to stop its current activities and execute a specific piece
of code (the ISR) to handle an event. Interrupts can come from hardware devices (e.g.,
keyboards, mice, disk drives) or be generated by software (e.g., system calls, exceptions).

Key Functions of an ISR

1. Event Handling: The primary function of an ISR is to respond to events. For instance, when
a keyboard key is pressed, an ISR can read the keystroke and store it in a buffer for further
processing.
2. Task Management: ISRs help manage tasks by handling asynchronous events, allowing the
CPU to perform other operations without waiting for the event to complete.
3. Resource Management: ISRs often manage hardware resources, such as reading from I/O
ports or communicating with other hardware components.

14. Write a short note about(i)Loop, NOP and HLT instructions


Ans: 1. Loop Instruction
The LOOP instruction is used to create loops in assembly language programming. It decrements
the value of the CX register (or ECX in 32-bit architecture) and continues execution of a
specified block of code as long as CX is not zero. This is useful for repeating operations a fixed
number of times.
2. NOP Instruction
The NOP (No Operation) instruction is used to do nothing for one clock cycle. It is essentially a
placeholder that can be useful for timing adjustments or creating delays in a program. It can also
be used in debugging or to fill space in code.
3. HLT Instruction
The HLT (Halt) instruction is used to stop the execution of the CPU until an interrupt occurs.
When the CPU encounters a HLT instruction, it enters a halt state, conserving power and
resources.

15. What is microprocessor? What is the difference between a MP and CPU?


Ans: A microprocessor is a compact integrated circuit (IC) that serves as the central processing
unit (CPU) of a computer system. It performs arithmetic and logic operations, manages data flow
between various components, and executes instructions from programs. Microprocessors are built
on a single silicon chip and contain the essential components of a CPU, including the arithmetic
logic unit (ALU), control unit, and registers. They are used in a wide range of devices, from
personal computers and smartphones to embedded systems in appliances and vehicles.

MICROPROCESSR CPU
Refers specifically to a CPU that is integrated Refers to the entire processing unit of a
onto a single chip. It encapsulates all the computer, which may include multiple chips.
necessary components for processing data and The CPU encompasses not only the
executing instructions. microprocessor but also other supporting
components like cache memory and
sometimes external controllers.
Typically consists of a single silicon chip that May consist of multiple microprocessors or a
includes the ALU, control unit, and registers. combination of microprocessors and
It is designed to perform basic processing additional processing units (such as GPUs)
tasks. and memory management units (MMUs),
depending on the architecture of the system
Examples include Intel's 8086, ARM Cortex, The term can refer to a multi-core CPU,
and AMD Ryzen chips. where multiple microprocessor cores are
integrated to enhance processing power, such
as an Intel Core i7.
16. Why the program counter and stack pointer are registers of 16 bit?.

The 8086 microprocessor is designed with a 16-bit architecture, meaning it processes 16 bits of
data simultaneously. This architecture defines the size of its registers, including the PC and SP.
The 8086 has a 16-bit data bus, allowing it to read or write 16 bits of data in a single operation.
This influences the size of all internal registers, including the PC and SP.

1. Program Counter (IP)

The Program Counter is implemented as the Instruction Pointer (IP) register. It holds the
address of the next instruction to be executed.

Addressable Memory: The 8086 can address up to 1 MB of memory. However, it uses a


segmented memory model, where addresses are computed based on segment registers (16 bits)
and the offset (also 16 bits). The 16-bit IP is sufficient for addressing instructions within a
segment.

2. Stack Pointer (SP)

The Stack Pointer (SP) register in the 8086 points to the top of the stack in memory, which is
used for temporary storage of data, return addresses, and local variables.

Memory Management: The stack operates in a segment-based model where the segment
address (from the stack segment register, SS) and the offset (given by the SP) form a complete
address. A 16-bit SP allows the stack to manage addresses effectively within a 64 KB segment.

17. What are the 8086 instructions used for BCD arithmetic?
ANS. BCD (Binary-Coded Decimal) arithmetic instructions in 8086 are:
1. DAA (Decimal Adjust AL after Addition): Adjusts the result of adding two packed BCD
numbers to ensure a valid BCD result.
2. DAS (Decimal Adjust AL after Subtraction): Adjusts the result of subtracting two packed
BCD numbers to ensure a valid BCD result.
3. AAA (ASCII Adjust AL after Addition): Adjusts the result of adding two unpacked BCD
numbers to ensure a valid BCD result in ASCII format.
4. AAS (ASCII Adjust AL after Subtraction): Adjusts the result of subtracting two unpacked
BCD numbers to ensure a valid BCD result in ASCII format.
5. AAM (ASCII Adjust AX after Multiplication): Adjusts the result of multiplying two
unpacked BCD numbers.
6. AAD (ASCII Adjust AX before Division): Converts two unpacked BCD digits in AX into a
binary number before division.

18. List any four program control instructions available in 8086.


1. CALL: Used to call a procedure.
2. RET: Used to return from a procedure.
3. JMP: Unconditional jump to a specified address.
4. LOOP: Decreases the count in the CX register and jumps to a label if CX ≠ 0.
19. How will carry and zero flags reflect the result of the instruction CMP BX, CX?
 CMP BX, CX performs a subtraction of CX from BX without storing the result.
 If BX = CX, the Zero flag (ZF) will be set (ZF = 1), and Carry flag (CF) will be cleared (CF
= 0).
 If BX > CX, the Zero flag will be cleared (ZF = 0), and Carry flag will be cleared (CF = 0).
 If BX < CX, the Zero flag will be cleared (ZF = 0), and the Carry flag will be set (CF = 1).

20. Give any four miscellaneous instructions in 16-bit processor?


 NOP (No Operation): Does nothing for one clock cycle.
 HLT (Halt): Halts the processor until the next hardware interrupt occurs.
 WAIT: The processor waits for the TEST pin to become low.
 ESC (Escape): Used to transfer control to an external device like a coprocessor.

21. List the flags of 8086. Draw the flag register format of 8086 microprocessor.

Ans. The flags in 8086 are divided into two categories: Status Flags and Control Flags.

Status Flags:

1. Carry Flag (CF): Indicates an overflow from the most significant bit.
2. Parity Flag (PF): Set if the number of set bits in the result is even.
3. Auxiliary Carry Flag (AF): Used in BCD arithmetic.
4. Zero Flag (ZF): Set if the result is zero.
5. Sign Flag (SF): Indicates the sign of the result (0 for positive, 1 for negative).
6. Overflow Flag (OF): Indicates an overflow in signed arithmetic.

Control Flags:

7. Trap Flag (TF): Enables single step debugging.


8. Interrupt Flag (IF): Enables or disables interrupts.
9. Direction Flag (DF): Determines the direction for string operations (increment or
decrement).
22. How is physical address generated in 8086?

Ans. The physical address in 8086 is generated by combining the segment address and the offset
address. The segment address is shifted left by 4 bits (multiplied by 16) and then added to the
offset address. The formula for physical address calculation is:
Physical Address = (Segment Address * 16) + Offset Address
For example, if the segment address is 1234H and the offset is 5678H, the physical address
would be:
Physical Address = (1234H * 10H) + 5678H
= 12340H + 5678H = 179B8H

23. List any two external hardware synchronization instruction of 8086 microprocessor?
Ans. Two external hardware synchronization instructions of the 8086 microprocessor are:

1. LOCK: This instruction is used to ensure that the bus is locked during the execution of
certain critical instructions, preventing other processors or devices from accessing shared
memory.
2. WAIT: The WAIT instruction causes the processor to halt its execution until the Test pin
(TEST#) is active, which is used for synchronization with external hardware.

24. What are the 8086 instructions used for ASCII arithmetic.
Ans. The instructions are:
AAA (ASCII Adjust after Addition): After performing an addition of two ASCII characters, this
instruction adjusts the result to ensure it is a valid unpacked BCD (Binary Coded Decimal) value.
AAS (ASCII Adjust after Subtraction): After performing a subtraction of two ASCII characters,
this instruction adjusts the result to a valid unpacked BCD value.
Other instructions used for ASCII arithmetic include:
AAM (ASCII Adjust after Multiply): Adjusts the result of a multiplication of two ASCII values.
AAD (ASCII Adjust before Division): Prepares two unpacked BCD digits in AX for division.

25. List any four features of 8086


Ans: Here are four key features of the 8086 microprocessor:
1. 16-bit Architecture: The 8086 is a 16-bit microprocessor, meaning it has a 16-bit data bus and
can process 16 bits of data in a single cycle.
2. 20-bit Address Bus: It has a 20-bit address bus, allowing it to address up to 1 MB of memory
directly.
3. Segmented Memory: The 8086 uses a segmented memory architecture, dividing memory into
segments (code, data, stack, extra) for more efficient management of the 1 MB address space.
4. Instruction Set: It supports a wide range of instructions, including arithmetic, logical, control,
and data transfer instructions, making it versatile for various computing tasks.
26. Define Pipeline.
Pipeline is a technique in computing where multiple instruction stages (fetch, decode, execute,
etc.) are processed simultaneously to increase efficiency, allowing different instructions to be
executed in parallel.

27. State the function of following pins of 8086. (a) TEST (b) BHE
Here are the functions of the specified pins in the 8086 microprocessor:
(a) TEST Pin: The TEST pin is an input pin used in conjunction with the WAIT instruction. It
allows the 8086 to check if an external device is ready. If the TEST pin is low, the processor
will continue execution; if high, it will wait until the TEST pin goes low.
(b) BHE (Bus High Enable): The BHE pin is used to indicate that there is a data transfer on the
upper byte (D8-D15) of the 16-bit data bus. It is used when the processor accesses a 16-bit
data word or the higher byte of an 8-bit word. It helps manage data in odd or even memory
banks.

28. State the function of following pins of 8086. (a) ALE (b) DT/R 4 Marks
Here are the functions of the following pins in the 8086 microprocessor:

(a) ALE (Address Latch Enable): This pin is used to indicate when the address is available on the
multiplexed address/data bus (AD0-AD15). ALE is high during the first clock cycle,
signalling external latches to capture the address. After this, the bus is used for data, and ALE
goes low.

(b) DT/R (Data Transmit/Receive): This pin is used to control the direction of data flow through
the data bus transceivers. When **DT/R** is high, the 8086 is transmitting data (sending);
when low, it is receiving data. It helps manage the direction of communication between the
processor and external devices.

31) Draw architecture of 8086 and Label it.


32) Write any four important functions of EU

1) Instruction execution: excutes arithmetic, logic, and data movement instruction


2) Flag register: modifies flags based on the result of operation
3) Instruction Decoding: Decode the fetched instruction from the instruction queue
4) Control operation: Manages program flow using jump, call, and loop instruction.

33) Write any four important functions of BIU.

1) Instruction Fetching: BIU fetches instruction from memory into the instruction queue
2) Address generation: It calculates physical address using segment and offset value
3) Data transfer: handles the transfer of data between the processor and memory or I\O devices
4) Instruction Queue management: Maintains a queue of perfected instruction to speed up
processing

34) What is memory segmentation? How it is done in 8086 microprocessor.

Memory segmentation is a technique used to divide the memory into segments to improve
memory management and access .In the 8086 microprocessor the total 1mb memory is divided
into segments of up to 64kb each
How it’s done:
The 8086 uses segments register (CS,DS,SS,ES)to point to the start of a segment
An offset address is used to access a specific location within a segments
The phycial address is calucated as:Physcial address = (segment register*16) + offset

35) Describe following assembler directives. (a) DD (b) STRUCT

a) DD: Define Double word


This directive allows the initialization of single or multiple data in the form of double words (i.e.,
4 bytes). The is used to inform the assembler that the stored data in memory is a double word.

Thus memory stores the given data in the form:

b) STRUCT (Structure Declaration)


• STRUCT is used to define data structures in assembly language, similar to how
structures are defined in high-level languages like C.
• It allows grouping of different data types (e.g., bytes, words, double words) into a single,
composite structure.
• A structure helps in organizing related data together, making it easier to handle complex
data like records.
Syntax: asm
Copy code
STRUCT structName
field1Type field1Name
field2Type field2Name

37. Describe following assembler directives. (a) EQU (b) EVEN


Ans: (a) EQU
The EQU directive is used to define a constant or symbolic name in assembly language. It
assigns a value to a label or symbol, allowing you to use the label in your code instead of the
actual value. This can improve code readability and maintainability. For example:
Assembly
Copy code
MAX_SIZE EQU 100
In this case, MAX_SIZE can be used throughout the code in place of the literal value 100.
(b) EVEN
The EVEN directive is used to align the next instruction or data to an even memory address. In
many architectures, instructions or data are more efficiently accessed at even addresses. Using
EVEN helps ensure proper alignment, which can enhance performance and prevent potential
access issues.
For example:
Assembly
Copy code
EVEN
DATA BYTE 0xFF
In this example, the assembler will insert padding if necessary to ensure that DATA starts at an
even address.

38. Difference between Assembler Directive and Instructions.


Ans:

Feature Assembler Directives Instructions


Definition Commands for the assembler Commands for the CPU
Purpose Guide the assembly process Perform operations on data
Examples EQU, ORG, DB, DW, END, EVEN MOV, ADD, SUB, JMP, CALL
Feature Assembler Directives Instructions
Execution Not executed by the CPU Executed by the CPU
Effect on Control layout, define constants, allocate Alter program behavior, perform
Code memory calculations
Syntax Typically start with a dot or keyword Consist of an opcode and operands

39. Identify the addressing mode of the following instructions. (a) MUL AL,BL (b) MOV
DX,0040H 40.
Ans:
(a) MUL AL, BL
Addressing Mode: Register Addressing Mode : In this instruction, both AL and BL are
registers. The operation multiplies the contents of the AL register by the contents of the BL
register. Since both operands are specified as registers, it uses the register addressing mode.
(b) MOV DX, 0040H
Addressing Mode: Immediate Addressing Mode : In this instruction, 0040H is a constant value
(immediate data) that is being moved into the DX register. The immediate value is specified
directly in the instruction, indicating that it uses immediate addressing mode.

40. Explain the following instruction of 8086 (a) XLAT (b) XCHG
Ans:
XCHG − Used to exchange the data from two locations.
Description: The XCHG instruction exchanges the values of two operands. These can be
registers, memory locations, or a combination of both.
Operation: The values of the two specified operands are swapped. For example, XCHG AX, BX
will exchange the contents of registers AX and BX.
If one of the operands is in memory, the instruction will perform a memory-to-register or
register-to-memory exchange
XLAT − Used to translate a byte in AL using a table in the memory
Description: The XLAT instruction translates a byte using a lookup table. It uses the contents of
the AL register as an index to access a byte in a table located in memory.
Operation: The effective address of the table is determined by the BX register (or EBX in 32-bit
mode) plus an optional displacement (if specified).
The byte at the effective address ([BX + AL]) is loaded into AL, effectively replacing the value
of AL with the value found at that address.

41. Explain the following instruction of 8086 (a) CALL (b) RET
(a) CALL
Description: The CALL instruction is used to call a procedure (subroutine) within a program. It
transfers control to the specified procedure and saves the address of the next instruction to return
to after the procedure finishes executing.
Operation:
When a CALL instruction is executed, the current value of the instruction pointer (IP) is pushed
onto the stack. This IP value points to the next instruction after the CALL.
The control is then transferred to the address specified by the operand (which can be an
immediate value, a direct address, or a label).
(b) RET
Description: The RET instruction is used to return control from a procedure back to the calling
point in the program. It retrieves the saved return address from the stack.
Operation:
When RET is executed, it pops the top value from the stack (which is the return address that was
pushed by the CALL instruction) into the instruction pointer (IP).
This action transfers control back to the instruction immediately following the original

42. With suitable example explain following instruction. (a) DAA (b) ADC (c ) MUL (d) AAM 4
Explain any four logical instructions of 8086 microprocessor with example.
Ans:- Arithmetic Instructions
(a) DAA (Decimal Adjust for Addition)
The DAA instruction is used after an addition operation to adjust the result for BCD (Binary-
Coded Decimal) numbers.
Example: If you add two BCD numbers 25 (0010 0101) and 35 (0011 0101):
ADD Result: 60 (0011 1100)
DAA: Adjusts the result from 60 to 25 (0010 0101) + 35 (0011 0101) = 60. DAA converts this to
the correct BCD representation.
(b) ADC (Add with Carry)
ADC adds two operands along with the carry flag (CF). This is useful for multi-byte arithmetic
operations.
Example:
MOV AL, 25h ; AL = 25h (37 decimal)
MOV BL, 35h ; BL = 35h (53 decimal)
ADD AL, BL ; AL = AL + BL = 25h + 35h = 5Ah
; Assume carry is set from a previous operation
ADC AL, 01h ; AL = AL + 01h + CF
If CF = 1, AL would become 5Bh; if CF = 0, AL remains 5Ah.
(c) MUL (Multiply)
MUL performs unsigned multiplication. The result is stored in the DX
register pair.
Example:
MOV AL, 04h ; AL = 4
MOV BL, 03h ; BL = 3
MUL BL ; DX:AX = AL * BL = 4 * 3 = 0Ch
Here, AX will contain 0Ch (12 in decimal), and DX will be 0 (since the product fits in AX).
(d) AAM (ASCII Adjust AX After Multiply)
AAM adjusts the AX register after a multiplication operation to BCD representation.
Example: After multiplying two BCD values, AAM can be used to convert the result:
MOV AL, 25h ; AL = 25 (BCD)
MOV BL, 03h ; BL = 3
MUL BL ; AX = 75 (in binary)
AAM ; Adjusts AX to BCD
This changes AX to 75h (BCD) representation.
Logical Instructions of 8086
1. AND
AND performs a bitwise AND operation between two operands.
Example:
MOV AL, 0Fh ; AL = 0000 1111
MOV BL, 0Ch ; BL = 0000 1100
AND AL, BL ; AL = AL AND BL = 0000 1100 (0Ch)
2. OR
OR performs a bitwise OR operation between two operands.
Example:
MOV AL, 0Fh ; AL = 0000 1111
MOV BL, 0Ch ; BL = 0000 1100
OR AL, BL ; AL = AL OR BL = 0000 1111 (0Fh)
3. XOR
XOR performs a bitwise exclusive OR operation between two operands.
Example:
MOV AL, 0Fh ; AL = 0000 1111
MOV BL, 0Ch ; BL = 0000 1100
XOR AL, BL ; AL = AL XOR BL = 0000 0011 (3)
4. NOT
NOT performs a bitwise NOT operation, flipping all bits of the operand.
Example:
MOV AL, 0Fh ; AL = 0000 1111
NOT AL ; AL = NOT AL = 1111 0000
These logical instructions are fundamental for manipulating binary data, allowing you to set,
clear, or toggle bits as needed in various applications.
43. List and explain any four string operation instruction.
Ans:- 1. MOVS (Move String)
The MOVS instruction is used to move a block of data from the source string to the destination
string. The direction of the operation is controlled by the Direction Flag (DF).
Usage:
MOVS BYTE PTR [DI], BYTE PTR [SI] (for byte strings)
MOVS WORD PTR [DI], WORD PTR [SI] (for word strings)
Example:
Assume DS:SI points to the source string and ES:DI points to the destination
MOV CX, 5 ; Number of bytes/words to move
CLD ; Clear direction flag (incrementing mode)
REP MOVSB ; Move CX bytes from DS:SI to ES:DI
Here, the REP MOVSB instruction will move 5 bytes from the source to the destination.
2. CMPS (Compare String)
The CMPS instruction compares two strings. The comparison is done byte by byte or word by
word, depending on whether the operand is BYTE or WORD.
Usage:
CMPS BYTE PTR [SI], BYTE PTR [DI]
CMPS WORD PTR [SI], WORD PTR [DI]
Example:
MOV CX, 5 ; Number of bytes/words to compare
CLD ; Clear direction flag (incrementing mode)
REP CMPSB ; Compare CX bytes from DS:SI and ES:DI
The result of the comparison will set the flags accordingly (ZF, CF, etc.) for further conditional
branching.
3. SCAS (Scan String)
SCAS scans a string for a specified value in the AL register. It compares the value in AL with
each byte/word of the string, starting from the address in DI.
Usage:
SCASB (for byte strings)
SCASW (for word strings)
Example:
MOV AL, 'A' ; Value to search for
MOV CX, 10 ; Number of bytes to scan
CLD ; Clear direction flag (incrementing mode)
REP SCASB ; Scan CX bytes starting at ES:DI
After execution, the status of the flags will indicate whether the value was found.
4. STOS (Store String)
STOS stores the value from AL (for bytes) or AX (for words) into a destination string pointed to
by DI. This instruction is useful for initializing or filling memory with a specific value.
Usage:
STOSB (for byte strings)
STOSW (for word strings)
Example:
MOV AL, 0FFh ; Value to store
MOV CX, 10 ; Number of bytes to store
CLD ; Clear direction flag (incrementing mode)
REP STOSB ; Store AL into ES:DI for CX times
This will fill the memory starting at ES
With the value in AL, repeating it 10 times.

44. Write assembly language instructions of 8086 microprocessor to (a) Divide the content of AX
register by 50H (b) Rotate the content of BX register by 4 bit toward left.
Ans:- (a) Divide the content of AX register by 50H
To divide the content of the AX register by 50H, we can use the DIV instruction. The result will
be stored in the AL register (quotient), and any remainder will be in the AH register.
Example Code:
Assume AX contains the dividend
MOV AX, 1234h ; Load AX with the dividend (for example)
MOV BX, 50h ; Load BX with the divisor (50H)
DIV BX ; Divide AX by BX (AX / BX)
; After the DIV instruction:
; AL = Quotient
; AH = Remainder

(b) Rotate the content of BX register by 4 bits toward left


To rotate the contents of the BX register to the left by 4 bits, we can use the ROL (Rotate Left)
instruction.
Example Code:
Assume BX contains the value to rotate

MOV BX, 0ABCDh ; Load BX with some value (for example)


ROL BX, 4 ; Rotate the contents of BX left by 4 bits

You might also like