Sunday, 16 February 2025

Microprocessor Unit 3 Important Questions And Answers

Q1. List instruction formats of 8086 and explain any one . 4 Marks

Ans: 

The 8086 microprocessor has six types of instruction formats:

  1. Instruction Byte
  2. Register to Register
  3. Register to/from Memory with no Displacement
  4. Register to/from Memory with Displacement
  5. Immediate Operand to Register
  6. Immediate Operand to Memory
  7. Direct Addressing Mode

Explanation of Immediate Operand to Register Instruction Format (8086)

This instruction format is used when a constant (immediate value) is directly loaded into a register.

Format Structure:

  • Opcode: Specifies the operation (e.g., MOV, ADD, etc.).
  • Register: Specifies the destination register.
  • Immediate Data: The constant value to be loaded into the register.


Example Instruction:

MOV AX, 1234H

  • This instruction loads the immediate value 1234H into the AX register.
  • The opcode defines a MOV operation.
  • The register field specifies AX as the destination.
  • The immediate value 1234H is stored directly in the instruction.

Key Features:

Fast execution (No memory access required).
Efficient for loading constants into registers.
Size depends on the register (8-bit or 16-bit).

Q2. Draw Machine language instruction format for register to register transfer. 2 Marks

Ans. 

Explanation of Register to Register Instruction Format

This format is used when data transfer occurs between two registers. The structure of this format is:


  • Opcode: Specifies the operation (e.g., ADD, MOV, etc.).
  • MOD: Defines the addressing mode.
    • 11 means register to register mode.
  • REG: Specifies the destination register.
  • R/M: Specifies the source register.

Example:

MOV AX, BX

  • This moves the content of BX register into AX.
  • The MOD field is 11 (register mode), REG is AX, and R/M is BX.

This instruction format is fast because no memory access is needed.

Q3. State example of immediate addressing mode. S-14, S-16, 2 M

Ans. In immediate addressing mode, the operand (data) is specified directly in the instruction.

Example:

MOV R1, #25

Explanation:
Here, #25 is the immediate data (constant value) that is directly loaded into the register R1. There is no memory access required to fetch the data, making the operation quick.

Q. Define addressing mode. List any two addressing mode of 8086 microprocessor. W-14, S-22, 2 Marks

Ans. 

Addressing mode refers to the way in which the operand (data) is specified in an instruction. It defines how to access the data required for executing an instruction. Addressing modes provide flexibility in accessing data from registers, memory, or directly as an immediate value.

Two Addressing Modes of 8086 Microprocessor:

  1. Immediate Addressing Mode:
    In this mode, the operand is specified directly in the instruction.
    Example: MOV AX, 500 (Here, 500 is an immediate operand)

  2. Register Addressing Mode:
    The operand is stored in a register, and the instruction specifies the register.
    Example: MOV BX, AX (Here, the content of register AX is moved to register BX)

Q. Describe various addressing modes of 8086 with one suitable example each. S-15, S-19, W-19, 4 Marks

Ans. 

The 8086 microprocessor supports several addressing modes to access operands. These modes provide flexibility in accessing data from registers, memory, or directly as immediate values.

1. Immediate Addressing Mode:

In this mode, the operand is specified directly in the instruction.
Example:

MOV AX, 500

Explanation:
The value 500 is directly moved into the AX register.


2. Register Addressing Mode:

The operand is in one of the registers, and the instruction specifies the register.
Example:

MOV BX, AX

Explanation:
The content of the AX register is moved to the BX register.


3. Direct Addressing Mode:

The effective address of the operand is given directly in the instruction.
Example:

MOV AX, [5000H]

Explanation:
The data from memory location 5000H is moved to the AX register.


4. Register Indirect Addressing Mode:

The effective address of the operand is in a register (e.g., BX, SI, DI, BP).
Example:

MOV AX, [BX]

Explanation:
The content at the memory location pointed to by the BX register is moved to AX.


5. Indexed Addressing Mode:

The effective address is the sum of a base address and an index.
Example:

MOV AX, [SI+5000H]

Explanation:
The data from the memory location at (SI + 5000H) is moved to AX.


6. Based Indexed Addressing Mode:

Combines base and index registers to form the effective address.
Example:

MOV AX, [BX+SI]

