Dec 15
Dec 15
Dec 15
Note: Attempt five questions in all, selecting one question from each section. Q. No. 1 is
compulsory.
Q.1.(a) Define Memory Segmentation. (4)
Ans. Memory segmentation is the division of a computer’s primary memory into segments
or sections. In a computer system using segmentation, a reference to a memory location includes
a value that identifies a segment and an offset within that segment. Segments or sections are
also used in object files of compiled programs when they are linked together into a program
image and when the image is loaded into memory.
Some of the advantages of memory segmentation in the 8086 are as follows:
(i) With the help of memory segmentation a user is able to work with registers having
only 16-bits.
(ii) By memory segmentation the various portions of a program can be of more than
68kb.
(iii) The data and the users code can be stored separately allowing for more flexibility.
(iv) Also due to segmentation the logical address range is from 0000H to FFFFH the
code can be loaded at any location in the memory.
Q.1.(b) Describe the purpose of program Counter in 8085. (4)
Ans. Program counter is a 16 bit resistor. This resistor is a memory pointer. The function
of program counter is to point to the memory location from which the next instruction is to be
executed. When a program is to be executed, it is first entered into the memory locations. Now
the program counter is loaded by the address of the first instruction to be executed. Once the
first instruction is executed, the program counter is automatically incremented to point to the
address of next instruction. The process is repeated till the end of the program.
This addressing mode is normally preferred because the instructions are compact and
fastest executing of all instruction forms. The reason why it is fastest executing is just because,
all the register reside on chip, therefore data transfer is within the chip and external bus is not at
all required.
Instruction
Opcode Register Address R
Registers
Operand
Unit – I
Q.2.(b) Subtract the 16 bit number in memory locations 2002H and 2003H from
the 16 bit number in memory locations 2000H and 2001H. The most significant eight
bits of the two numbers are in memory locations 2001H and 2003H. Store the result in
memory location 2004H and 2005H with the most significant byte in memory location
2005H. (10)
Ans. Sample problem
(2000H) = 19H
(2001H) = 6AH
(2002H) = 15H
(2003H) = 5cm
Result = 6A 19H–5C 15H= OE04H
(2004H) = 04H
(2005H) = OEH
B.Tech., 5th Semester, Solved papers, Dec 2015 85
Program
LHLD 2000H Get first 16 bit number in HL.
XCHG Save first 16 bit number in DE.
LHLD 2002H Get second 16 bit number.
MOV A, E Get lower byte of the first number.
SUB L Substract lower byte of the second number.
MOV L, A Store result in L register.
MOV A, D Get higher byte of the first number.
SUB H Subtract higher byte of second number with borrow.
MOV H, A Store 16 bit result in memory locations 2004H and 2005H.
SHLD 2004 Store 16 bit result in memory locations 2004H and 2005H.
HLT Terminate program execution.
Q.3.(a) Explain pin diagram of 8085 and describe various signals. (10)
Ans. Refer Q.3(b) of paper Dec. 2011.
Unit – II
Instruction Queue : To speed up program execution, the BIU fetches six instruction
bytes ahead of time from memory. These prefetched instruction bytes are held for the execution
unit in a group of registers called queue. With the help of queue it is possible to fetch next
instruction while current instruction is in execution. There are number of instructions in 8086
which need a quite large number of clock cycles for execution. During this execution time the
BIU fetches the next instruction or instructions from memory into the instruction queue instead
of remaining idle. The BIU continues this process as long as the queue is not full. Due to this,
execution unit gets, the ready instruction in the queue and instruction fetch time is eliminated
(while decoding or executing an instruction EU does not requir e use of the
buses).
This system has the advantage over the 8085 because, while the EU is executing an
instruction, the BIU is fetching and storing in the queue the next instructions.
The BIU’s instruction queue is based on first in first out (FIFO). So that the EU gets the
instructions for execution in the order they are fatched. If the queue is full and EU does not
request BIU for accessing memory, the BIU does not perform any bus cycle. On the other hand,
if the queue is not full and even through the EU does not request BIU for accessing the memory
the BIU can fill the queue on its own. If the EU interrupts the BIU, the BIU Ist completes the
prefetching and then attains to the service of the EU.
In case of JUMP and CALL instruction, instruction already fetched in queue are of no
use. Hence, in these cases queue is dumped and newly formed by loading instructions from new
address specified by JUMP or CALL instruction.
Execution Unit (EU) : The EU of 8086 tells the BIU from where to fetch instructions
or data, decodes instrcuction and executes instructions. It contains :
(i) Control Circuitary
(ii) Instruction Decoder
(iii) Arithmetic Logic Unit (ALU)
(iv) Flag register
(v) General purpose registers.
(vi) Pointers and Index registers.
The central circuitry in the EU directs the internal operation. A decoder in the EU
translates the instructions fetched from memory into a series of actions which the EU performs.
ALU is 6 bit. If can add, subtract, AND, OR, XOR, increment, decrements complement and
shift binary numbers.
More about Queue : In the beginning, the CS : IP is loaded with the required address
from which the execution is to be started. In the initial condition the queue will be empty and the
microprocessor starts a fetch operation to bring one byte (the first byte) of instruction code, if
the CS : IP address is odd, and two bytes at a time, if the CS : IP address is even. The first byte
is a complete opcode in case of some instructions(one byte opcode instructions), the remaining
part of opcode may lie in the second byte. But invariably the first byte of an instruction is an
opcode. These opcodes along with data are fetched and arranged in the queue. When the first
byte from the queue goes for decoding and interpretation, one byte in the queue becomes empty
and subsequently the queue is up dated.
(i) The microprocessor does not perform the next fetched operation till at least two
bytes of the instruction queue are emptied. The instruction execution cycle is never broken for
B.Tech., 5th Semester, Solved papers, Dec 2015 87
fetch operation. After decoding the first byte the decoding circuit decides whether the instruction
is of single opcode byte or double opcode byte. If the single opcode bytes, the next bytes are
treated as data bytes depending upon the decoded instruction length. Otherwise, the next byte in
the queue is treated as the second byte of the instruction opcode.
(ii) The queue is updated after every byte is read from the queue but the fetch cycle is
entreated by BIU only if at least two bytes of the queue are empty and the EU may be concurrently
executing the fetched instructions. Fig. shows the queue operation.
Unit – III
Q.6.(a) Write the purpose of following instruction in 8086 with example. (10)
(i) LOOP
(ii) RET
(iii) AAM
(iv) MOVSB
Ans. (i) LOOP : This instruction is used to repeat a series of instructions some number
of times. The number of times the instruction sequence is to be repeated is loaded into CX. Each
time loop executes CX is decremented by 1.
If CX 0 execution will jump to destination specified by label.
If CX = 0 execution will go to the next instruction after loop.
(ii) RET : It POPs a word (16–bit) from the top of the stack into the IP (near return)
and places it in Ip and CS or 32–bit number (far return) and places it in IP and CS. The execution
starts where from it left the main program. Its object code is C3. The stack has 0003H = IP. CS
= 1000H. the new address = 10000H = 0003H in Fig.
88 Microprocessing & Interfacing
refers to the data segment, it should use the logical segment called DATA. If, for example, the
assembler reads the statement MOV AX, [BX] after it reads this ASSUME, it will know that the
memory location referred to by [BX] is in the logical segment DATA.
(ii) ALIGN : The align directive is used to align the next segment at an address divisible
by specified number. The general syntax for this directive is as shown below :
ALIGN n
where n can be 2, 4, 8 or 16
(iii) CODE : The code directive is used to provide shortcut in definition of the code
segment. General syntax for this directive is as shown below :
.code [name]
The name is optional.
(iv) DATA : The data directive is used to provide shortcut in definition of the data
segment.
(v) GROUPS : A program may contain several segments of the same type i.e. code,
data, or stack. The purpose of the GROUP is to collect them all under one hut, so that they reside
within one segment, usually a data segment.
Format : Name GROUP Seg–name,......., Seg–name.
(vi) LENGTH : It is an operator which tells the assembler to determine the number of
elements in some named data item such as a string or array.
(vii)MACRO and ENDM : The macros in the program can be defined by MACRO
directive. ENDM directive is used along with the MACRO directive. ENDM defines the end of
the macro.
(viii) NAME : The name directive is used at the start of a source program to give
specific names, to each assembly module.
(ix) OFFSET : It is an operator which tells the assembler to determine the offset or
displacement of a named data item (variable) from the start of the segment which contains.
(x) ORG : It is an assembler that uses a location counter to account for its relative
position in a data or code segment.
Format : ORG expression
(xi) PAGE : The PAGE directive help to control the format of a listing of an assembled
program. At the start of a program the PAGE directive specifies the maximum number of lines
to list on a page and the maximum number of characters on a line.
Format : PAGE [length], [width]
(xii) ENDP : ENDP directive is used along with the PROC directive. ENDP defines
the end of the procedure.
(xiii) TYPE : It is an operator which tells assembler to determine the type of specified
variable. Assembler determines the type of specified variable in number of bytes. For byte type
variable the assembler gives a value of 1. For word type variable the assembler gives a value of
2 and for double word type variable the assembler gives a value of 4.
Explanation :
Consider that a block of N bytes is present at source location.
Let the number of bytes N = 10 for example.
We have to add these N bytes.
We will initialize this as count in the CX register.
We know that source address is in the SI register. This SI register will act as pointer.
Clear the direction flag.
Using ADD instruction add the contents, byte by byte of the block.
Increment SI to point to next element.
Decrement the counter and add the contents till all the contents are added.
Result is stored in AX.
Fig. : Flowchart
B.Tech., 5th Semester, Solved papers, Dec 2015 91
Algorithm :
Step I : Initialise the data segment.
Step II : Initialise SI as pointer with source address.
Step III : Initialise CX register with count.
Step IV : Initialise direction flag to zero.
Step V : Add data, word by word.
Step VI : Increment pointer i.e. SI by 2 as 16 bit addition.
Step VII : Decrement counter CX.
Step VIII : Check for count in CX, if not zero goto step V
else goto step IX.
Step IX : Store the result of addition.
Step X : Stop.
Unit – IV
Q.8. Explain the working of 8255 in mode 2 and BSR Mode. Also explain how
the contents of control registers are interpreted in BSR and I/O mode. (20)
Ans. Working of 8255 in mode 2 : In this mode group A is used as input and output
i.e. for transmitting and receiving data from peripheral through 8255 as shown in fig.(a).
The transfer of data is achieved by port C handshake signals. The group B can be in
Mode 0 or Mode 1.
The bi-directional data is transferred through port A so it consists of input and output
latch.
The Mode 2 is combination of Mode 1 input and output both at a time to port A.
The interrupt signals of input and output mode are combined to generate common
interrupt signal to CPU. The internal organization of these signals is as shown in fig. (b).
The different handshake signals used are OBFA , ACK A ,STBA , IBFA and INTERA. 2
handshake signals are used for output operation, 2 are used for input operation and one is common
to both.
Output operation :
OBF (Output buffer full) : This is an active low output signal generated by 8255.
When CPU writes data to output port 8255 will enable OBF signal to indicate peripheral that
data is available in output buffer.
ACK (Acknowledge) : This is an active low input signal for 8255. When the peripheral
detects OBF signal, it reads data from 8255 port and makes ACK = 0 and the ACK signal is
used to acknowledge 8255 that data is read from port so 8255 will remove OBF signal to
indicate output buffer is empty.
B.Tech., 5th Semester, Solved papers, Dec 2015 93
Input operation :
STB (strobe) : This is an active low input signal. When the peripheral writes data to
input buffer, it generates a signal STB to indicate 8255 that it has written data.
IBF (Input buffer full) : When data is available in input buffer 8255 will enable IBF
signal to indicate that data is available in input buffer.
INTR (Interrupt request) : This is an output signal given by 8255 to request CPU
service.
The INTR is generated in two different conditions input and output.
The interrupt is generated for input mode when IBF = 1, STB = 1 and INTE1 = 1 and for
output mode when OBF = 1, ACK = 1 and INTE2 = 1. The INTE1 and INTE2 are set/reset using
BSR mode, port C bits used are PC6 and PC4 respectively.
The logical equation will be,
INTRA = INTE1.ACK A .OBFA INTE 2 .STBA .IBFA
The timing diagram of Mode 2 bi-directional data transfer for data transfer from peripheral
to CPU and CPU to peripheral are as shown in Fig. (c).
The mode 2 also supports both modes of data transfer i.e. Interrupt drive I/O and status
driven I/O. The port C is used as status word and its definitions are as follows :
OBFA INTE1 IBFA INTE2 INTR A x x x
Working of 8255 in BSR : The BSR is a Port C bit set reset mode. The mode used
eight bits of Port C only. The individual bit of Port C can be set or reset by writing control word
in the control register.
The control word format of BSR mode is as shown in Fig.(d)(i) and mode selection
formal is in fig.(d)(ii).
94 Microprocessing & Interfacing
The pin of Port C, i.e., Bit 0 to Bit 7 to set or rest is chosen using Bit select bits b3b2b1,
i.e., D3, D2 and D1, of control word register. The bit to set or reset is decided by bit S/R, i.e., D0.
The BSR mode affects only one bit of Port C at a time. The bit set using BSR mode remains set
unless and until you change the bit. The bit to be set/reset is decided by control word. So to set
any bit of Port C, bit pattern is loaded in control register. Even though a BSR mode is selected it
will not affect I/O mode.
D7 D6 D5 D4 D3 D2 D1 D0
0 X X X b3 b2 b1 S/R
Fig : (d)(i )
Control Word :
D7 D6 D5 D4 D3 D2 D1 D0
I/O
I/O Mode
Fig : (d)(ii)
Q.9.(b) Explain BSR and I/O modes of 8255 PPI chips. (10)
Ans. BSR mode : It is a bit Set/Reset mode. This mode is concerned only with 8 bits of
port C. A control word with bit D7= 0 is recognized as BSR control word. It does affect any
previously transmitted control word with bit D7= 1 and thus the I/O operations of port A and port
B are not affected by a BSR control word. In the BSR mode, the individual 8 bits of port C can
be used for applications such as on/off switch.
BSR Control Word : The BSR control word written in the control register, sets or
resets one bit at a time as shown in fig.
(v) D1 and D0 : In I/O mode the bits D1 and D0 selects the port function for group B.
If these bits = 1 respective port specified is used as input port. But if bit = 0, the port is used as
output port.
From the above explanation you can observe that all the 3 modes i.e. Mode 0, Mode 1
and Mode 2 are only for group A ports, but for group B only 2 modes i.e. Mode 0 and Mode 1 are
provided.
When 8255 is reset, it will clear control word register contents and all the ports are set to
input mode. The ports of 8255 can be programmed for other modes by sending appropriate bit
pattern to control register.