0% found this document useful (0 votes)
12 views18 pages

Mic

The document provides an overview of various instructions and concepts related to the 8086 microprocessor, including bit manipulation instructions, pipelining, assembly language programming, and addressing modes. It details specific instructions such as NOT, AND, OR, and XOR for bit manipulation, as well as the advantages of pipelining for efficient processing. Additionally, it covers assembler directives, memory segmentation, and string operations, along with examples of assembly language programs.

Uploaded by

shrilamb1777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views18 pages

Mic

The document provides an overview of various instructions and concepts related to the 8086 microprocessor, including bit manipulation instructions, pipelining, assembly language programming, and addressing modes. It details specific instructions such as NOT, AND, OR, and XOR for bit manipulation, as well as the advantages of pipelining for efficient processing. Additionally, it covers assembler directives, memory segmentation, and string operations, along with examples of assembly language programs.

Uploaded by

shrilamb1777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Q) List any four instructions from the bit manipulation instructions of 8086.

Bit Manipulation Instructions

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

 NOT − Used to invert each bit of a byte or word.

 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.

2. Pipelining has become possible due to the use of queue.

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:

More efficient use of processor.

Quicker time of execution of large number of instruction

Q) Write ALP for addition of two 8bit numbers. Assume suitable data.

.Model small

.Data

NUM DB 12H

.Code

START:

MOV AX, @DATA

MOV DS,AX

MOV AL, NUM

MOV AH,13H
ADD AL,AH

MOV AH, 4CH

INT 21H ENDS END


Q ) 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 i.e. DF = 1; SI, DI decrements.

E.g. MOV CX, 0023H

CLD

REP MOVSB

The above section of a program will cause the following string

operation

ES: [DI] ← DS: [SI]

SI ← SI + I

DI ← DI + I

CX ← CX – 1

to be executed 23H times (as CX = 23H) in auto incrementing mode (as

DF is cleared).

REPZ/REPE (Repeat while zero/Repeat while equal)

It is a conditional repeat instruction prefix.

It behaves the same as a REP instruction provided the Zero Flag is set (i.e. ZF = 1).

It is used with CMPS instruction.

REPNZ/REPNE (Repeat while not zero/Repeat while not equal)

It is a conditional repeat instruction prefix.

It behaves the same as a REP instruction provided the Zero Flag is reset (i.e. ZF = 0).

It is used with SCAS instruction.


Q ) Compare Procedure and Macros. (4 points)
Q) Explain any two assembler directives of 8086

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.

2. DD – The DD directive is used to declare a DWORD – A DWORD double word is made up of 32


bits =2 Word’s or 4 BYTE. Declaration examples: Dword1 DW 12345678h Dword2 DW 4294967295
;0FFFFFFFFh.

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.

classification of instruction set of 8086

Data Transfer Instructions Arithmetic Instructions Bit Manipulation Instructions


String Instructions Program Execution Transfer Instructions Processor Control Instructions
Iteration Control Instructions Interrupt Instructions
Processor Control Instructions : These instructions are used to control the processor action by
setting/resetting the flag values. STC: It sets the carry flag to 1.

CLC: It clears the carry flag to 0.

CMC: It complements the carry flag

STD: It sets the direction flag to 1. If it is set, string bytes are


accessed from higher memory address to lower memory address.

CLD: It clears the direction flag to 0. If it is reset, the string


bytes are accessed from lower memory address to higher memory address.

Q) State the function of READY and INTR pin of 8086

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.

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.

Q) List assembly language programming tools.

Editors 2. Assembler 3. Linker 4. Debugger.


Q) Draw flowchart for multiplication of two 16 bit numbers

Q) State the function of editor and assembler

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.

Q) Write any two difference between NEAR and FAR procedure.


Q) Give the difference between intersegment and intrasegment CALL

Q) Define immediate addressing mode with suitable example

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.

Q) Explain assembly language program development steps.

1. Defining the problem: The first step in writing program is to think very carefully about the
problem that the program must solve

2. 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.

3. Flowchart: The flowchart is a graphically representation of the program operation or task.

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.

Q) State the use of DAA instruction in BCD addition

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

Q) Write an ALP to add two 16-bit numbers.

DATA SEGMENT MOV DS, AX END START

NUMBER1 DW 6753H MOV AX, NUMBER1

NUMBER2 DW 5856H MOV BX, NUMBER2

SUM DW 0 ADD AX, BX