Explanation:
The content of the memory location at (BX + SI) is moved to AX.

7. Based Indexed with Displacement Addressing Mode:

A displacement is added to the base and index registers to get the effective address.
Example:

MOV AX, [BX+SI+500H]

Explanation:
The data from the memory location at (BX + SI + 500H) is moved to AX.

These addressing modes offer versatility in accessing data and enable efficient instruction execution in 8086 microprocessors.

Q. State and explain any four addressing modes of 8086 microprocessor with example. W-15, 4 Marks

Ans. 

The 8086 microprocessor supports several addressing modes to access operands. These modes provide flexibility in accessing data from registers, memory, or directly as immediate values.

1. Immediate Addressing Mode:

In this mode, the operand is specified directly in the instruction.
Example:

MOV AX, 500

Explanation:
The value 500 is directly moved into the AX register.


2. Register Addressing Mode:

The operand is in one of the registers, and the instruction specifies the register.
Example:

MOV BX, AX

Explanation:
The content of the AX register is moved to the BX register.


3. Direct Addressing Mode:

The effective address of the operand is given directly in the instruction.
Example:

MOV AX, [5000H]

Explanation:
The data from memory location 5000H is moved to the AX register.


4. Register Indirect Addressing Mode:

The effective address of the operand is in a register (e.g., BX, SI, DI, BP).
Example:

MOV AX, [BX]

Explanation:
The content at the memory location pointed to by the BX register is moved to AX.

Q. Define immediate and direct addressing mode. Also give one example of each. S-17, 2 Marks

Immediate Addressing Mode:

In this mode, the operand is specified directly in the instruction.
Example:

MOV AX, 500

Explanation:
The value 500 is directly moved into the AX register.

Direct Addressing Mode:

The effective address of the operand is given directly in the instruction.
Example:

MOV AX, [5000H]

Explanation:
The data from memory location 5000H is moved to the AX register.

Q. State the addressing mode of following instructions: S-22, 6 Marks

i) MOV AX, 3456H

ii) ADD BX, [2000H]

iii) DAA

iv) MOV AX, [Si]

v) MOV AX, BX

vi) SUB AX, [BX + SI + 80H]

Ans. 

Here are the addressing modes for each instruction:

  1. MOV AX, 3456H
    Addressing Mode: Immediate Addressing Mode
    Explanation: The immediate data 3456H is directly moved to the AX register.

  1. ADD BX, [2000H]
    Addressing Mode: Direct Addressing Mode
    Explanation: The content of the memory location 2000H is added to the BX register.

  1. DAA
    Addressing Mode: Implicit Addressing Mode
    Explanation: The DAA (Decimal Adjust after Addition) instruction works directly on the AL register without specifying an operand.

  1. MOV AX, [SI]
    Addressing Mode: Register Indirect Addressing Mode
    Explanation: The data from the memory location pointed to by the SI register is moved to AX.

  1. MOV AX, BX
    Addressing Mode: Register Addressing Mode
    Explanation: The content of the BX register is moved to the AX register.

  1. SUB AX, [BX + SI + 80H]
    Addressing Mode: Based Indexed with Displacement Addressing Mode
    Explanation: The effective address is calculated by adding BX, SI, and 80H, and the data from this memory location is subtracted from AX.
Q. What will be the contents of AX register after execution of following lines of code. W-14, 4 Marks
MOV AL, 10
MOV DL, 20
MUL DL
Ans.

Let's analyze the instructions step-by-step:

  1. Instruction: MOV AL, 10
    Operation: The value 10 is moved to the AL register.
    Result: AL = 10H (10 in hexadecimal is 0AH).

  2. Instruction: MOV DL, 20
    Operation: The value 20 is moved to the DL register.
    Result: DL = 20H (20 in hexadecimal is 14H).

  3. Instruction: MUL DL
    Operation: MUL is an unsigned multiplication of AL by DL.
    The result of MUL is stored in AX, where:

    • AL is the lower 8-bit register of AX.
    • AH is the higher 8-bit register of AX.

    Calculation:
    10×20=20010 \times 20 = 200
    200 in hexadecimal is C8H.

    Result:
    AX = 00C8H

    • AL = C8H (200 in decimal)
    • AH = 00H

