0% found this document useful (0 votes)
131 views

MIC Notes

The document discusses various topics related to 8086 assembly language programming. It provides details about: 1. The functions of the READY and INTR pins of 8086 which control the processor's operation and interrupt handling. 2. The XCHG instruction which is used to exchange the contents of two registers or a register and memory location. 3. Common assembly language programming tools like editors, assemblers, linkers and debuggers and the role of debuggers in testing programs. 4. The STC and CMC instructions which set and complement the carry flag.
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)
131 views

MIC Notes

The document discusses various topics related to 8086 assembly language programming. It provides details about: 1. The functions of the READY and INTR pins of 8086 which control the processor's operation and interrupt handling. 2. The XCHG instruction which is used to exchange the contents of two registers or a register and memory location. 3. Common assembly language programming tools like editors, assemblers, linkers and debuggers and the role of debuggers in testing programs. 4. The STC and CMC instructions which set and complement the carry flag.
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

2 Marks

1. State the function of READY & INTR pin of 8086.


1. READY: When asserted high, 8086 carries out its normal operation. When low, 8086
freezes its buses and enters a wait state.
2. INTR (Interrupt Request): This is an active high level triggered signal sampled during
the last clock cycle of each instruction. A signal on this input causes 8086 to interrupt
the program it is executing and execute the specified interrupt service procedure.

2. What is role of XCHG instruction in assembly language program ? Give example.


 This instruction is used to exchange the contents of a register with the contents of
another register or memory location.
 Example: XCHG AX, BX
Exchange the word in AX with word in BX.

3. List assembly language programming tools.


1. Editors
2. Assembler
3. Linker
4. Debugger

4. State the role Debugger in assembly language programming.


Debugger is a tool that helps us test and examine the program for its desired specified
functionality, as it is executing.

5. State the use of STC and CMC instructions of 8086.


 STC (Set Carry Flag) – The set carry instruction sets the carry flag to 1.
 CMC (One’s Complement Carry Flag) – The CMC instruction complements or
inverts the carry flag contents.

6. Draw flowchart for multiplication of two 16 bit numbers.


7. Write ALP for addition of two 8bit numbers. Assume suitable data. *2
.model small
.data
num1 db 23h
num2 db 34h
sum db ?

.code
main: mov ax, @data
mov ds, ax
mov al, num1
add al, num2
mov sum, al

.exit
end

8. State the function of BHE and A0 pins of 8086.


BHE (Bus High Enable): During T1 state, the BHE signal is used to enable data on the most
significant half of the data bus pins D15-D8.
A0: A0 is analogous to BHE for the lower byte of the data bus, pins D0-D7. It is Low during
T1 state when a byte is to be transferred on the lower portion of the bus in memory or I/O
operations.

BHE A0 Word/ Byte Access

0 0 Whole word from even address

0 1 Upper byte from / to odd address

1 0 Lower byte from / to even address

1 1 None

9. How single stepping or tracing is implemented in 8086?


Single stepping or tracing in the 8086 processor is implemented using the trap flag in the flag
register. When the trap flag is set, the processor enters single-step mode and generates an
interrupt after executing each instruction, allowing the programmer to examine and modify
the state of the processor and memory.

10. Define Macro & Procedure. *2


Procedure: A procedure is group of instructions that usually performs one task. It is a
reusable section of a software program which is stored in memory once but can be used as
often as necessary. A procedure can be of two types.
1. Near Procedure
2. Far Procedure
Macro: A macro is a sequence of instructions or statements that can be defined once and used
multiple times in a program. Macros are often used to reduce code duplication and simplify
code.
Syntax:
Macro_name MACRO[arg1,arg2,…..argN)
…..
ENDM
11. List any four instructions from the bit manipulation instructions of 8086.
These instructions are used to perform operations where data bits are involved, i.e.
operations like logical, shift, etc.
Instructions to perform logical operation
1. NOT − Used to invert each bit of a byte or word.
2. AND − Used for adding each bit in a byte/word with the corresponding bit in another
byte/word.
3. OR − Used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.
4. XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with
the corresponding bit in another byte/word.

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.

13. State the function of editor and assembler.


An editor is a software tool that allows programmers to write and modify the source code of
a program. It provides a convenient interface for organizing and managing the code, and it
includes features such as syntax highlighting and code formatting.
An assembler is a software tool that converts assembly language code into machine code that
can be executed by the target system. It assigns memory addresses to the program code and
data, resolves symbolic labels and references, and generates object code that can be linked
with other object files to create an executable program.

14. State the use of REP in string related instructions.


 This is an instruction prefix which can be used in string instructions. It causes the
instruction to be repeated CX number of times.
 After each execution, the SI and DI registers are incremented/decremented based on
the DF (Direction Flag) in the flag register and CX is decremented.

15. Write any two difference between NEAR and FAR procedure.

NEAR Procedures FAR Procedures

Use relative addressing mode Use absolute addressing mode

Access data and code within the same Access data and code in other segments
segment

Require less memory Require additional memory to store the


