Mic
Mic
These instructions are used to perform operations where data bits are involved, i.e. operations like
logical, shift, etc.
Following is the list of instructions under this group − Instructions to perform logical operation
AND − Used for adding each bit in a byte/word with the corresponding bit in another byte/word.
OR − Used to multiply each bit in a byte/word with the corresponding bit in another byte/word.
XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with the
corresponding bit in another byte/word.
Q) Explain the concept of pipelining in 8086. State the advantages of pipelining (any two).
Pipelining:
1. The process of fetching the next instruction when the present instruction is being executed is
called as pipelining.
3. BIU (Bus Interfacing Unit) fills in the queue until the entire queue is full.
4. BIU restarts filling in the queue when at least two locations of queue are vacant.
Advantages of pipelining:
Q) Write ALP for addition of two 8bit numbers. Assume suitable data.
.Model small
.Data
NUM DB 12H
.Code
START:
MOV DS,AX
MOV AH,13H
ADD AL,AH
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 i.e. DF = 1; SI, DI decrements.
CLD
REP MOVSB
operation
SI ← SI + I
DI ← DI + I
CX ← CX – 1
DF is cleared).
It behaves the same as a REP instruction provided the Zero Flag is set (i.e. ZF = 1).
It behaves the same as a REP instruction provided the Zero Flag is reset (i.e. ZF = 0).
1. SEGMENT: It is used to indicate the start of a logical segment. It is the name given to the
segment. Example: the code segment is used to indicate to the assembler the start of logical
segment.
3. DW – The DW directive is used to declare a WORD type variable – A WORD occupies 16 bits or (2
BYTE). Declaration examples: Word DW 1234h
4. PROC: (PROCEDURE) It is used to identify the start of a procedure. It follows a name we give the
procedure. After the procedure the term NEAR and FAR is used to specify the procedure Example:
SMART-DIVIDE PROC FAR identifies the start of procedure named SMART-DIVIDE and tells the
assembler that the procedure is far.
Q) Write classification of instruction set of 8086. Explain any one type out of them.
INTR: This is a level triggered interrupt request input, checked during last clock cycle of each
instruction to determine the availability of request. If any interrupt request is occurred, the
processor enters the interrupt acknowledge cycle.
Editor: The editor is a program which allows the user to enter and modify as well as store a group
of instructions or text under a file name
Assembler: The assembler is used to convert assembly language written by a user or a program
into a machine recognizable format.
An instruction in which 8 bit or 16 bit operand (data) is specified in instruction itself then the
addressing mode of such instruction is called as immediate addressing mode.
Eg.
MOV AX,7120H
Q) Draw flag register of 8086 and explain any four flags.
Z-Zero Flag This flag is set if the result is zero after performing ALU operations. Otherwise it is
reset.
P-Parity Flag This flag is set to 1 if the lower byte of the result contains even number of 1’s
otherwise it is reset.
C-Carry Flag : It is set when carry/borrow is generated out of MSB of result. (i.e D7 bit for 8-bit
operation, D15 bit for a 16 bit operation).
T-Trap Flag If this flag is set ,the processor enters the single step execution mode.
1. Defining the problem: The first step in writing program is to think very carefully about the
problem that the program must solve
4. Initialization checklist: Initialization task is to make the checklist of entire variables, constants,
all the registers, flags and programmable ports
5. Choosing instructions: Choose those instructions that make program smaller in size and more
importantly efficient in execution.
6. Converting algorithms to assembly language program: Every step in the algorithm is converted
into program statement using correct and efficient instructions or group of instructions.
The DAA (Decimal Adjust after Addition) instruction makes the result in Packed BCD from after BCD
addition is performed. It works only on AL register.
Q) Draw functional block diagram of 8086 microprocessor
LEN DB ? Z DB 0
JZ EXIT INC Z
INC SI HLT
MOV AH,4CH
INT 21H
CODE ENDS
Q) Describe re-entrant and recursive procedure with schematic diagram.
In some situation it may happen that Procedure 1is called from main program Procrdure2 is called
from procedure1And procrdure1 is again called from procdure2. In this situation program
execution flow reenters in the procedure1. These types of procedures are called re enterant
procedures. The RET instruction at the end of procrdure1 returns to procedure2. The RET
instruction at the end of procedure2 will return the execution to procedure1.Procedure1 will again
executed from where it had stopped at the time of calling procrdure2 and the RET instruction at
the end of this will return the program execution to main program.
Recursive Procedure
A recursive procedure is a procedure which calls itself. Recursive procedures are used to work with
complex data structures called trees. If the procedures is called with N (recursion depth) 3. Then
the n is decremented by one after each procedure CALL and the procedure is called until n = 0. Fig.
recursive procedure.
Q) Describe any 6 addressing modes of 8086 with one example each.
3. Register relative addressing mode: An instruction in which the address of the operand is
obtained by adding the displacement (8-bit or 16 bit) with the contents of base registers or index
registers (BX, BP, SI, DI). The default segment register is DS or ES.
4. Relative Based Indexed addressing mode: X An instruction in which the address of the
operand is obtained by adding the displacement (8 bit or 16 bit) with the base registers (BX or BP)
and index registers (SI or DI) to the default segment.
1 BHE stands for Bus High Enable. It is available at pin 34 and used to indicate the transfer of data
using data bus D8-D15. This signal is low during the first clock cycle, thereafter it is active.
2 ALE: ALE stands for address Latch Enable, as address and data bus are multiplexed; ALE is used to
lock either Address or Data.
3 READY: It is used as acknowledgement from slower I/O device or memory. It is Active high signal,
when high; it indicates that the peripheral device is ready to transfer data.
4 RESET: This pin requires the microprocessor to terminate its present activity immediately
Q) Describe any four assembler directives with suitable example.
made up of 8 bits.
Declaration examples:
Declaration examples:
TEMP DW 1234h
Declaration examples:
Dword1 DW 12345678h
4. SEGMENT: It is used to indicate the start of a logical segment. It is the name given to the
segment. Example: the code segment is used to indicate to the assembler the start of logical
segment
Example:
Q) Describe memory segmentation in 8086 with suitable diagram
memory. 8086 can access 1Mbyte memory which is divided into number of logical
segments. Each segment is 64KB in size and addressed by one of the segment register.
The 4 segment register in BIU hold the 16-bit starting address of 4 segments. CS holds
program instruction code. Stack segment stores interrupt & subroutine address. Data
segment stores data for program. Extra segment is used for string data.
The number of address lines in 8086 is 20, 8086 BIU will send 20bit address, so
The four segment registers actually contain the upper 16 bits of the starting
addresses of the four memory segments of 64 KB each with which the 8086 is
Note that the 8086 does not work the whole 1MB memory at any given time. However, it
works only with four 64KB segments within the whole 1MB memory
Q) Describe how string instructions are used to compare two strings with suitable example.
Syntax:
It compares a byte or word in one string with a byte or word in another string. SI holds
the offset of source and DI holds offset of destination strings. CX contains counter and
DF=0 or 1 to auto increment or auto decrement pointer after comparing one byte/word.
e.g.
Q) Write an ALP to concatenate two strings.
DATA SEGMENT
STR1 DB "hello$"
STR2 DB "world$"
DATA ENDS
CODE SEGMENT
CMP AL,’$’
JE EXIT
INC SI
JMP NEXT
JE EXIT1
MOV [SI], AL
INC SI
INC DI
JMP UP
MOV [SI], AL
INT 21H
CODE ENDS
END START
Q) State the addressing mode of following instructions:
ANS :
Q) Describe how an assembly language program is developed and debugging using program
developments tools.
EDITOR:
extension .asm, in right format so that the assembler will translate it to machine
language. It enables one to create, edit, save, copy and make modification in source file.
Assembler:
Assembler is a program that translates assembly language program to the correct binary
code. It also generates the file called as object file with extension .obj. It also displays
Linker:
It is a programming tool used to convert Object code (.OBJ) into executable (.EXE)
program. It combines, if requested, more than one separated assembled modules into one
with C program.
Debugger:
Debugger is a program that allows the execution of program in single step mode under
the control
of the user. The errors in program can be located and corrected using a debugger.
.model small
.data
Array db 02h,04h,06h,01h,05h
Ends
.code
Mov ds,ax
Mov cl,04h
Lea si,array
Mov al,[si]
Up : inc si
Cmp al,[si]
Jnc next
Mov al,[si]
Next : dec cl
Jnz up
Int 03h
Ends
Q) Describe how 20 bit Physical address is generated in 8086 microprocessor with suitable
example.
Formation of a physical address:- Segment registers carry 16 bit data, which is also known as base
address. BIU attaches 0 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 locations.
Example
+ SI : 4567H
----------------------------
2A887H
Unsigned no.s
ends end