Final Answer:

After execution, the content of the AX register will be 00C8H.

MOV AL, 10: This instructions loads OAH in AL register as 10 is considered as decimal number as H is written at the end of number.

MOV DL, 20: This instructions loads 14H in DL register as 10 is considered as decimal number as H is written at the end of number.

MUL DL: This instruction store result 00C8H in AX register which is nothing but 200 in decimal.

Q.  For following instructions. Identify the addressing mode of the following

(i) MUL AL BL
(ii) MOV AX, BX
(iii) MOV BX, [SI]
(iv) MOV DX, 0040H
W-14, 4 Marks
Ans.

Here are the addressing modes for each instruction:

  1. MUL AL, BL
    Addressing Mode: Register Addressing Mode
    Explanation: Both AL and BL are registers, and the multiplication is performed on the contents of these registers.

  1. MOV AX, BX
    Addressing Mode: Register Addressing Mode
    Explanation: The data is transferred directly between two registers (BX to AX).

  1. MOV BX, [SI]
    Addressing Mode: Register Indirect Addressing Mode
    Explanation: The effective address of the data is stored in the SI register, and the data at that address is moved into the BX register.

  1. MOV DX, 0040H
    Addressing Mode: Immediate Addressing Mode
    Explanation: The immediate value 0040H is directly moved to the DX register.

Q. What will be the contents of AL, BL, AX, DX register after the execution of all 4 lines. W-14, 4 Marks
MOV AL. 03H
MOV BL, 03H
SUB AL. BL
MUL AL. 08H
Also write which flags will be affected?

Ans.

Instructions:

  1. MOV AL, 03H
    Operation: The value 03H is moved to the AL register.
    Result:
    AL = 03H

  2. MOV BL, 03H
    Operation: The value 03H is moved to the BL register.
    Result:
    BL = 03H

  3. SUB AL, BL
    Operation: The contents of BL are subtracted from AL.

    03H03H=00H03H - 03H = 00H

    Result:
    AL = 00H

    Flags Affected:

    • Zero Flag (ZF): Set to 1 (since the result is 0).
    • Sign Flag (SF): Set to 0 (since the result is not negative).
    • Carry Flag (CF): Set to 0 (no borrow needed).
    • Overflow Flag (OF): Set to 0 (no signed overflow).
    • Parity Flag (PF): Set to 1 (00H has an even number of 1s in binary: 00000000).
  4. MUL AL, 08H
    Operation: The MUL instruction performs unsigned multiplication.

    00H×08H=0000H00H \times 08H = 0000H

    Result:

    • AL = 00H (Lower byte of the result)
    • AH = 00H (Upper byte of the result)
    • AX = 0000H

    Flags Affected:

    • Carry Flag (CF): Set to 0 (since the upper byte AH is 0).
    • Overflow Flag (OF): Set to 0 (same reason as CF).

Final Register Values:

  • AL = 00H
  • BL = 03H
  • AX = 0000H (since AL = 00H and AH = 00H)
  • DX = Unchanged (since no instruction modifies DX)

Affected Flags:

  • Zero Flag (ZF): 1 (Result of subtraction is zero)
  • Carry Flag (CF): 0 (No borrow or overflow in multiplication)
  • Overflow Flag (OF): 0 (No signed overflow)
  • Sign Flag (SF): 0 (Result is not negative)
  • Parity Flag (PF): 1 (Even parity in AL = 00H)
(1) MOV AL, 03H instruction loads 03H in AL register.

(2) MOV BL, 03F instruction loads 03H in BL register.

(3) SUB AL, BL instruction subtract BL from AL, as numbers in AL and BL are same so result will be 0 in AL and ZF will set.

(4) MUL AL, 08H instruction should be written as MUL 08H and this instruction does not execute because immediate addressing mode for this instruction is not allowed i.e. 08H cannot be used.

Q. Write assembly language instructions to perform following operations. W-14, 4 Marks
(i) Move contains of memory location pointed by DI into BX register
(ii) Copy a string from one memory location to another using string manipulation instruction.
Ans. 

(i) Move contents of memory location pointed by DI into BX register:

MOV BX, [DI]

Explanation:

  • [DI] is the Register Indirect Addressing Mode.
  • The data from the memory location pointed to by the DI register is moved into the BX register.

