Q1. List instruction formats of 8086 and explain any one . 4 Marks
Ans:
The 8086 microprocessor has six types of instruction formats:
- Instruction Byte
- Register to Register
- Register to/from Memory with no Displacement
- Register to/from Memory with Displacement
- Immediate Operand to Register
- Immediate Operand to Memory
- 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
1234Hinto theAXregister. - The opcode defines a MOV operation.
- The register field specifies
AXas the destination. - The immediate value
1234His 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.
11means 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:
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:
-
Immediate Addressing Mode:
In this mode, the operand is specified directly in the instruction.
Example:MOV AX, 500(Here, 500 is an immediate operand) -
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
MOV AX, 3456H
Addressing Mode: Immediate Addressing Mode
Explanation: The immediate data3456His directly moved to theAXregister.
ADD BX, [2000H]
Addressing Mode: Direct Addressing Mode
Explanation: The content of the memory location2000His added to theBXregister.
DAA
Addressing Mode: Implicit Addressing Mode
Explanation: TheDAA(Decimal Adjust after Addition) instruction works directly on theALregister without specifying an operand.
MOV AX, [SI]
Addressing Mode: Register Indirect Addressing Mode
Explanation: The data from the memory location pointed to by theSIregister is moved toAX.
MOV AX, BX
Addressing Mode: Register Addressing Mode
Explanation: The content of theBXregister is moved to theAXregister.
SUB AX, [BX + SI + 80H]
Addressing Mode: Based Indexed with Displacement Addressing Mode
Explanation: The effective address is calculated by addingBX,SI, and80H, and the data from this memory location is subtracted fromAX.
Let's analyze the instructions step-by-step:
-
Instruction:
MOV AL, 10
Operation: The value10is moved to theALregister.
Result:AL = 10H(10 in hexadecimal is0AH). -
Instruction:
MOV DL, 20
Operation: The value20is moved to theDLregister.
Result:DL = 20H(20 in hexadecimal is14H). -
Instruction:
MUL DL
Operation:MULis an unsigned multiplication ofALbyDL.
The result ofMULis stored inAX, where:ALis the lower 8-bit register ofAX.AHis the higher 8-bit register ofAX.
Calculation:
200 in hexadecimal isC8H.Result:
AX = 00C8HAL = C8H(200 in decimal)AH = 00H
Final Answer:
After execution, the content of the AX register will be 00C8H.
Here are the addressing modes for each instruction:
MUL AL, BL
Addressing Mode: Register Addressing Mode
Explanation: BothALandBLare registers, and the multiplication is performed on the contents of these registers.
MOV AX, BX
Addressing Mode: Register Addressing Mode
Explanation: The data is transferred directly between two registers (BXtoAX).
MOV BX, [SI]
Addressing Mode: Register Indirect Addressing Mode
Explanation: The effective address of the data is stored in theSIregister, and the data at that address is moved into theBXregister.
MOV DX, 0040H
Addressing Mode: Immediate Addressing Mode
Explanation: The immediate value0040His directly moved to theDXregister.
Instructions:
-
MOV AL, 03H
Operation: The value03His moved to theALregister.
Result:
AL = 03H -
MOV BL, 03H
Operation: The value03His moved to theBLregister.
Result:
BL = 03H -
SUB AL, BL
Operation: The contents ofBLare subtracted fromAL.Result:
AL = 00HFlags 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).
-
MUL AL, 08H
Operation: TheMULinstruction performs unsigned multiplication.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
AHis 0). - Overflow Flag (OF): Set to 0 (same reason as CF).
Final Register Values:
AL = 00HBL = 03HAX = 0000H(sinceAL = 00HandAH = 00H)DX = Unchanged(since no instruction modifiesDX)
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)
(i) Move contents of memory location pointed by DI into BX register:
Explanation:
[DI]is the Register Indirect Addressing Mode.- The data from the memory location pointed to by the
DIregister is moved into theBXregister.
(ii) Copy a string from one memory location to another using string manipulation instruction:
Explanation:
SIpoints to the source string (source_address).DIpoints to the destination string (dest_address).CXholds the count of bytes to copy (length).CLDensures that copying is done in the forward direction (incrementsSIandDI).REP MOVSBcopies a byte from[SI]to[DI]and auto-incrementsSIandDIuntilCXbecomes 0.
This is an efficient way to copy a string using the string manipulation instruction MOVSB with the repeat prefix REP.
(a) Initialize Stack at
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 with0FFF0Hto prevent stack overflow (asSPdecrements onPUSHoperations).
(b) Rotate Register BX Right 4 Times:
Explanation:
CLis used to specify the number of rotations (4in this case).ROR(Rotate Right) rotates the contents ofBXregister to the right by 4 bits.- Bits shifted out from the right are re-entered from the left, maintaining all 16 bits.
Instructions:
-
MOV AL, 10
Operation: Load the value10into theALregister.
Result:
AL = 10H(10 in decimal is0AHin hexadecimal) -
MOV DL, 20
Operation: Load the value20into theDLregister.
Result:
DL = 20H(20 in decimal is14Hin hexadecimal) -
MUL DL
Operation: Perform unsigned multiplication ofALbyDL.
TheMULinstruction for 8-bit operands multipliesALbyDLand stores the 16-bit result in theAXregister.Calculation:
- 200 in hexadecimal is
C8H.
Result:
AL = C8H(lower 8 bits of the result)AH = 00H(upper 8 bits of the result)AX = 00C8H
- 200 in hexadecimal is
Final Answer:
The content of the AX register after execution of all instructions will be:
MUL AL, BL
Addressing Mode: Register Addressing Mode
Explanation: BothALandBLare registers, and the multiplication is performed directly using the contents of these registers.
MOV AX, BX
Addressing Mode: Register Addressing Mode
Explanation: The data is transferred directly between two registers (BXtoAX).
MOV BX, [SI]
Addressing Mode: Register Indirect Addressing Mode
Explanation: The memory address is stored in theSIregister. The data at this memory location is moved into theBXregister.
MOV DX, 0040H
Addressing Mode: Immediate Addressing Mode
Explanation: The immediate value0040His directly moved into theDXregister.
Instructions:
-
MOV AL, 03H
Operation: Load03Hinto theALregister.
Result:
AL = 03H -
MOV BL, 03H
Operation: Load03Hinto theBLregister.
Result:
BL = 03H -
SUB AL, BL
Operation: Subtract the contents ofBLfromAL.Result:
AL = 00HAffected 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).
-
MUL AL, 08H
Operation: Unsigned multiplication ofALby08H.Result:
AL = 00H(Lower 8-bit ofAX)AH = 00H(Upper 8-bit ofAX)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
00His even).
Final Register Contents:
- AL = 00H
- BL = 03H
- AX = 0000H (since
AL = 00HandAH = 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)
(i) Move Contents of Memory Location Pointed by DI into BX Register:
Explanation:
[DI]is the Register Indirect Addressing Mode.- The instruction moves the data from the memory location pointed to by the
DIregister into theBXregister.
(ii) Copy a String from One Memory Location to Another Using String Manipulation Instruction:
Explanation:
SIis the Source Index register pointing to the start of the source string (source_address).DIis the Destination Index register pointing to the start of the destination (dest_address).CXis the Counter Register holding the length of the string (length).CLD(Clear Direction Flag) ensures that the copying proceeds in the forward direction (auto-incrementsSIandDI).REP MOVSB(Repeat Move String Byte) copies a byte from[SI]to[DI], repeating this untilCXbecomes 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
MOV AX, 2050H
Addressing Mode: Immediate AddressingExplanation: The constant 2050H is directly provided in the instruction and loaded into the register AX.
STC
Addressing Mode: Implied (or Inherent) AddressingExplanation: This instruction does not require an operand. It simply sets the carry flag.
MOV AL, DS:[SI]
INC BX
Addressing Mode: Register Addressing
Explanation: The operand is a register (BX) and the instruction operates directly on it.
MOV BX, D50H
No comments:
Post a Comment