segment selector and offset

Used for small code segments Used for larger code segments

Faster than FAR procedures Slower than NEAR procedures


16. Define immediate addressing mode with suitable example.
An instruction in which the data is specified in the instruction, then the addressing mode of
such instruction is known as Immediate addressing mode.
Example: MOV AX,67D3H

17. State the use of DAA instruction in BCD addition.


DAA (Decimal Adjust Accumulator) instruction is used in BCD addition to adjust the
hexadecimal result into its BCS equivalent.

18. Draw Machine language instruction format for Register-to-Register transfer.


The machine language instruction format for a register-to-register transfer operation in x86
assembly language typically consists of the following components:

Opcode (6 bits) ModR/M byte (8 bits)

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:

Opcode (6 bits) ModR/M byte (8 bits)

89H (MOV) C3H (EAX to EBX)


4 Marks

1. Draw flag register of 8086 and explain any four flags. *2

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.

2. Give the difference between intersegment and intra-segment CALL.


Sr. No. Intersegment Call Intrasegment Call

1. It is also called Far procedure call It is also called Near procedure call.

A near procedure refers to a


A far procedure refers to a procedure
procedure which is in the same code
2. which is in the different code segment
segment from that of the call
from that of the call instruction.
instruction

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.

The value of the old CS:IP pairs are


The value of old IP is pushed on to
pushed on to the stack SP=SP-2 ;Save
4. the stack. SP=SP-2 ;Save IP on
CS on stack SP=SP-2 ;Save IP (new
stack(address of procedure)
offset address of called procedure)

5. More stack locations are required Less stack locations are required

6. Example - Call FAR PTR Delay Example - Call Delay

3. Describe any four assembler directives with suitable example. *2


1. DW: Used to tell the assembler to define a variable type as word or reserve word in
memory.
Example: NUM1 DW 1234H
2. EQU: Used to give a name to some value or symbol.
Example: CTRL EQU 11000110B
3. ASSUME: Used to tell the assembler the name of the logical segment it should use
for a specified argument.
Example: CS: CODE, DS: DATA
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.
Example:
NAME DB “Shrikant”
MOV BX, OFFSET NAME

4. Explain memory segmentation in 8086 and list its advantages. *2


 The 8086 processor uses a segmented memory model where the memory address
space is divided into several 64KB segments.
 Each segment is identified by a segment address, which is combined with an offset
address to form a physical memory address.
 The segment address is stored in a segment register and the offset address is stored in
a general-purpose register. This allows the processor to access up to 1MB of memory
while using only 16-bit registers.
 However, it requires more complex memory addressing calculations and can lead to
segmentation faults if memory is accessed incorrectly.

Some of the advantages of memory segmentation are:


 By working with only 64K byte segments of memory at a time, the 8086 has to
work only with 16-bit effective address and hence the use of 16-bit registers for
addressing is possible.
 In a time-shared microcomputer system, each time the CPU switches from one
user's program to the next, it has to access a new section of code and data.
Segmentation makes this switching easy.
 Segmentation makes it easy to keep user's programs and data separate from each
other.
5. Explain logical instructions of 8086. (Any Four)
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.
Example: ADD AL BL
AL 1111 1100
BL 0000 0011
AL = 0000 0000
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.
Example: OR BL AL
AL 1111 1100
BL 0000 0011
BL = 1111 1111
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.
Example: XOR BL AL
AL 1111 1100
BL 0000 0011
BL = 1111 1111
4. NOT destination: The contents of destination are converted into its complement form.
Example: BL 0000 0011
NOT BL
BL = 1111 1100
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. The flags affected by
ANDing are OF= 0, CF = 0, SF, ZF, AF undefined), PF.

6. Explain assembly language program development steps.


The Programming in Assembly language or for that matter any language follows the specific
sequence of steps which is called as Program Development steps.
It is also called as Program Development Life Cycle (PDLC) or Software Development Life
Cycle (SDLC).
These steps can be listed as follows-
1. Defining the Problem: The first step in writing program is to think very carefully
about the problem that the program must solve.
2. Representation of the Program Logic by-
a. Algorithm: The formula or sequence of operations to be performed by the
program can be specified as a step in general English is called algorithm.
b. Flowchart: The flowchart is a graphically representation of the program
operation or task.
3. Initialization Checklist: Initialization task is to make the checklist of entire variables,
constants, all the registers, flags and programmable ports
4. Choosing Instructions: Choose those instructions that make program smaller in size
and more importantly efficient in execution.
5. Converting Algorithms to Assembly Language Programs: Every step in the algorithm
is converted into program statement using correct and efficient instructions or group
of instructions.

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

8. Write the function of following pins of 8086:


1. BHE (Bus High Enable): During T1 state, the BHE signal is used, to enable data on
the Most Significant half Of the Data Bus pins DIS - D8.
2. ALE (Address Latch Enable): ALE is used to latch the 20-bit address into 8282/8283
address latch. This is a high pulse active during 9 states of any bus cycle.
3. READY: When asserted high, 8086 carries out its normal operation. When low, 8086
freezes its buses and enters a wait state.
4. RESET: RESET causes the processor to immediately terminate its present activity.