(ii) Copy a string from one memory location to another using string manipulation instruction:

MOV SI, source_address ; Load source address into SI MOV DI, dest_address ; Load destination address into DI MOV CX, length ; Load the length of the string into CX CLD ; Clear the direction flag (for forward direction) REP MOVSB ; Repeat MOVSB for CX times (copy byte by byte)

Explanation:

  • SI points to the source string (source_address).
  • DI points to the destination string (dest_address).
  • CX holds the count of bytes to copy (length).
  • CLD ensures that copying is done in the forward direction (increments SI and DI).
  • REP MOVSB copies a byte from [SI] to [DI] and auto-increments SI and DI until CX becomes 0.

This is an efficient way to copy a string using the string manipulation instruction MOVSB with the repeat prefix REP.

Q.Write appropriate instructions to perform following operations S-14, 4 Marks
(a) Initialize stack at 42000H
(b) Rotate register BX right 4 times

Ans.
(a) Initialize Stack at 42000H:
MOV SP, 0FFF0H ; Set stack pointer to the offset within the segment MOV SS, 4200H ; Set stack segment to 42000H

Explanation:

  • The SS (Stack Segment) register is loaded with the upper part of the address (4200H × 10H = 42000H).
  • The SP (Stack Pointer) is initialized with 0FFF0H to prevent stack overflow (as SP decrements on PUSH operations).

(b) Rotate Register BX Right 4 Times:

MOV CL, 4 ; Load count 4 into CL ROR BX, CL ; Rotate BX right 4 times

Explanation:

  • CL is used to specify the number of rotations (4 in this case).
  • ROR (Rotate Right) rotates the contents of BX register to the right by 4 bits.
  • Bits shifted out from the right are re-entered from the left, maintaining all 16 bits.
(a) Initialize stack at 42000H

MOV AX, 4000H
MOV SS. AX
MOV SP, 2000H

OR

MOV AX, 4200H
MOV SS, AX
MOV SP, 0000H

(b) Rotate register BX right 4 times

MOV CL, 4
ROR BX, CL

Q. What will be the contents of AX register after execution of following lines of code. W-14, 4 Marks

MOV AL. 10
MOV DL, 20
MUL DL
Ans.

Instructions:

  1. MOV AL, 10
    Operation: Load the value 10 into the AL register.
    Result:
    AL = 10H (10 in decimal is 0AH in hexadecimal)

  2. MOV DL, 20
    Operation: Load the value 20 into the DL register.
    Result:
    DL = 20H (20 in decimal is 14H in hexadecimal)

  3. MUL DL
    Operation: Perform unsigned multiplication of AL by DL.
    The MUL instruction for 8-bit operands multiplies AL by DL and stores the 16-bit result in the AX register.

    Calculation:
    10×20=20010 \times 20 = 200

    • 200 in hexadecimal is C8H.

    Result:

    • AL = C8H (lower 8 bits of the result)
    • AH = 00H (upper 8 bits of the result)
    • AX = 00C8H

Final Answer:

The content of the AX register after execution of all instructions will be:

AX = 00C8H
MOV AL, 10: This instructions loads OAH in AL register as 10 is considered as decimal number as H is written at the end of number.

MOV DL, 20: This instructions loads 14H in DL register as 10 is considered as decimal number as H is written at the end of number.

MUL DL: This instruction store result 00C8H in AX register which is nothing but 200 in decimal.

Q. Identify the addressing mode of the following instructions W-14, 4 Mark

(i) MUL AL BL (ii) MOV AX, BX
(ⅲ) MOV BX,[SI] (iv) MOV DX, 0040H

Ans.
  1. MUL AL, BL
    Addressing Mode: Register Addressing Mode
    Explanation: Both AL and BL are registers, and the multiplication is performed directly using the contents of these registers.

  1. MOV AX, BX
    Addressing Mode: Register Addressing Mode
    Explanation: The data is transferred directly between two registers (BX to AX).

  1. MOV BX, [SI]
    Addressing Mode: Register Indirect Addressing Mode
    Explanation: The memory address is stored in the SI register. The data at this memory location is moved into the BX register.

  1. MOV DX, 0040H
    Addressing Mode: Immediate Addressing Mode
    Explanation: The immediate value 0040H is directly moved into the DX register.
