MIC Notes
MIC Notes
.code
main: mov ax, @data
mov ds, ax
mov al, num1
add al, num2
mov sum, al
.exit
end
1 1 None
12. State any two differences between TEST and AND instructions.
1. Operand handling: The TEST instruction performs a logical AND operation on two
operands, but does not store the result. It only sets the flags in the processor's flags
register based on the result of the operation. In contrast, the AND instruction
performs a logical AND operation on two operands and stores the result in the
destination operand.
2. Effect on flags: The TEST instruction only sets the flags based on the result of the
logical AND operation, but does not modify the operands. The AND instruction, on
the other hand, both performs the logical AND operation and modifies the destination
operand, setting the flags based on the result of the operation.
15. Write any two difference between NEAR and FAR procedure.
Access data and code within the same Access data and code in other segments
segment
Used for small code segments Used for larger code segments
The Opcode field specifies the particular transfer instruction being executed, while the
ModR/M byte specifies the source and destination registers.
For example, the MOV instruction is commonly used for register-to-register transfer operations in
x86 assembly language. The machine language instruction format for MOV between two 32-bit
registers (such as EAX and EBX) would look like this:
1. Carry Flag: When addition of two 8-bit numbers is greater than FF or addition of two
16-bit numbers is greater than FFFF then carry flag is set to 1.
During subtraction, if a larger number is subtracted from a smaller number the carry
flag is set to 1 to indicate that a borrow was needed.
2. Parity Flag: The parity flag is set when lower 8 bits of the result of arithmetic or
logical operations in destination register has even number of 1’s.
3. Auxiliary Carry Flag: During addition of two 8 bit or two 16-bit numbers, if there is a
carry from lower nibble to higher nibble, then the auxiliary flag is set.
Similarly, if subtraction of two nibbles require a borrow, then the auxiliary carry flag
is set. It is used during BCD addition and subtraction.
4. Zero Flag: If the result of an arithmetic or logical operation in the destination register
is zero, then the zero flag is set.
5. Sign Flag: The sign flag is set to indicate that the result of an arithmetic or a logical
operation is negative. Since 2’s complement is used, the MSB of the result in the
destination register will be 1 whenever the result is negative.
6. Overflow Flag: If the result of an operation is greater than 7f(for 8 bit) or 7fff(for 16
bit), then the overflow flag will be set to indicate that the result has overflown into the
sign bit.
1. It is also called Far procedure call It is also called Near procedure call.
This procedure call replaces the old This procedure call replaces the old IP
3.
CS:IP pairs with new CS:IP pairs with new IP.
5. More stack locations are required Less stack locations are required
7. Describe the directives used to define the procedure with suitable example.
Procedure declaration with assembler directives: The PROC directive is used to identify the
start of a procedure and ENDP directive is used to indicate the end of a procedure.
1. PROC directive: PROC directive follows the name of the procedure and is followed
by the term near or far which specifies the type of the procedure.
The term near indicates a procedure which resides in the same segment as the CALL
segment.
The term far indicates that the procedure resides in a Code Segment other than the
CALL segment.
2. ENDP directives: The name of a procedure followed by an ENDP directive indicates
the end of a procedure.
Thus, the PROC and the ENDP directive inform the assembler about the start and end
of that procedure.
Example 1: Writing a delay routine as a procedure.
Delay PROC ; Start of Delay procedure
____________ ; Procedure instructions
Delay ENDP ; End of Delay procedure
12. Describe how 20-bit Physical address is generated in 8086 microprocessor with suitable
example. *2
Formation of a physical address: Segment registers carry 16-bit data, which is also known as
base address. BIU attaches O as LSB of the base address. So, now this address becomes 20-
bit address. Any base/pointer or index register carry 16 bit offset. Offset address is added into
20-bit base address which finally forms 20-bit physical address of memory location.
Example:
Assume DS = 2632H, SI = 4567H
DS: 26320H (O added by BIU (or Hardwired O))
+SI: 4567H
= 2A887H
13. Explain the concept of pipelining in 8086. State the advantages of pipelining. *2
Fetching the next instruction while the recent instruction executes is known as
pipelining.
To speed up program execution, the Bus Interface Unit fetches as many as 6
instruction bytes ahead of time from the memory and these are held for execution unit
in the (FIFO) group of registers called QUEUE.
The BIU can be fetching instruction bytes while EU is decoding or executing an
instruction which does not require the use of buses. When the EU is ready for the next
instruction, it simply reads the instruction from the QUEUE in the BIU.
14. Write classification of instruction set of 8086. Explain any one type out of them.
The instruction sets can be broadly classified as:
1. Arithmetic Instructions
2. Data Transfer Instructions
3. Rotate Instructions
4. Logical Instructions
5. Branch Instructions
6. CPU Control Instructions
7. Flag Instructions
8. String Instructions
Logical Instructions:
1. AND destination, source: The contents of destination are ANDed with those of source
and the result is stored in the destination. All flags except Auxiliary Flag are affected.
2. OR destination, source: The contents of the destination are ORed with those of the
source and result is placed in the destination. All flags are affected except Auxiliary
Flag are affected.
3. XOR destination, source: The contents of destination are XORed with those of the
source and the result is placed in the destination. All flags except the Auxiliary flag
are affected.
4. NOT destination: The contents of destination are converted into its complement form.
5. TEST Instruction: The test instruction ANDS the source and the destination operands
but does not store the result operands. It only affects the flags.
Procedure Macro
Program control is transferred to the The MACRO code is inserted into the
procedure. when CALL instruction is program, wherever MACRO is called, by
executed at run time. the assembler
Memory required is less, as the program Memory required is more, as the code is
control is transferred to procedure. inserted at each MACRO call.
Stack is required at procedure CALL. Stack is not required at the MACRO call.
Extra overhead time is required for linkage
between the calling program and called No overhead time required
procedure.
16. Write an ALP to count the number of positive and negative numbers in array.
17. Write an ALP to find the sum of series. Assume series of 10 numbers.
18. Write ALP to count ODD and EVEN numbers in an array *2
19. Write ALP to perform block transfer operation of 10 numbers.
20. Write ALP using procedure to solve equation such as Z= (A+B)*(C+D)
21. Write ALP using macro to perform multiplication of two 8 Bit Unsigned numbers
22. Write an ALP to add two 16-bit numbers.
23. Write an ALP to find length of string.
24. Write an ALP to solve p = x2 + y2 using macro. (x and y are 8-bit numbers)
25. Write an ALP to count no. of 0’s in 16 bit number.
26. Write an ALP to find largest number in array of elements 10H, 24H, 02H, 05H, 17H. *2
27. Write an ALP for addition of series of 8-bit number using procedure.
28. Write an ALP to multiply two 16 bit signed numbers.
29. Write a MACRO to perform 32 bit by 16 bit division of unsigned numbers.
30. Write an ALP to count number of ‘0’ in 8 bit number.
31. Write an ALP to subtract two BCD number using procedure.
6 Marks
1. Define logical and effective address. Describe physical address generation process in 8086.
If DS = 345A H and SI = 13DC H. Calculate physical address.
2. Explain the use of assembler directives:
1. DW: Used to tell the assembler to define a variable type as word or reserve word in
memory.
2. EQU: Used to give a name to some value or symbol.
3. ASSUME: Used to tell the assembler the name of the logical segment it should use
for a specified argument.
4. OFFSET: Used to tell the assembler to determine the offset or displacement of a
named item, a procedure from the start of the segment, which contains it.
5. SEGMENT: Used to indicate the start of a logical segment.
6. EVEN: Used to align the memory allocation of a variable on an even boundary.