Mpi 4,2
Mpi 4,2
4m
Sure, I can help with that. Here are the relevant answers to your questions:
- **Minimum Mode:**
- **Maximum Mode:**
2. The 8086 acts as a multi-processor system when used in maximum mode configuration, allowing
multiple processors to work together in a single system.
4. **Logical address** is the address generated by the CPU during program execution, which is
translated into a physical address by the memory management unit (MMU). Example: 16-bit address
generated by an x86 processor.
**Physical address** is the actual location in the memory where data is stored. Example: Memory
cell 0x1234.
5. Here's an example of an 8086 assembly language program to add two 8-bit numbers and store the
result:
```assembly
```
6. Segment registers in 8086 (CS, DS, SS, ES) are used to hold segment addresses, which are
combined with an offset to form a physical address. They facilitate memory segmentation in the x86
architecture.
7. The prefetch queue in 8086 holds the next instruction to be executed, fetched from memory in
advance. This prefetching helps improve instruction execution speed by reducing memory access
time.
8. The Instruction Pointer (IP) in 8086 holds the offset address of the next instruction to be executed.
It is essential for the processor to fetch the correct instructions in sequential order.
```assembly
```
```assembly
Store_Loop:
```
```
Flags affected: Carry Flag (CF), Auxiliary Carry Flag (AF), Zero Flag (ZF), Sign Flag (SF), Parity Flag
(PF), Overflow Flag (OF)
```
11. **Sequential flow instructions** execute instructions in the order they appear in the program,
while **control transfer instructions** alter the normal flow of execution by transferring control to a
different part of the program (e.g., jump, call, return instructions).
12. **MOV instruction** is used to transfer data between registers or between a register and
memory, while **XCHG instruction** exchanges the contents of two registers or a register and a
memory location.
13. **MUL instruction** performs unsigned multiplication, while **IMUL instruction** performs
signed multiplication in 8086.
14. **DIV instruction** performs unsigned division, while **IDIV instruction** performs signed
division in 8086.
```
```
```
2m
```
DAA ; Adjust AL after addition, no carry from lower nibble to upper nibble, so AL remains 7EH
AL = 7EH
```
```
POP AX ; Pops the top of the stack into AX, AX now contains 34H
POP G ; Pops the top of the stack into G, G now contains 20H
```
4. The direction flag (DF) in 8086 is used to control the direction of certain string instructions like REP
MOVSB, REP STOSB, etc. When DF = 0, these instructions process data from lower memory addresses
to higher memory addresses. When DF = 1, they process data in the reverse direction, from higher
addresses to lower addresses.
5. Output of the code:
```
AL = 00110101 (35H)
BL = 39H
AAS ; Adjust AL after subtraction, since AL is greater than 9 (in hexadecimal), AAS subtracts 6
from AL and adjusts the result, AL = FCH - 6 = F6H
AL = F6H
```
7. IDIV and DIV instructions perform division operations. IDIV is used for signed division (with signed
operands), while DIV is used for unsigned division (with unsigned operands). Here's an example
code:
```assembly
```
For IDIV, you would use signed values for AX and BX.
8. The opcode is a part of the instruction in machine language that specifies the operation to be
performed by the CPU. It is essential for decoding instructions and executing the corresponding
operations.
```
AL = 00110100 (34H)
BL = 00111000 (38H)
AAA ; Adjusts AL after addition, since AL > 9 (in decimal), AAA adds 6 to AL and adjusts, AL =
6CH + 6 = 72H
AL = 72H
```
11. ADC (Add with Carry) instruction is used to add two operands along with the value of the Carry
Flag (CF). It's used in arithmetic operations where a carry from a previous operation needs to be
considered.
12. The NEG instruction inverts the sign of a number. It is used to perform two's complement
negation, converting a positive number to negative and vice versa.
```
CX = 0EEFH
```
14. The NOT instruction inverts each bit of a binary number. It is used for bitwise complementation,
flipping 0s to 1s and vice versa.
- Status flags (also known as condition flags): CF, PF, AF, ZF, SF, OF
- POP: Pops data from the stack into a register or memory location
Unit-2
**Question 1:**
Consider the 8-bit data as 11000110 and assume the carry flag is 0. Perform two times rotate right
with carry and show the final result.
**Answer:**
Final result after two times rotate right with carry: 10110001
---
**Question 2:**
Consider the data is 11000111, assume the carry flag is 0. Perform two times shift arithmetic left and
show the final result.
**Answer:**
---
**Question 3:**
Define the role of the direction flag in MOVSB instruction in the 8086 processor.
**Answer:**
The direction flag (DF) in the 8086 processor determines the direction of string operations like
MOVSB. When DF is set (1), string operations decrement the SI and DI registers after each operation.
When DF is cleared (0), the registers are incremented. This flag allows for efficient processing of data
in memory, facilitating both forward and backward movement through memory locations.
---
**Question 4:**
State the use of REP & REPE instructions in the 8086 processor.
**Answer:**
- REP (Repeat) instruction is used to repeat string operations such as MOVSB, STOSB, etc., a specific
number of times specified by the CX register.
- REPE (Repeat if Equal) instruction is used in conjunction with string comparison instructions like
CMPSB to repeat the operation until a mismatch occurs or until the CX register becomes zero.
---
**Question 5:**
**Answer:**
- Unconditional branch instructions (e.g., JMP) always transfer control to a specified address without
any conditions.
- Conditional branch instructions (e.g., JZ, JNZ) transfer control to a specified address only if a certain
condition is met, such as the zero flag being set or cleared.
---
**Question 6:**
**Answer:**
- Jump (JMP) instruction transfers the control of the program unconditionally to a specified address.
- Call (CALL) instruction transfers control to a subroutine, but before doing so, it saves the return
address in the stack. After executing the subroutine, control returns to the instruction following the
call.
---
**Question 7:**
**Answer:**
- Software interrupts are initiated by software instructions (e.g., INT) to request services from the
operating system or to invoke specific routines.
- Hardware interrupts are initiated by external hardware devices to request attention from the CPU
for various events like I/O completion or timer expiry.
---
**Question 8:**
**Answer:**
```assembly
.model small
.stack 100h
.data
.code
main:
mov ah, 9
end main
```
This program displays "Hello, world!" using DOS interrupt 21h (function 09) and then terminates the
program using DOS interrupt 21h (function 4Ch).
---
**Question 9:**
a. Variables
b. Suffixes
c. Operators
**Answer:**
a. Variables: Variables are named memory locations used to store data during program execution.
They are identified by a unique name and can hold different types of data such as integers,
characters, or arrays. Example:
```assembly
message db 'Hello, world!', '$' ; Define a variable named message to store a string
```
b. Suffixes: Suffixes in assembly language indicate the size or type of data being used. They are
appended to data declarations or instructions to specify the size of the data. Examples:
```assembly
num1 dw 1234h ; Define a word (16-bit) variable num1 with initial value 1234h
value1 db 'A' ; Define a byte (8-bit) variable value1 with initial value 'A'
```
c. Operators: Operators in assembly language are symbols used to perform operations on data. They
include arithmetic operators (+, -, *, /), logical operators (AND, OR, XOR), comparison operators
(CMP), and bitwise operators (AND, OR, XOR). Examples:
```assembly
```
---
**Question 10:**
Explain CMPSB instruction with an example. Discuss how you can conclude that the two numbers
compared are equal, lesser, or greater.
**Answer:**
CMPSB (Compare String Byte) instruction is used to compare two bytes in memory. It compares the
byte at the address pointed to by the SI register with the byte at the address pointed to by the DI
register. The result of the comparison is reflected in the status flags.
Example:
```assembly
mov si, offset array1 ; Set SI to point to the first byte of array1
mov di, offset array2 ; Set DI to point to the first byte of array2
compare_loop:
equal:
less:
; Handle the case when the byte at [SI] is less than the byte at [DI]
greater:
; Handle the case when the byte at [SI] is greater than the byte at [DI]
```
In the above example, if the byte at [SI] is equal to the byte at [DI], the zero flag (ZF) will be set after
the CMPSB instruction (je equal). If the byte at [SI] is less than the byte at [DI], the carry flag (CF) will
be set (jb less). If the byte at [SI] is greater than the byte at [DI], the zero flag (ZF) will be cleared, and
the carry flag (CF) will be cleared (jg greater).
---
**Question 11:**
State the advantage of Assembly level language over Machine level language discuss about the role
of assembler directives in achieving these advantages in short.
**Answer:**
---
**Question 12:**
State the advantage of assembly level language over machine level language discuss about the role
of assembler directives in achieving these advantages in short.
**Answer:**
Apologies for the repetition in the question. Please refer to the answer provided for Question 11.
---
**Question 13:**
**Answer:**
```assembly
.model small
.stack 100h
.data
sum dw ?
.code
main:
add_loop:
end main
```
This program calculates the sum of multiple numbers stored in an array. It initializes the sum to 0 and
then iterates over each element in the array, adding it to the sum. Finally, it displays the sum.
---
**Question 14:**
```assembly
.model small
.stack 100h
.data
num1 dw 1234h
num2 dw 5678h
.data
sum dw ?
.code
main:
; At this point, sum contains the total sum of num1 and num2
end main
```
This program calculates the sum of two multi-byte numbers and stores the result in a variable called
sum.
---
**Question 15:**
How can you check if an 8-bit number is even or odd using appropriate 8086 assembly language
instructions?
**Answer:**
You can check if an 8-bit number is even or odd by examining the least significant bit (LSB) of the
number. If the LSB is 0, the number is even; if it is 1, the number is odd. Here's how you can do it in
assembly language:
```assembly
jmp end
even:
end:
```
---
**Question
16:**
What are the sequence of instructions that can be used to perform addition of two BCD numbers in
8086 processor so that the results must be in BCD?
**Answer:**
To perform addition of two BCD (Binary Coded Decimal) numbers in 8086 processor so that the result
must be in BCD, you can follow these steps:
Example:
```assembly
jc carry_detected
; No carry, continue
carry_detected:
```
2 marks
**Question 1:**
"What will be the content of reg AX after execution of the following program. Assume CF=1.
```
SAR AH, 02
SHL AL, 02
SHR AL, 03
HLT
```
**Answer:**
Given:
- CF = 1 (Assumption)
- AH = 0FH
- AL = FFH
Execution steps:
---
**Question 2:**
In 8086 Processor, the content of the accumulator and the carry flag are A7 and 0 (in hex). if the RLC
instruction is executed, then the content of the accumulator (in hex) and the carry flag, respectively
will be______.
**Answer:**
RLC (Rotate Left through Carry) instruction rotates the bits of the accumulator to the left through the
carry flag. After execution:
- Carry flag: 1
---
**Question 3:**
While performing any of the MOV instructions over Strings, i.e. MOVSB, MOBSW, or MOVSD, by
default, what is the source and destination?
**Answer:**
---
**Question 4:**
```
MOV AX,0200H
MOV DS,AX
MOV AX,0300H
MOV ES,AX
MOV DS:[0000],52H
MOV DS:[0001],74H
MOV DS:[0002],8AH
MOVSB
MOVSB
MOVSB
HLT
```
**Answer:**
This program copies three bytes from the DS segment to the ES segment using MOVSB instruction.
---
**Question 5:**
```
MOV AX,01234H
MOV BX,01233H
XOR AX,BX
JZ ABC
MOV CX,01234H
HLT
HLT
```
**Answer:**
Given:
- AX = 01234H
- BX = 01233H
XOR AX, BX results in AX = 00001H. Since AX is not zero, the JZ instruction doesn't jump. Hence, the
next instruction MOV CX, 01234H is executed, loading CX with 01234H. The program then halts. So,
the output is CX = 01234H.
---
**Question 6:**
**Answer:**
---
**Question 7:**
What name is given to a special software routine to which control is passed when an interrupt
occurs?
**Answer:**
The special software routine to which control is passed when an interrupt occurs is called an
Interrupt Service Routine (ISR) or Interrupt Handler.
---
**Question 8:**
What will be the hexadecimal value in the register AX (32-bits) after executing the following
instructions?
```
MOV AL,15
MOV AH,15
XOR AL,AL
MOV CL,03
SHR AX,CL
```
**Answer:**
Given:
- AL = 15 (in hex)
- AH = 15 (in hex)
After SHR AX, CL, AX is right shifted by 3 bits. So, AX = 00001500 (in hex).
---
**Question 9:**
In 8086 microprocessor ________ has the highest priority among all type interrupts?
**Answer:**
In the 8086 microprocessor, Non-Maskable Interrupt (NMI) has the highest priority among all types
of interrupts.
---
**Question 10:**
How many times the instruction sequence below will loop before coming out of the loop?
```
INC AL
JNZ A1
```
**Answer:**
The instruction sequence will loop 256 times because AL is initially set to 00H, and INC AL increments
it by 1. When AL reaches FFH, the next increment will make it 00H again, and the loop continues. So,
the loop iterates through all possible values of AL, resulting in 256 iterations.
---
**Question 11:**
A certain microprocessor requires 4.5 microseconds to respond to an interrupt. Assuming that the
three interrupts I1, I2, I3 requires the following execution time after the interrupt is recognized:
i. I1 requires 25 microseconds
To determine the possible range of time for I3 to be executed, considering that it may or may not
occur simultaneously with other interrupts, let's analyze the scenario:
Given:
i. I1 requires 25 microseconds
Thus, the possible range of time for I3 to be executed is between 24.5 microseconds and 39.5
microseconds, assuming it may or may not occur simultaneously with other interrupts.
12)I1 has the highest priority and I3 has the lowest. What is the possible range of time for I3 to be
executed assuming it may or may not occur simultaneously with other interrupts?
If I1 has the highest priority and I3 has the lowest priority, let's consider the possible scenarios for
the execution of I3:
Given:
i. I1 requires 25 microseconds
Since I3 has the lowest priority, it can only occur after the other interrupts have been processed.
Therefore, the possible range of time for I3 to be executed is between 29.5 microseconds and 39.5
microseconds, assuming it may or may not occur simultaneously with other interrupts.
**Question 13:**
iii. SCAS 3) compares two strings of bytes or words whose length is stored in CX register
**Answer:**
ii
. CMPS - 3) compares two strings of bytes or words whose length is stored in CX register
---
**Question 14:**
Which instruction cannot force the 8086 processor out of ‘halt’ state?
**Answer:**
The instruction that cannot force the 8086 processor out of the 'halt' state is the NOP (No Operation)
instruction.
---
**Question 15:**
**Answer:**
The LOCK prefix is used in multiprocessor environments to ensure that certain instructions are
executed atomically. When a LOCK prefix is used with an instruction, it ensures that no other
processor can access the memory while the instruction is being executed. This is often used in critical
sections of code where multiple processors might try to access shared resources simultaneously.
---
**Question 16:**
```
MOV AL, 09
MOV AH, 08
ADD AL, AH
DAA
HLT
```
**Answer:**
Given:
- AL = 09 (in hex)
- AH = 08 (in hex)
After ADD AL, AH, AL becomes 11 (in hex). DAA (Decimal Adjust AL after Addition) adjusts AL to
represent the correct decimal result. In this case, since AL = 11 (in hex), no adjustment is needed. So,
after DAA, AL remains 11 (in hex).