Q. What will be the contents of AL BL AX DX register after the execution of all 4 lines

MOV AL 03H
MOV BL, 03H
SUB AL, BL
MUL AL, 08H
Also write which flags will be affected? W:14. 4 Marks
Ans.
Step-by-Step Execution and Register Contents:

Instructions:

  1. MOV AL, 03H
    Operation: Load 03H into the AL register.
    Result:
    AL = 03H

  2. MOV BL, 03H
    Operation: Load 03H into the BL register.
    Result:
    BL = 03H

  3. SUB AL, BL
    Operation: Subtract the contents of BL from AL.

    03H03H=00H03H - 03H = 00H

    Result:
    AL = 00H

    Affected Flags:

    • Zero Flag (ZF): Set to 1 (since the result is 0).
    • Sign Flag (SF): Set to 0 (since the result is not negative).
    • Carry Flag (CF): Set to 0 (no borrow needed).
    • Overflow Flag (OF): Set to 0 (no signed overflow).
    • Parity Flag (PF): Set to 1 (even parity in binary 00000000).
  4. MUL AL, 08H
    Operation: Unsigned multiplication of AL by 08H.

    00H×08H=0000H00H \times 08H = 0000H

    Result:

    • AL = 00H (Lower 8-bit of AX)
    • AH = 00H (Upper 8-bit of AX)
    • AX = 0000H

    Affected Flags:

    • Carry Flag (CF): Set to 0 (no overflow, as AH = 00H).
    • Overflow Flag (OF): Set to 0 (same as CF).
    • Zero Flag (ZF): Remains 1 (result is still zero).
    • Sign Flag (SF): Remains 0 (result is non-negative).
    • Parity Flag (PF): Remains 1 (parity of 00H is even).

Final Register Contents:

  • AL = 00H
  • BL = 03H
  • AX = 0000H (since AL = 00H and AH = 00H)
  • DX = Unchanged (since no instruction modifies DX)

Affected Flags:

  • Zero Flag (ZF): 1 (result is zero)
  • Sign Flag (SF): 0 (result is non-negative)
  • Carry Flag (CF): 0 (no carry or overflow)
  • Overflow Flag (OF): 0 (no signed overflow)
  • Parity Flag (PF): 1 (even parity)

(1) MOV AL, 03H instruction loads 03H in AL register.

(2) MOV BL, 03F instruction loads 03H in BL register.

(3) SUB AL, BL instruction subtract BL from AL, as numbers in AL and BL are same so result will be 0 in AL and ZF will set.

(4) MUL AL, 08H instruction should be written as MUL 08H and this instruction does not execute because Immediate addressing mode for this instruction is not allowed i.e. 08H cannot be used.

Q. Write assembly language instructions to perform following operations. W-14, 4 Marks

(i) Move contains of memory location pointed by Di into 8X register
(ii) Copy a string from one memory location to another using string manipulation instruction.
Ans.

(i) Move Contents of Memory Location Pointed by DI into BX Register:

MOV BX, [DI]

Explanation:

  • [DI] is the Register Indirect Addressing Mode.
  • The instruction moves the data from the memory location pointed to by the DI register into the BX register.

(ii) Copy a String from One Memory Location to Another Using String Manipulation Instruction:

MOV SI, source_address ; Load source address into SI MOV DI, dest_address ; Load destination address into DI MOV CX, length ; Load the length of the string into CX CLD ; Clear Direction Flag for forward direction REP MOVSB ; Copy CX bytes from [SI] to [DI]

Explanation:

  • SI is the Source Index register pointing to the start of the source string (source_address).
  • DI is the Destination Index register pointing to the start of the destination (dest_address).
  • CX is the Counter Register holding the length of the string (length).
  • CLD (Clear Direction Flag) ensures that the copying proceeds in the forward direction (auto-increments SI and DI).
  • REP MOVSB (Repeat Move String Byte) copies a byte from [SI] to [DI], repeating this until CX becomes 0.

This method is efficient for copying strings using the string manipulation instruction MOVSB with the repeat prefix REP.

Q. Identify addressing modes in following -14, 4 Marks

i) MOV AX, 2050H
ii) STC
iii)  MOV AL, DS:[SI]
(iv) INC BX

