Microprocessor
Microprocessor
Winter-22 Q.15 State the function of READY and INTR pin of 8086
Ans:
Q.1 State the function of the following pins of 8086 microprocessor. Ready: It is used as acknowledgement from slower I/O device or memory. It is
(i) ALE (ii) DT | R̅ Active high signal, when high; it indicates that the peripheral device is ready to
transfer data.
Q.2 Write an assembly language instruction of 8086 microprocessor to INTR: This is a level triggered interrupt request input, checked during last clock
(i) Divide the content of AX register by 50H. cycle of each instruction to determine the availability of request. If any interrupt
(ii) Rotate the content of BX register by 4-bit towards left. request is occurred, the processor enters the interrupt acknowledge cycle.
Q.3 List directives used for procedure. Q.16 What is role of XCHG instruction in assembly language program? Give
example
Q.4 State any two differences between FAR and NEAR procedure. Ans:
Role of XCHG:
Q.5 Write algorithm to find sum of a series of numbers. This instruction exchanges the contents of a register with the contents of another
register or memory location.
Q.6 What is the use of REP in string related instruction ? Explain. Example:
XCHG AX, BX ; Exchange the word in AX with word in BX.
Q.7 Differentiate between ROL and RCL.
Q.17 List assembly language programming tools.
Summer-22 Ans: 1. Editors
2. Assembler
Q.8 Draw the labelled format of 8086 flag register. 3. Linker
4. Debugger.
Q.9 State any two differences between TEST and AND instructions.
Q.18 Define Macro.Give syntax.
Q.10 State the function of editor and assembler. Ans:
Macro: Small sequence of the codes of the same pattern are repeated frequently at
Q.11 Write any two difference between NEAR and FAR procedure. different places which perform the same operation on the different data of same
data type, such repeated code can be written separately called as Macro.
Q.12 Write an ALP to add two 8 bit numbers. Syntax:
Macro_name MACRO[arg1,arg2,…..argN)
Q.13 Define immediate addressing mode with suitable example. …..
End
Q.14 State the use of DAA instruction in BCD addition.
Q.19 Draw flowchart for multiplication of two 16 bit numbers.
Ans:
A0: A0 is analogous to BHE for the lower byte of the data bus, pinsD0-D7. A0 bit
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.
Winter-22 Q.14 Describe the directives used to define the procedure with suitable example.
Q.1 What do you mean by procedure ? Explain re-centrant and re-entrant Q.15 Write the function of following pins of 8086 :
procedure. (i) BHE
(ii) ALE
Q.2 What is memory segmentation ? Explain it with reference to 8086 (iii) READY
microprocessor. (iv) RESET
Q.3 Describe following assembler directives : Q.16 Describe any four assembler directives with suitable example.
(i) DB (ii) EQU (iii) Segment (iv) Assume
Q.17 Describe DAS instruction with suitable example.
Q.4 What are the functions of CALL and RET instructions ? Describe in brief.
Q.18 Describe memory segmentation in 8086 with suitable diagram.
Q.5 Describe register organization of 8086 microprocessor.
Q.19 Write an ALP to multiply two 16 bit signed numbers.
Q.6 Write an assembly language program to add BCD numbers in an array of 10
numbers. Assume suitable array. Store the result at the end of the array. Q.20 Write an ALP to count odd numbers in the array of 10 numbers.
Q.7 Write a procedure to find factorial of given number. Q.21 Write a MACRO to perform 32 bit by 16 bit division of unsigned numbers.
Q.8 Write an assembly language program for conversion of BCD to Hexe number. Q.22 Describe how 20 bit Physical address is generated in 8086 microprocessor
with suitable example.
Q.9 Draw functional block diagram of 8086 microprocessor.
Q.23 Write an ALP to find largest number in the array.
Q.10 Write an assembly language program to arrange the numbers in ascending
order (Assume suitable data). Q.24 Write an ALP to count number of ‘0’ in 8 bit number.
Q.11 Write an assembly language program to Count No. of 1’s in a 16-bit number. Q.25 Write an ALP to subtract two BCD number using procedure.
Q.12 Write an assembly language program using MACRO to perform following Q.26 Describe re-entrant and recursive procedure with suitable diagram.
operation.
X = (A + B) * (C + D) Q.27 Give the difference between intersegment and intrasegment CALL
Q.13 Describe with suitable example how parameter is passed on the stack in 8086
assembly language procedure.
Conditional /Status Flags
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).
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.
AC-Auxiliary Carry Flag: This is set if a carry is generated out of the lower
nibble, (i.e. From D3 to D4 bit)to the higher nibble
Z-Zero Flag: This flag is set if the result is zero after performing ALU operations.
Otherwise it is reset.
S-Sign Flag: This flag is set if the MSB of the result is equal to 1 after performing
ALU operation , otherwise it is reset.
O-Overflow Flag: This flag is set if an overflow occurs, i.e. if the result of a
signed operation is large enough to be accommodated in destination register.
Control Flags
T-Trap Flag: If this flag is set ,the processor enters the single step execution
mode.
I-Interrupt Flag: it is used to mask(disable) or unmask(enable)the INTR
interrupt. When this flag is set,8086 recognizes interrupt INTR. When it is reset
INTR is masked.
D-Direction Flag: It selects either increment or decrement mode for DI &/or
SI register during string instructions.
2) OR – Logical OR 5)TEST
Syntax: OR destination, source Syntax: TEST Destination, Source
Operation This instruction AND’s the contents of a source byte or word with the contents of
Destination OR source specified destination byte or word and flags are updated, flags are updated as
Flags Affected: CF=0, OF=0, PF, SF, ZF result, but neither operands are changed.
This instruction OR’s each bit in a source byte or word with the corresponding bit Operation performed:
in a destination byte or word. The result is put in a specified destination. Flags set for result of (destination AND source)
Example : TEST AL, BL ; AND byte in BL with byte in AL, no result, Update PF, SF, ZF.
• OR AL,BL e.g. MOV AL, 00000101
• AL 1111 1100 TEST AL, 1 ; ZF = 0.
• BL 0000 0011 TEST AL, 10b ; ZF = 1
---------------------
• AL1111 1111 Q.31 Write an ALP to add two 16-bit numbers.
Ans: DATA SEGMENT
3) NOT – Logical Invert NUMBER1 DW 6753H
Syntax: NOT destination NUMBER2 DW 5856H
Operation: Destination NOT destination SUM DW 0
Flags Affected: None DATA ENDS
The NOT instruction inverts each bit of the byte or words at the specified CODE SEGMENT
destination. ASSUME CS: CODE, DS: DATA
Example START: MOV AX, DATA
NOT BL MOV DS, AX
MOV AX, NUMBER1 Q.33 Write an ALP to find length of string.
MOV BX, NUMBER2 Ans: Data Segment
ADD AX, BX STRG DB 'GOOD MORNING$'
MOV SUM, AX LEN DB ?
MOV AH, 4CH DATA ENDS
INT 21H CODE SEGMENT
CODE ENDS START:
END START ASSUME CS: CODE, DS : DATA
MOV DX, DATA
Q.32 Draw functional block diagram of 8086 microprocessor. MOV DS,DX
LEA SI, STRG
MOV CL,00H
MOV AL,'$'
NEXT: CMP AL,[SI]
JZ EXIT
ADD CL,01H
INC SI
JMP
NEXT EXIT: MOV LEN,CL
MOV AH,4CH
INT 21H
CODE ENDS
Q.38 Write an ALP for addition of series of 8-bit number using procedure.
Ans: DATA SEGMENT
NUM1 DB 10H,20H,30H,40H,50H
RESULT DB 0H
CARRY DB 0H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV DX,DATA
MOV DS, DX
MOV CL,05H
MOV SI, OFFSET NUM1
UP: CALL SUM
INC SI
LOOP UP
MOV AH,4CH
INT 21H
SUM PROC; Procedure to add two 8 bit numbers
MOV AL,[SI]
ADD RESULT, AL
JNC NEXT
INC CARRY
NEXT: RET
SUM ENDP
CODE ENDS
END START Q.40 Explain the concept of pipelining in 8086. State the advantages of
pipelining (any two).
Q.39 Describe re-entrant and recursive procedure with schematic diagram. Ans: Pipelining:
Ans: In some situation it may happen that Procedure 1is called from main program 1. The process of fetching the next instruction when the present instruction is being
Procrdure2 is called from procedure1And procrdure1 is again called from executed is called as pipelining.
procdure2. In this situation program execution flow reenters in the procedure1. 2. Pipelining has become possible due to the use of queue.
These types of procedures are called re enterant procedures. The RET instruction at 3. BIU (Bus Interfacing Unit) fills in the queue until the entire queue is full.
the end of procrdure1 returns to procedure2. The RET instruction at the end of 4. BIU restarts filling in the queue when at least two locations of queue are vacant.
Advantages of pipelining: Q.42 Explain any two assembler directives of 8086.
The execution unit always reads the next instruction byte from the queue in Ans: 1. DB – The DB directive is used to declare a BYTE -2-BYTE variable – A
BIU. This is faster than sending out an address to the memory and waiting for the BYTE is made up of 8 bits.
next instruction byte to come. Declaration examples:
More efficient use of processor. Byte1 DB 10h
Quicker time of execution of large number of instruction. Byte2 DB 255; 0FFh, the max. possible for a BYTE
In short pipelining eliminates the waiting time of EU and speeds up the CRLF DB 0Dh, 0Ah, 24h ;Carriage Return, terminator BYTE
processing. -The 8086 BIU will not initiate a fetch unless and until there are two 2. DW – The DW directive is used to declare a WORD type variable – A WORD
empty bytes in its queue. 8086 BIU normally obtains two instruction bytes per occupies 16 bits or (2 BYTE).
fetch. Declaration examples:
Word DW 1234h
Q.41 Compare Procedure and Macros. (4 points). Word2 DW 65535; 0FFFFh, (the max. possible for a WORD)
3. 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.
4. EQU - The EQU directive is used to give name to some value or symbol. Each
time the assembler finds the given names in the program, it will replace the name
with the value or a symbol. The value can be in the range 0 through 65535 and it
can be another Equate declared anywhere above or below.
The following operators can also be used to declare an Equate:
THIS BYTE
THIS WORD
THIS DWORD
A variable – declared with a DB, DW, or DD directive – has an address and has
space reserved at that address for it in the .COM file. But an Equate does not
have an address or space reserved for it in the .COM file.
Example:
A – Byte EQU THIS BYTE
DB 10
A_ word EQU THIS WORD
DW 1000
A_ dword EQU THIS DWORD
DD 4294967295
Buffer Size EQU 1024
Buffer DB 1024 DUP (0)
Buffed_ ptr EQU $ ; actually points to the next byte after the; 1024th byte in ADC: Add with Carry
buffer. This instruction performs the same operation as ADD instruction, but adds the
5. SEGMENT: carry flag to the result.
It is used to indicate the start of a logical segment. It is the name given to the Eg. ADC 0100H
segment. ADC AX, BX
Example: the code segment is used to indicate to the assembler the start of logical ADC AX, [SI]
segment. ADC AX, [5000]
6. PROC: (PROCEDURE) ADC [5000], 0100H
It is used to identify the start of a procedure. It follows a name we give the SUB: Subtract
procedure. After the procedure the term NEAR and FAR is used to specify the The subtract instruction subtracts the source operand from the destination operand
procedure and the result is left in the destination operand.
Example: SMART-DIVIDE PROC FAR identifies the start of procedure named Eg. SUB AX, 0100H
SMART-DIVIDE and tells the assembler that the procedure is far. SUB AX, BX
SUB AX, [5000H]
Q.43 Write classification of instruction set of 8086. Explain any one type out SUB [5000H], 0100H
of them. SBB: Subtract with Borrow
Ans: classification of instruction set of 8086 The subtract with borrow instruction subtracts the source operand and the borrow
Data Transfer Instructions flag (CF) which may reflect the result of the previous calculations, from the
Arithmetic Instructions destination operand
Bit Manipulation Instructions Eg. SBB AX, 0100H
String Instructions SBB AX, BX
Program Execution Transfer Instructions (Branch & Loop Instructions) SBB AX, [5000H]
Processor Control Instructions SBB [5000H], 0100H
Iteration Control Instructions INC: Increment
Interrupt Instructions This instruction increases the contents of the specified Register or memory
location by 1. Immediate data cannot be operand of this instruction.
1) Arithmetic Instructions: Eg. INC AX
These instructions are used to perform arithmetic operations like addition, INC [BX]
subtraction, multiplication, division, etc. INC [5000H]
ADD: The add instruction adds the contents of the source operand to the DEC: Decrement
destination operand. The decrement instruction subtracts 1 from the contents of the specified register or
Eg. ADD AX, 0100H memory location.
ADD AX, BX Eg. DEC AX
ADD AX, [SI] DEC [5000H]
ADD AX, [5000H] NEG: Negate
ADD [5000H], 0100H The negate instruction forms 2’s complement of the specified destination in the
ADD 0100H instruction. The destination can be a register or a memory location. This instruction
can be implemented by inverting each bit and adding 1 to it.
Eg. NEG AL DIV: Unsigned division
AL = 0011 0101 35H Replace number in AL with its 2’s complement This instruction is used to divide an unsigned word by a byte or to divide an
AL = 1100 1011 = CBH unsigned double word by a word.
CMP: Compare Eg.
This instruction compares the source operand, which may be a register or an DIV CL ; Word in AX / byte in CL
immediate data or a memory location, with a destination operand that may be a ; Quotient in AL, remainder in AH
register or a memory location DIV CX ; Double word in DX and AX / word
Eg. CMP BX, 0100H ; in CX, and Quotient in AX,
CMP AX, 0100H ; remainder in DX
CMP [5000H], 0100H 2) Processor Control Instructions
CMP BX, [SI] These instructions are used to control the processor action by
CMP BX, CX setting/resetting the flag values.
MUL: Unsigned Multiplication Byte or Word STC: It sets the carry flag to 1.
This instruction multiplies an unsigned byte or word by the contents of AL. CLC: It clears the carry flag to 0.
Eg. CMC: It complements the carry flag.
MUL BH ; (AX) (AL) x (BH) STD: It sets the direction flag to 1. If it is set, string bytes are accessed from higher
MUL CX ; (DX)(AX) (AX) x (CX) memory address to lower memory address.
MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI]) CLD: It clears the direction flag to 0. If it is reset, the string bytes are accessed
IMUL: Signed Multiplication from lower memory address to higher memory address.
This instruction multiplies a signed byte in source operand by a signed byte in
AL or a signed word in source operand by a signed word in AX. Q.44 Explain memory segmentation in 8086 and list its advantages.(any two)
Eg. IMUL BH Ans: Memory Segmentation:
IMUL CX In 8086 available memory space is 1MByte.
IMUL [SI] This memory is divided into different logical segments and each segment has its
CBW: Convert Signed Byte to Word own base address and size of 64 KB.
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then It can be addressed by one of the segment registers.
said to be sign extension of AL. There are four segments.
Eg. CBW
AX= 0000 0000 1001 1000 Convert signed byte in AL signed word in AX.
Result in AX = 1111 1111 1001 1000
CWD: Convert Signed Word to Double Word
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then
said to be sign extension of AL.
Eg. CWD
Convert signed word in AX to signed double word in DX : AX
DX= 1111 1111 1111 1111
Result in AX = 1111 0000 1100 0001
;Array Of 16 Bit No.;Assume array of 6 no.s
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV DX,0000H
MOV CX,COUNT
MOV SI, OFFSET ARRAY
NEXT: MOV AX,[SI]
ROR AX,01H
JC NEGATIVE
INC DL
JMP COUNT_IT
NEGATIVE: INC DH
COUNT_IT: INC SI
INC SI
LOOP NEXT
MOV NEG_COUNT,DL
MOV POS_COUNT,DH
MOV AH,4CH
INT 21H
Advantages of Segmentation: CODE ENDS
The size of address bus of 8086 is 20 and is able to address 1 Mbytes ( ) of DATA SEGMENT
physical memory. ARRAY DW F423H,6523H,B658H,7612H, 2300H,1559H
The compete 1 Mbytes memory can be divided into 16 segments, each of 64 COUNT DW 06H
Kbytes size. POS_COUNT DB ?
It allows memory addressing capability to be 1 MB. NEG_COUNT DB ?
It gives separate space for Data, Code, Stack and Additional Data segment as DATA ENDS
Extra segment size. END START
The addresses of the segment may be assigned as 0000H to F000H respectively.
The offset values are from 00000H to FFFFFH Q.46 Write an ALP to find the sum of series. Assume series of 10 numbers.
Segmentation is used to increase the execution speed of computer system so that Ans:
processor can able to fetch and execute the data from memory easily and fast. ; Assume TEN , 8 bit HEX numbers
CODE SEGMENT
Q.45 Write an ALP to count the number of positive and negative numbers in ASSUME CS:CODE,DS:DATA
array. START: MOV AX,DATA
Ans: MOV DS,AX
;Count Positive No. And Negative No.S In Given LEA SI,DATABLOCK
MOV CL,0AH
UP:MOV AL,[SI]
ADD RESULT_LSB,[SI]
JNC DOWN
INC REULT_MSB
DOWN:INC SI
LOOP UP
CODE ENDS
DATA SEGMENT
DATABLOCK DB 45H,02H,88H,29H,05H,45H,78H, Q.48 Describe mechanism for generation of physical address in 8086 with
95H,62H,30H suitable example.
RESULT_LSB DB 0
RESULT_MSB DB 0
DATA ENDS
END
Q.47 With neat sketches demonstrate the use of re-entrant and recursive
procedure.
Ans: Re-entrant Procedure:
A re-entrant procedure is one in which a single copy of the program code can be Fig.: Mechanism used to calculate physical address in 8086
shared by multiple users during the same period of time. Re-entrance has two key As all registers in 8086 are of 16 bit and the physical address will be in 20 bits. For
aspects: The program code cannot modify itself and the local data for each user this reason the above mechanism is helpful.
must be stored separately. Logical Address is specified as segment: offset
Physical address is obtained by shifting the segment address 4 bits to the left and
adding the offset address.
Thus the physical address of the logical address A4FB:4872 is:
A4FB0
+ 4872
---------------
A9822 OR
• i.e. Calculate physical Address for the given
Recursive procedures: CS= 3525H, IP= 2450H.
An active procedure that is invoked from within itself or from within another
active procedure is a recursive procedure. Such an invocation is called recursion. A
procedure that is invoked recursively must have the RECURSIVE attribute
specified in the PROCEDURE statement.
ASSUME CS:CODE,DS:DATA,ES:EXTRA
Q.49 Write ALP to count ODD and EVEN numbers in an array. MOV AX,DATA
Ans: ;Count ODD and EVEN No.S In Given ;Array Of 16 Bit No. MOV DS,AX
;Assume array of 10 no.s MOV AX,EXTRA
CODE SEGMENT MOV ES,AX
ASSUME CS:CODE,DS:DATA MOV CX,000AH
START: MOV AX,DATA LEA SI,BLOCK1
MOV DS,AX LEA DI,ES:BLOCK2
MOV DX,0000H CLD
MOV CX,COUNT REPNZ MOVSW
MOV SI, OFFSET ARRAY1 MOV AX,4C00H
NEXT: MOV AX,[SI] INT 21H
ROR AX,01H CODE ENDS
JC ODD_1 DATA SEGMENT
INC DL BLOCK1 DW 1001H,4003H,6005H,2307H,4569H, 6123H, 1865H,
JMP COUNT_IT 2345H,4000H,8888H
ODD_1 : INC DH DATA ENDS
COUNT_IT: INC SI EXTRA SEGMENT
INC SI BLOCK2 DW ?
LOOP NEXT EXTRA ENDS
MOV ODD_COUNT,DH END
MOV EVENCNT,DL
MOV AH,4CH Q.51 Write ALP using procedure to solve equation such as Z= (A+B)*(C+D)
INT 21H Ans: ; Procedure For Addition
CODE ENDS SUM PROC NEAR
DATA SEGMENT ADD AL,BL
ARRAY1 DW F423H, 6523H, B658H, 7612H, 9875H, RET
2300H, 1559H, 1000H, 4357H, 2981H SUM ENDP
COUNT DW 0AH DATA SEGMENT
ODD_COUNT DB ? NUM1 DB 10H
EVENCNT DB ? NUM2 DB 20H
DATA ENDS NUM3 DB 30H
END START NUM4 DB 40H
RESULT DB?
Q.50 Write ALP to perform block transfer operation of 10 numbers. DATA ENDS
Ans: ;Assume block of TEN 16 bit no.s CODE SEGMENT
;Data Block Transfer Using String Instruction ASSUME CS: CODE,DS:DATA
CODE SEGMENT START:MOV AX,DATA
MOV DS,AX Winter-23
MOV AL,NUM1
MOV BL,NUM2
CALL SUM
MOV CL,AL
MOV AL, NUM3
MOV BL,NUM4
CALL SUM
MUL CL
MOV RESULT,AX
MOV AH,4CH
INT 21H
CODE ENDS
END
Q.52 Write ALP using macro to perform multiplication of two 8 Bit Unsigned
numbers.
Ans: ; Macro For Multiplication
PRODUCT MACRO FIRST,SECOND
MOV AL,FIRST
MOV BL,SECOND
MUL BL
PRODUCT ENDM
DATA SEGMENT
NO1 DB 05H
NO2 DB 04H
MULTIPLE DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
PRODUCT NO1,NO2
MOV MULTIPLE, AX
MOV AH,4CH
INT 21H
CODE ENDS
END
Summer-23 6 Marks
Winter-22
Q.1 Define logical and effective address. Describe physical address generation
process in 8086 microprocessor. Calculate physical address by taking suitable DS,
CS and IP.
Q.3 Describe different addressing modes of 8086 with one suitable example each.
Q.6 Draw flow chart and write assembly language program to reverse the word in
string.
Summer-22
Q.18 Write an ALP to reverse a string. Also draw flowchart for same.
Ans:
Program:
DATA SEGMENT
STRB DB 'GOOD MORNING$'
REV DB 0FH DUP(?)
DATA ENDS
CODE SEGMENT
START:ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
LEA SI,STRB
Q.19 Draw architectural block diagram of 8086 and describe its register 12. DI – Destination Index – acts as the destination for string movement
organization. instructions
13. IP – Instruction Pointer – contains the offset of the next instruction to be
executed.
14. Flag Register – individual bit positions within register show status of CPU or
results of arithmetic operations.
Winter-23