Professional Documents
Culture Documents
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 1 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 2 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 3 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Flowcha
rt 2M
Page 4 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
4) ENDs:
This directive informs the assembler the end of the segment
The directives SEGMENT, ENDS are always enclosed in data, code,
stack and extra segments.
(iii) Describe re-entrant procedure with the help of schematic 4M
diagram.
Ans. Re-entrant Procedures:
A procedure is said to be re-entrant, if it can be interrupted, used
and re-entered without losing or writing over anything.
To be a re-entrant, Procedure must first push all the flags and
registers used in the procedure. It should also use only registers or Descript
stack to pass parameters. ion 2M
In some situation it may happen that procedure1 is called from
main program, procedure2 is called from procedure1 is again
called from procedure2. In this situation program execution flow
reenters in the procedure1. These types of procedures are called
reentrant procedures.
Diagram
2M
Page 5 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 6 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Description:
Data segment is used to hold data, Code segment for the
executable program, Extra segment also holds data specifically in
strings and stack segment is used to store stack data. Explana
Each segment is 64Kbytes & addressed by one segment register. tion 2M
i.e CS,DS,ES or SS
The 16 bit segment register holds the starting address of the
segment
The offset address to this segment address is specified as a 16-bit
displacement (offset) between 0000 to FFFFH.
Since the memory size of 8086 is 1Mbytes, total 16 segments are
possible with each having 64Kbytes.
Advantages of segmentation:
1) With the use of segmentation the instruction and data is never
overlapped.
2) The major advantage of segmentation is Dynamic relocatability of
program which means that a program can easily be transferred
from one code memory segment to another code memory segment Any 2
without changing the effective address. advanta
3) Segmentation can be used in multi-user time shared system. ges ½M
4) Segmentation allows two processes to share data. each
5) Segmentation allows you to extend the addressability of a
processor i.e., address up to 1MB although the actual addresses to
be handled are of 16 bit size.
6) Programs and data can be stored separately from each other in
segmentation.
d) Draw typical 8086 minimum mode configuration and explain 4M
function of any two signals used in minimum mode.
Ans.
Page 7 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Diagram
2M
MN/𝑴𝑿
• This pin indicates operating mode of 8086, minimum or
maximum.
• When this pin connected to
1)Vcc, the processor operates in minimum mode,
2) ground, processor operates in maximum mode.
Any 2
𝐈𝐍𝐓𝐀 (Interrupt acknowledge) signals
• It is active low output signal. 1M each
• When processor receive INTR signal, processor complete current
machine cycle, and acknowledge interrupt by generating this
signal.
Page 8 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
74LS373.
DT/ 𝐑
• This output signal used to decide the direction of data flow
through transreceivers (bi-directional buffers) 8286 or 74LS245
• When processor sends data out, this signal is high, when
processor receives data, this signal is low.
M/ 𝐈𝐎
• This signal is issued by processor to distinguish memory access
from I/O access.
• When this signal high memory is accessed and when this signal is
low , an I/O device is accessed
•
𝑾𝑹
• It is an active low signal used to write data to memory or I/O
device depending on status of M/IO.
HLDA:
• This is an active high output signal generated by processor after
receiving HOLD signal.
HOLD:
• When another master device needs the use of the address, data,
control bus, it sends a HOLD request to the processor through this
line.
It is an active high input signal.
e) State the functions of the following pins of 8086. 4M
(i) MN/𝐌𝐗
(ii) NMI
(iii) INTR
(iv) 𝐋𝐎𝐂𝐊
Page 9 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
(ii) NMI: An edge triggered signal on this pin causes 8086 to Each
interrupt the program it is executing and execute Interrupt service correct
Procedure corresponding to Type-2 interrupt.NMI is Non-maskable function
by software 1M
(iv) 𝐋𝐎𝐂𝐊:
Prevent other processor to take the control of shared resources.
Lock the bus attached to lock pin of device while a multicycle
instruction completes.
The lock prefix this allows a microprocessor to make sure that
another processor does not take control of system bus while it is in
the middle of a critical instruction.
f) Enlist the instruction formats used in 8086. Describe any one of 4M
them.
Ans. Instruction formats of 8086:
1) One byte Instruction
2) Register to Register
3) Register to/from memory with no displacement List 2M
4) Register to/from Memory with Displacement
5) Immediate operand to register.
6) Immediate operand to memory with 16-bit displacement
1) One byte Instruction: This format is only one byte long and may Descript
have the implied data or register operands. The least significant 3 bits ion of
of the opcode are used for specifying the register operand, if any. any one
Otherwise, all the eight bits form an opcode and the operands are 2M
implied.
Page 10 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 11 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 12 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 13 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 14 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 16 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 17 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
NOT AX
INC AX
MOV C, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
d) Write an 8086 assembly language program to count number of 4M
1’s in 8 bit number
(Note: Any other logic shall be considered)
Ans. Program for finding number of 1's :
DATA SEGMENT
A DB 34H
C DB 0H Correct
DATA ENDS program
CODE SEGMENT 4M
ASSUME DS:DATA, CS:CODE
START: MOV AX, DATA
MOV DS, AX
MOV AL, A
MOV CL, 08H
NEXT: SHR AL, 01H
JNC SKIP
INC C
SKIP: LOOP NEXT
MOV AH,4CH
INT 21H
CODE ENDS
END START
e) Write an 8086 assembly language programme to find length of a 4M
string.
(Note: Any other logic shall be considered)
Ans. Program for finding length of a string:
DATA SEGMENT
S DB 'MSBTE$'
L DB 0H Correct
DATA ENDS program
CODE SEGMENT 4M
ASSUME CS:CODE, DS:DATA
Page 18 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
CODE SEGMENT
START: MOV AX, 5555H
MOV BX, 7272H
: Example
: 2M
CALL PROC1
:
:
Page 19 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
PROCEDURE PROC1
:
:
ADD AX,BX
:
:
RET
PROC1 ENDP
CODE ENDS
END START
5. Attempt any FOUR of the following: 16
a) State two instructions each for arithmetic multiplication and 4M
division with example.
Ans.
Instruction to perform multiplication:
MUL − Used to multiply unsigned byte by byte/word by word.
Example:
MOV AL, 200 ; AL = 0C8h
MOV BL, 4
MUL BL ; AX = 0320h (800)
RET Any two
IMUL − Used to multiply signed byte by byte/word by word. instructio
Example: ns of
MOV AL, -2 multiplic
MOV BL, -4 ation 1M
IMUL BL ; AX = 8 and
RET Example
AAM − Used to adjust ASCII codes after multiplication. 1M
Example:
MOV AL, 15 ; AL = 0Fh
AAM ; AH = 01, AL = 05
RET
Page 20 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
by word.
Example:
MOV AX, -203 ; AX = 0FF35h
MOV BL, 4
IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh)
RET
jnz step1
Code ends
End start
c) Write an 8086 assembly language program to add two BCD 4M
numbers.
(Note: Program without carry can also be considered)
Ans.
Program –
OR
Page 22 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Correct
program
4M
Page 23 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
HLT Stop
Syntax:
Macro_nameMACRO [arg1,arg2,.....argN)
.....
endMacro
Example:
Page 24 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MOV BX, p2
MOV CX, p3 Example
ENDM ;indicates end of macro. 2M
data segment
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
MyMacro 1, 2, 3 ; macro call
MyMacro 4, 5, DX
mov ah,4ch
int 21h
code ends
end start
OR
(Any Same Type of Example can be considered)
f) State the function of CALL and RET with suitable example. 4M
Ans.
CALL :
Functions of CALL:
Page 25 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Example:
ORG 100h ; for COM file.
CALL p1
ADD AX, 1
OR
The RET instruction stands for return. This instruction is used at the
end of the procedures or the subprograms. This instruction transfers
the execution to the caller program. Whenever the RET instruction
is called, the following process takes place inside the microprocessor:
The address of the next instruction in the mainline program which
was previously stored inside the stack is now again fetched and is
placed inside the instruction pointer (IP).
The instruction queue will now again be filled with the
subsequent instructions of the mainline program.
Example:
ORG 100h ; for COM file.
CALL p1
ADD AX, 1
Diagram
4M
Page 27 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
OR
Page 28 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
data in the data segment; but you can always change the value of the
ds register to access additional data in other segments.
3. ES-The extra segment register, ES, is exactly that – an extra
segment register. 8086 programs often use this segment register to
gain access to segments when it is difficult or impossible to modify
the other segment registers.
4. SS-The SS register points at the segment containing the 8086
stack. The stack is where the 8086 stores important machine state
information, subroutine return addresses, procedure parameters, and
local variables. In general, you do not modify the stack segment
register because too many things in the system depend upon it.
b) Write an 8086 assembly language program to compare two 8M
strings using
(i) String instructions
(ii) Without using string instructions.
Ans.
i) ALP With string Instruction
section .text
global _start ;must be declared for using gcc
equal:
mov eax, 4
Page 29 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
mov ebx, 1
mov ecx, msg_eq
mov edx, len_eq
int 80h
exit:
mov eax, 1
mov ebx, 0
int 80h
section .data
s1 db 'Hello, world!',0 ;our first string
lens1 equ $-s1
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
Relevant
data SEGMENT Correct
p_str1 DB Cr, Lf, 'Enter 1st string: ',0 program
p_str2 DB Cr, Lf, 'Enter 2nd string: ',0 without
p_not1 DB Cr, Lf, 'The strings are not same because of different string
lengths',0 instructi
p_not2 DB Cr, Lf, 'The strings are not same because of different on 4M
characters',0
p_same DB Cr, Lf, 'The strings are the same',0
str1 DB 100 DUP (?)
Page 30 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
;initialize
lea si, str1
lea di, str2 ;iterate to compare characters
nxt_chk: mov al, [si] ;copy the two bytes in ax
mov ah, [di]
cmp al, ah ;compare the two bytes
jne l_not2 ;if not (ah==al)
incsi ;increment the two bytes
inc di
dec cx ;decrement the count(string length)
jzl_same ;if count=0 the strings are same
jmpnxt_chk ;else jump to check next byte
Page 31 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
CODE SEGMENT
START: ASSUME CS:CODE, DS:DATA
MOV AX,DATA Correct
MOV DS,AX program
CALL FACTORIAL 4M
MOV AH,4CH
INT 21H
PROC FACTORIAL
MOV BL,NUM ; TAKE No IN BL REGISTER
MOV CL,BL ;TAKE CL AS COUNTER
Page 32 / 33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
DEC CL ;DECREMENT CL BY 1
MOV AL,BL
UP: DEC BL ;DECREMENT BL TO GET N-
1
MUL BL ;MULTIPLY CONTENT OF N BY N-1
DEC CL ;DECREMENT COUNTER
JNZ UP ;REPEAT TILL ZERO
RET
FACTORIAL ENDP
CODE ENDS
END START
Page 33 / 33