MOV AX, 2050H

Addressing Mode: Immediate Addressing
Explanation: The constant 2050H is directly provided in the instruction and loaded into the register AX.

STC

Addressing Mode: Implied (or Inherent) Addressing
Explanation: This instruction does not require an operand. It simply sets the carry flag.
MOV AL, DS:[SI]
Addressing Mode: Register Indirect Addressing
Explanation: The effective address is calculated using the SI register. The data is fetched from memory at the location pointed to by SI in the DS segment and moved into AL.

INC BX
Addressing Mode: Register Addressing
Explanation: The operand is a register (BX) and the instruction operates directly on it.

Q. What will be content of register BX after the execution of instructions.
MOV BX, D50H
MOV CL, 05H
SHL BX,CL
Ans.

Let's analyze the given assembly instructions step by step:

Step 1: MOV BX, D50H

  • This instruction moves the hexadecimal value D50H into the BX register.
  • D50H in binary: D50H=1101 0101 00002\text{D50H} = 1101\ 0101\ 0000_2
  • So, BX = 1101 0101 0000₂ (16-bit representation).

Step 2: MOV CL, 05H

  • This instruction moves the hexadecimal value 05H into the CL register.
  • CL = 0000 0101₂ (5 in decimal).

Step 3: SHL BX, CL

  • The SHL (Shift Left) instruction shifts the bits in BX left by the number of positions specified in CL (which is 5).
  • SHL shifts left and fills the least significant bits (LSBs) with 0.
  • Each shift left effectively multiplies the number by 2.

Shifting BX = 1101 0101 0000₂ left by 5 bits:

1101 0101 0000 (D50H) 1. 1010 1010 0000 0 2. 0101 0100 0000 00 3. 1010 1000 0000 000 4. 0101 0000 0000 0000 5. 1010 0000 0000 0000
  • The final result is:
    BX = 1010 0000 0000 0000₂ (A000H in hexadecimal).

Final Answer:

After execution, BX = A000H.

Q. Identify the addressing mode used in following Instructions:
(a) MOV DS, AX
(b) MOV AX, [4172H]
(c) ADD AX, [SI]
(d) ADD AX, [SI][BX][04]

 S-14, 4 Marks
Ans.

(a) MOV DS, AX

  • This instruction moves the contents of the AX register into the DS (Data Segment) register.
  • The operand AX is a register operand.
  • Addressing Mode: Register Addressing Mode
    (Since both source and destination are registers, this is a register-to-register move.)

(b) MOV AX, [4172H]

  • This instruction moves the contents of the memory location at address 4172H into the AX register.
  • The operand [4172H] refers to a direct memory address.
  • Addressing Mode: Direct Addressing Mode
    (The address is explicitly mentioned in the instruction.)

(c) ADD AX, [SI]

  • This instruction adds the contents of the memory location pointed to by SI (Source Index Register) to the AX register.
  • Here, SI holds the memory address (offset), and the actual data comes from that memory location.
  • Addressing Mode: Register Indirect Addressing Mode
    (The effective address is given by the contents of the register SI.)

(d) ADD AX, [SI][BX][04]

  • This instruction adds the value stored at the memory address formed by SI + BX + 04H to the AX register.
  • Here:
    • SI and BX are registers containing memory addresses.
    • 04H is a displacement (offset).
  • Addressing Mode: Base Index with Displacement Addressing Mode
    (A combination of base (BX), index (SI), and displacement (04H) is used to compute the memory address.)

Summary of Addressing Modes

InstructionAddressing Mode
MOV DS, AXRegister Addressing
MOV AX, [4172H]Direct Addressing
ADD AX, [SI]Register Indirect Addressing
ADD AX, [SI][BX][04]Base Index with Displacement

(a) MOV DS, AX : Register addressing mode

(b) MOV AX, [4172H] : Direct addressing mode

(c) ADD AX, [SI] : Indirect or indexed addressing mode

(d) ADD AX, [SI] [BX] [04]: Relative base index addressing mode

Q. 



No comments:

Post a Comment

Desktop Virtualisation

Desktop Virtualization ( DV ) Desktop Virtualization ( DV ) is a technique that creates an illusion of a desktop provided to the user. It d...