DATA ENDS MOV SUM, AX

CODE SEGMENT MOV AH, 4CH

ASSUME CS: CODE, DS: DATA INT 21H

START: MOV AX, DATA CODE ENDS


Q) Write an ALP to find length of string. Write an ALP to count no.of 0’s in 16 bit number.

Data Segment DATA SEGMENT

STRG DB 'GOOD MORNING$' N DB 1237H

LEN DB ? Z DB 0

DATA ENDS DATA ENDS

CODE SEGMENT CODE SEGMENT

START: ASSUME DS:DATA, CS:CODE

ASSUME CS: CODE, DS : DATA START:

MOV DX, DATA MOV DX,DATA

MOV DS,DX MOV DS,DX

LEA SI, STRG MOV AX, N

MOV CL,00H MOV CL,08

MOV AL,'$' NEXT: ROL AX,01

NEXT: CMP AL,[SI] JC ONE

JZ EXIT INC Z

ADD CL,01H ONE: LOOP NEXT

INC SI HLT

JMP CODE ENDS

NEXT EXIT: MOV LEN,CL END START

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.

The flow of program execution for re-entrant procedure is as shown in FIG

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.

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. 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.

Example: MOV AX, 50H[BX]

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.

Example: MOV AX, 50H [BX][SI]

5. 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]

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]

Q) Write the function of following pins of 8086:

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.

1. DB – The DB directive is used to declare a BYTE type variable – A BYTE is

made up of 8 bits.

Declaration examples:

Num1 DB 10hNum2 DB 37H

2. DW – The DW directive is used to declare a WORD type variable – A WORD

occupies 16 bits or (2 BYTE).

Declaration examples:

TEMP DW 1234h

3. DD – The DD directive is used to declare a double word which is made up of 32

bits =2 Word’s or 4 BYTE.

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

Q) Describe DAS instruction with suitable example.


DAS: Decimal Adjust after Subtraction: - This instruction converts the result of the
subtraction operation of 2 packed BCD numbers to a valid BCD number. The subtraction operation
has to be only in the AL. If the lower nibble of AL is higher than the value 9, this instruction will
subtract 06 from the lower nibble of the AL. If the output of the subtraction operation sets the
carry flag or if the upper nibble is higher than value 9, it subtracts 60H from the AL. This instruction
modifies the CF, AF, PF, SF, and ZF flags. The OF is not defined after DAS instruction. The instance is
following

Example:
Q) Describe memory segmentation in 8086 with suitable diagram

Memory Segmentation: The memory in 8086 based system is organized as segmented

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

as to access one of the 1MB memory locations.

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

working at that instant of time

A segment is a logical unit of memory that may be up to 64 kilobytes. Starting

address will always be changing. It will not be fixed.

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.

CMPS /CMPSB/CMPSW: Compare string byte or Words.

Syntax:

CMPS destination, source

CMPSB destination, source

CMPSW destination, source

Operation: Flags affected < ----- DS:[SI]- ES:[DI]

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

START: ASSUME CS: CODE, DS:DATA

MOV AX,@ DATA

MOV DS, AXMOV SI, OFFSET STR1

NEXT: MOV AL, [SI]

CMP AL,’$’

JE EXIT

INC SI

JMP NEXT

EXIT: MOV DI, OFFSET STR2

UP: MOV AL, [DI]

CMP AL, "$"

JE EXIT1

MOV [SI], AL

INC SI

INC DI

JMP UP

EXIT1: MOV AL,’$’

MOV [SI], AL

MOV AH, 4CH

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.

Assembly language development tools:

EDITOR:

It is a program which helps to construct assembly language program with a file

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

syntax errors in the program, if any.

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

executable module such as two or more assembly programs or an assembly language

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.

Debugger generates .exe file.


Q) Write an ALP to find largest number in the array.

.model small

.data

Array db 02h,04h,06h,01h,05h

Ends

.code

Start: Mov ax,@data

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

Assume DS= 2632H, SI=4567H

DS : 26320H ……...0 added by BIU(or Hardwired 0)

+ SI : 4567H

----------------------------

2A887H

Q) Write a MACRO to perform 32 bit by 16 bit division of

Unsigned no.s

model small Div1 macro no1,no2

mov ax,no1 div no2 endm .data num1 dw 12346666h


num2 dw 2222h .code mov ax,@data mov ds,ax div1 num1,num2

ends end

You might also like