9. Draw functional block diagram of 8086 microprocessor.

10. Describe re-entrant and recursive procedure with suitable diagram. *3


 A re-entrant procedure is a procedure that can be called by multiple tasks or processes
simultaneously, without interfering with each other. This is achieved by ensuring that
the procedure does not use any global or static variables, and all necessary data is
passed to the procedure as parameters. As a result, re-entrant procedures can be used
in multi-tasking or multi-processing systems.
 A recursive procedure is a procedure that calls itself, either directly or indirectly. This
allows the procedure to be applied repeatedly to sub-problems, often simplifying the
implementation of complex algorithms. However, care must be taken to ensure that
the recursion terminates at some point, and that the procedure does not cause a stack
overflow by consuming too much stack space.

11. Describe DAS instruction with suitable example.


 The DAS (Decimal Adjust After Subtraction) instruction is used to adjust the result of
a subtraction operation in BCD format. It is used to ensure that the result of the
subtraction is still in BCD format.
 The DAS instruction performs the adjustment by subtracting 6 from the lower nibble
of the AL register if it contains a value greater than 9, and subtracting 6 from the
upper nibble if the auxiliary carry flag (AF) is set.
 Example:
SUB AL, BL ; Subtract BL from AL (130 - 5 = 125)
DAS ; Adjust the result in AL register

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.

Some of the advantages of pipelining are:


 Improved performance: Pipelining allows the CPU to execute multiple instructions
simultaneously, overlapping different stages of instruction processing. This results in
faster overall processing of instructions and improved performance.
 Efficient use of resources: Pipelining allows the CPU to use resources more
efficiently, by keeping the functional units of the CPU busy at all times. This reduces
the likelihood of idle cycles.

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.

15. Compare Procedure and Macros.

Procedure Macro

Macro is a small sequence of codes of the


Procedure is a series of instructions to be same pattern, repeated frequently at
executed several times in a program, and different places, which perform the same
called whenever required. operation on different data of the same data
type.

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.

Parameters passed in registers. memory Parameter passed as the part of statement


locations or stack. which calls macro.

RET is required at the end of the procedure. RET is not used.

Procedure is called using: Macro is called using:


CALL <Procedure_name> <Macro_name> [arguments]

Directives used: PROC, ENDP, FAR. Directives used: MACRO, ENDM,


NEAR. LOCAL

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.

3. Describe any four string instructions of 8086 assembly language.


4. Describe any 6 addressing modes of 8086 with one example of each.
1. Immediate addressing mode: An instruction in which 8-bit or 16-bit operand (data) is
specified in the instruction, then the addressing mode of such instruction is known as
Immediate addressing mode. Example: MOV AX,67D3H
2. Register addressing mode: An instruction in which an operand (data) is specified in
general purpose registers, then the addressing mode is known as register addressing
mode. Example: MOV AX,CX
3. Direct addressing mode: An instruction in which 16 bit effective address of an
operand is specified in the instruction, then the addressing mode of such instruction is
known as direct addressing mode. Example: MOV CL,[2000H]
4. Register Indirect addressing model: An instruction in which address of an operand is
specified in pointer register or in index register or in BX, then the addressing mode is
known as register indirect addressing mode. Example: MOV AX, [BX]
5. Indexed addressing mode: An instruction in which the offset address of an operand is
stored in index registers (SI or DI) then the addressing mode of such instruction is
known as indexed addressing mode. Example: MOV AX,[SI]
6. Based Indexed addressing mode: An instruction in which the address of an operand is
obtained by adding the content of base register (BX or BP) to the content of an index
register (SI or DI) The default segment register may be DS or ES. Example: MOV
AX, [BX][SI]
5. Select assembly language for each of the following :
a. Rotate register BL right 4 times.
b. Multiply AL by 04 H
c. Signed division of AX by BL.
d. Move 2000 H in BX register.
e. Increment the content of AX by 1.
f. Compare AX with BX.
6. Calculate the physical address if :
a. CS = 1200H and IP = DE00H
b. SS = FF00H and SP = 0123H
c. DS = 1F00H and BX = 1A00H for MOV AX, [BX]
7. Describe how an assembly language program is developed and debugging using program
developments tools.
8. State the addressing mode of following instructions:
a. MOV AX, 3456H
b. ADD BX, [2000H]
c. DAA
d. MOV AX, [Si]
e. MOV AX, BX
f. SUB AX, [BX + SI + 80H]
9. Describe how string instructions are used to compare two strings with suitable example.
10. Write an instruction to perform following operations:
a. Multiply BL by 88H
b. Signed division of AL by BL
c. Move 4000H to DS register
d. Rotate content of AX register to left 4 times.
e. Shift the content of BX register to right 3 times.
f. Load SS with FF00H.
11. Write an ALP to concatenate two strings.
12. Write an ALP to reverse a string. Also draw flowchart for same.

You might also like