You are on page 1of 14

1. Explain the classification of the instruction set of the 8085 microprocessor.

Ans:
An instruction is a binary pattern designed inside a microprocessor to perform a
specific function. 8085 has 246 instructions. Each instruction is represented by an 8-bit
binary value.
Depending upon the performance the total set is classified into five instruction sets.
Data transfer instruction: The data or information is transferred from memory to
processor or into the registers of processor or processor to memory.
Arithmetic instruction: The arithmetical operation is performed into the processor.
Logical instruction: The logical operation is performed in the processor.
Branch Instruction: When performing the subroutine or interrupt driven program, then
this instruction is needed.
Machine control instruction: By using these instructions the machine or operation is
under controlled.

2. Explain the various elements of instructions.


Ans:
Operation code: The operation code field in the instruction specifies the operation to be
performed. The operation is specified by binary code, hence the name operation code or
simply opcode. For example, for 8085 processor operation code for ADD B instruction is
80H.

Source / destination operand: The source/destination operand field directly specifies the
source/destination operand for the instruction. In 8085, the instruction MOV A,B has B
register contents as a source operand and A register contents as a destination operand
because this instruction copies the contents of register B to register A.

Source operand address: We know that the operation specified by the instruction may
require one or more operands. The source operand may be in the 8085 register or in the
memory. Many times, the instruction specifies the address of the source operand so that
operand(s) can be accessed and operated by the 8085 according to the instruction.

In 8085, the source operand address for instruction ADD M is given by HL register pair.

Destination operand address: The operation executed by the 8085 may produce result.
Most of the times the result is stored in one operand. Such operand is known as
destination operand. The instruction which produces result specifies the destination
operand address. In 8085, the destination operand address for instruction INR M is given
by HL register pair because INR M instruction increments the contents of memory
location specified by HL register pair and stores the result in the same memory location.

Next instruction address: The next instruction address tells the 8085 from where to
fetch the next instruction after completion of execution of current instruction. For
BRANCH instructions the address of the next instruction is specified within the
instruction. However, for other instruction, the next instruction to be fetched immediately
follows the current instruction. For example, in 8085, instruction after INR B follows it.
The instruction JMP 2000H specifies the next instruction address as 2000H.

3. Give the instruction format for 8085.


Ans:
1-byte instruction: The instruction is held only single byte.
2-byte instruction: The two memory locations are needed to execute this particular
instruction.
3-byte instruction: The three memory locations are needed.

4. Give the opcode formats for 8085.


Ans:
The 8085A microprocessor has 8-bit opcodes. The opcode is unique for each Instruction
and Data Format of 8085 and contains the information about operation, register to be
used, memory to be used etc. The 8085A identifies all operations, registers and flags with
a specific code. For example, all internal registers are identified as shown in the Tables
2.1(a) and 2.1(b) below.

Registers Code
B 0 0 0
C 0 0 1
D 0 1 0
E 0 1 1
H 1 0 0
L 1 0 1
M (Memory) 1 1 0
A 1 1 1
Table 2.1(a)

Register Pairs Code

BC 0 0

DE 0 1

Hl 1 0

AF or SP 1 1

Table 2.1 (b)


Similarly, there are different codes for each opera are identified as follows :

Sr. Function Operation code

No. B7 B6 B5 B4 B3 B2 B1 B0

1 MVI r, data 0 0 D D D 1 1 0

2 LXI rp, data 0 0 D D 0 0 0 1

3 MOV rd, rs 0 1 D D D S S S

5. Explain the various data formats supported by 8085.


Ans:
The operand is an another name for data. It may appear in different forms :

Addresses : The address is a 16-bit unsigned integer ,number used to refer a memory
location.

Numbers/Data : The 8085 supports following numeric data types.

 Signed Integer : A signed integer number is either a positive number or a


negative number. In 8085, 8-bits are assigned for signed integer, in which
most significant bit is used for sign and remaining seven bits are used for
Sign bit 0 indicates positive number whereas sign bit 1 indicates negative
number.
 Unsigned Integer : The 8085 microprocessor supports 8-bit unsigned
integer.
 BCD : The term BCD number stands for binary coded decimal number. It
uses ten digits from 0 through 9. The 8-bit register of 8085 can store two
digit BCD
Characters : The 8085 uses ASCII code to represent characters. It is a 7-bit
alphanumeric code that represents decimal numbers, English alphabets, and other special
characters.

6. Write the two ways to initialize stack pointer at FFFFH.


Ans:
To set up the stack pointers, enter each mode with interrupts disabled, and assign the
appropriate value to the stack pointer. The stack pointer value set up in the reset handler
is automatically passed as a parameter to __user_initial_stackheap() by C
library initialization code.

7. How many times will the two JNZ instructions be executed in the following sequence?
What will be the contents of H and L when the program control reaches to HLT
instruction?
LXI H, 0503H
LOOP: DCR L
JNZ LOOP
DCR H
JNZ LOOP
HLT

 Since LXI H, 0503H then H is 05 and L is 03 the loop runs till it is 0000 hence
the JNZ loop runs for 503 times.
 The contents of H and L is 00 because at rnd both H and L are decremented until
00.

8. Explain the following instructions:


a. LHLD 8850- this instruction copies the contents of the memory location given
within the instruction into the L register and the contents of the next memory
location into the H register.
b. XTHL - is a mnemonic that stands for “eXchange Top of stack with HL”. This
instruction exchanges the contents of memory location pointed by the stackpointer
with the contents of L register and the contents of the next memory location with
the contents of H register. The instruction does not modify stack pointer contents.
c. DAD H – This instruction add register pair to H and L registers. The 16-bit
contents of the specified register pair are added to the contents of the HL register
and the sum is stored in the HL register. The contents of the source register pair
are not altered. If the result is larger than 16 bits, the CY flag is set. No other flags
are affected.
d. INR M- this instruction increments the contents of memory location pointed by
HL register pair by 1. The result is stored at the same memory location. The HL
register pair is used as a memory pointer.

8. Analyze the 8085 code below to reveal the arithmetic operation performed:
MVI A, 07
RLC
MOV B, A
RLC
RLC
ORA B
Ans:
MVI A, 07 ; (A) 07 = 0000 0111
RLC ; (A) 00001110
MOV B, A ; BA
RLC (A):0001 1100
RLC (A):00111000
ORA B ; 00111000
00001110
------------
00111110

10. Explain the contents of the accumulator to run SIM Instructions


Ans:
When SIM instruction is executed then the content of the Accumulator decides the action
to be taken. So before executing the SIM instruction, it is mandatory to initialize Accumulator
with the required value. The meaning and purpose of the various bits of the accumulator when
SIM is executed has been depicted below – 

10. Explain restart as software instructions. Explain the implementation of RST5.


Ans:
Interrupt: Interrupt is a mechanism by which an I/O or an instruction can temporarily
suspend the normal execution of processor and jump to a subroutine program. Interrupts
are used to in case some urgent priority task has to be accomplished.

There are two types of interrupt in 8085: Hardware Interrupt and Software Interrupt

Software Interrupt: There are 8 software interrupts in 8085 which can enabled during
the course of the program.

1. RST 0 (Vector Address 0000H)


2. RST 1 (Vector Address 0008H)
3. RST 2 (Vector Address 0010H)
4. RST 3 (Vector Address 0018H)
5. RST 4 (Vector Address 0020H)
6. RST 5 (Vector Address 0028H)
7. RST 6 (Vector Address 0030H)
8. RST 7 (Vector Address 0038H)

When RST 5 instruction is received by 8085, it will save the address of the next
instruction of the normal control flow on the stack and jump to the memory
location 0028H where it will find the subroutine program to be executed. After the
execution of the subroutine, the control will jump back to the main program and resume
the normal control flow (the address saved on the stack is used to get back to the main
program).
10. Explain the instructions RIM and SIM.
Ans:
Set Interrupt Mask (SIM) :
In 8085 Instruction set, SIM stands for “Set Interrupt Mask”. It is 1-Byte instruction
and it is a multi-purpose instruction.

The main uses of SIM instruction are –


 Masking/unmasking of RST7.5, RST6.5, and RST5.5
 Reset to 0 RST7.5 flip-flop.
 Perform serial output of data.
Read Interrupt Mask (RIM) :
In 8085 Instruction set, RIM stands for “Read Interrupt Mask”. It is a 1-Byte multi-
purpose instruction.
It is used for the following purposes –
 To check whether RST7.5, RST6.5, and RST5.5 are masked or not.
 To check whether interrupts are enabled or not.
 To check whether RST7.5, RST6.5, or RST5.5 interrupts are pending or not.
 To perform serial input of data.

10. Define the instruction and instruction set.


Ans:
An instruction of a computer is a command given to the computer to perform a
specified operation on given data. In microprocessor, the instruction set is the collection
of the instructions that the microprocessor is designed to execute.

10. Explain the operation difference between the following pairs of instructions.

a. SPHL and XTHL-


SPHL instruction copies the contents of HL register pair to the stack pointer
(SP).It means that the stack pointer will now point to the memory location whose
address was given in the HL register pair.

No flags are affected.


It is a one byte instruction.
Register addressing mode is used.
While XTHL instruction exchanges the contents of the memory location pointed
by stack pointer with the contents of the L register and the contents of the next
memory location with the contents of H register. This instruction does not alter
the contents of the stack pointer.

No flags are affected.


It is a one byte instruction.
Register Indirect addressing mode is used.

b. LHLD and SHLD addr-


LHLD stands for Load H and L Registers Direct . This instruction copies
the contents of the memory location pointed by the 16-bit address in register L
and copies the contents of the next memory location in register H. The contents of
source memory locations are not altered. The execution of LHLD instruction can
not affect the flags. While SHLD stands for store H and L Registers Direct. The
contents of register L are stored in the memory location specified by the 16- bit
address in the operand, and the contents of H registers are stored in the next
memory location by incrementing the operand. The contents of the HL pair
register are not altered. This is also a 3-byte instruction. The second byte specifies
the low-order address and the third byte specifies the high-order address. No flags
are affected.
c. INR A and ADI 01 H –
In INR A the contents of the designated register or the memory are
incremented by 1 and their result is stored at the same place. While in ADI 01 H
the 8-bit data is added to the contents of the accumulator and the result is stored
in the accumulator.

d. CALL addr and JMP addr -


If a JMP instruction is executed, we jump to the destination location, and
the execution carries on from there, without bothering to come back later to the
instruction after the JMP. On the other hand, if a CALL instruction is executed,
we jump to the subroutine, and the execution carries on from there till the RET
instruction is executed in the subroutine, and then we come back to the instruction
after the CALL in the main program.

e. XRA A and MVI A, 00H-


XRA A a one-byte instruction that performs the XOR operation with
accumulator itself. While MVI A, 00H is a two-byte instruction that loads 00H
into the accumulator.

f. DAD RP and DAA –


DAD rp instruction is a 1-Byte instruction. With this instruction, with the
content of the HL register pair, the contents of the mentioned register pair will get
added and the result thus produced will be stored on the HL register pair. The
instruction of DAA is used in the program after ADD, ADI, ACI, ADC, etc
instructions. After the execution of ADD, ADC, etc. instructions the result is in
hexadecimal and it is placed in the accumulator. The DAA instruction operates on
this result and gives the final result in the decimal system. It uses carry and
auxiliary carry for decimal adjustment. 6 is added to 4LSBs of the content of the
accumulator if their value lies between A and F or the AC flag is set to 1.
Similarly, 6 is also added to 4 MSBs of the content of the accumulator if their
value lies in between A and F or the CS flag is set to 1. All status flag is affected.
When DAA is used data should be in decimal numbers.

10. Explain the operation of following instructions and specify addressing mode and number
of M/C required:
a. DAA - The DAA (Decimal Adjust after Addition) instruction allows addition of numbers
represented in 8-bit packed BCD code. It is used immediately after normal addition
instruction operating on BCD codes. This instruction assumes the AL register as the
source and the destination, and hence it requires no operand.
b. DAD B – This instruction adds the contents of the specified register pair to the contents
of the HL register pair and stores the result in the HL register pair. The rp is 16-bit
register pair such as BC, DE, HL or stack pointer. Only higher order register is to be
specified for register pair within the instruction. DAD B is 1-Byte instruction so it
occupies a single Byte place in the memory.
c. XTHL - This instruction exchanges the contents of memory location pointed by the
stack pointer with contents of L register and the contents of the next memory location
with contents of H register. This instruction does not modify stack pointer contents.
d. CNC addr - CNC is a mnemonic, which stands for “Call if Not Carry”. This instruction is
used to branch to the subroutine whose 16-bit address is provided in the instruction, only
if Cy flag value is 0. If Cy flag value is 1, program flow continues in the main program
sequentially. It is a3-Byte instruction.

10. Explain the operation perform by 8085 when the following instructions are executed,
a. SBB C - This instruction will subtract the contents of C register and carry flag from
the contents of accumulator. It will store the result in the accumulator.
b. RRC – This instruction rotates the contents of the accumulator right by one position. Bit
B0 is placed in B7 as well as in CY.
c. LDAX B -  This instruction copies the contents of that memory location into the
accumulator. The contents of either the register pair or the memory location are not
altered. LDAX B is a 1-Byte instruction so it will occupy 1-Byte in the memory.
d. XTHL - In 8085 Instruction set, XTHL is a mnemonic that stands for “eXchange Top of
stack with HL”. This instruction exchanges the contents of the top two locations of the
stack with the contents of register pair HL.
10. Explain the various step involved while executing CALL instruction with an example.
Ans:
The CALL instruction is used to transfer program control to a subprogram or
subroutine. This instruction pushes the current PC contents onto the stack and loads the
given address into the PC. Thus the program control is transferred to the address given in
the instruction. Stack pointer is decremented by two.
When the subroutine is called, the program control transferred from calling
program to the subroutine. After execution of subroutine it is necessary to transfer
program control back to the calling program. To do this processor must remember the
address of the of the instruction next to the CALL instruction. Processor saves this
address on the stack when the CALL instruction is executed.

Note: The stack is a part of read/write memory set aside for storing intermediate results
and addresses.

Operation: (SP – 1)  PCH


(SP – 2)  PCL
SP  SP – 2
PC  addr

Example: Stack pointer = 3000H.


6000H CALL 2000H ; This instruction will store the address of instruction next to
CALL (i.e. 6003H) on the stack and load PC
6003H -- with 2000H.

Before Execution

SP 3000 2FFEH
PC 6000 2FFFH

3000H

After Execution

SP 2FFE 2FFEH 03
PC 2000 2FFFH 60

3000H
10. Explain DAA instruction with an example.
Ans:
This instruction adjusts accumulator to packed BCD (Binary Coded Decimal)
after adding two BCD numbers.

Instruction works as follows:


1. If the value of the lower-order four bits (D3-D0) in the accumulator is greater than 9 or
if auxiliary carry flag is set, the instruction adds 6(06) to the lower order four bits.
2. If the value of the higher-order four bits (D7-D4) in the accumulator is greater than 9 or
if carry flag is set, the instruction adds 6(60) to the higher-order four bits.

Example:

If, A = 0011 1001 = 39 BCD


And C = 0001 0010 = 12 BCD then
ADD C ; Gives A = 0100 1011 = 4BH
DAA ; adds 0110 because 1011>9,
; A=0101 0001 = 51 BCD
If A = 1001 0110 = 96 BCD
And D = 0000 0111 = 07 BCD then
ADD D ; Gives A = 1001 1101 = 9DH
DAA ; adds 0110 because 1101>9,
A = 1010 0011 = A3H,
1010 > 9 so adds 0110 0000,
A = 0000 0011 = 03 BCD, CF = 1.

10. What is a program?


Ans:
Programming is a process of writing the set of instructions which tells the
microprocessor what to do. We can say that programming is the process of telling the
processor exactly how to solve a problem. To do this, the programmer must “speak” to
the processor in a language which processor can understand.

10. Give the steps involved in programming. 


Ans:
Specifying the problem:
The first step I the programming is to find out which task is to be performed. This is
called specifying the problem. If the programmer does not understand what is to be done,
the programming process cannot begin.

Designing the problem-solution:


During this process, the exact step by step process that is to be followed (program logic)
is develop and written down.

Coding:
Once the program is specified and designed, it can be implemented. Implementation
begins with the process of coding the program. Coding the program means tell the
processor the exact step by step process in its language. Each processor has a set of
instructions. Programmer has to choose appropriate instructions from the set to build the
program.

Debugging:
Once the program or a part of the program is coded, the next step is debugging the code.
Debugging is the process of testing the code to see if it does the given task. If the
program is not working properly, debugging process helps in finding and correcting
errors.

To write a program, programmer should know:


 How to develop program logic?
 How to tell the program to the processor?
 How to code the program?
 How to test the program?

10. What is a flowchart? Explain its usage.


Ans:
Flow chart is a graphical tool that allows programmer to represent various actions
which are to be performed. The graphical representation is very useful for clear
understanding of the programmer logic.

10. Explain the process of writing an assembly language program with the help of an
example.
Ans:
Let us define a program statement as ‘write an assembly language program to add two
numbers’. The three tasks are involved in this program:

 Load two hex numbers


 Add numbers and
 Store the result in the memory
These tasks can symbolically presented as flowchart, as shown in the Figure below.
Next job is to find the suitable 8085 assembly language instruction/s for each task. These
instructions are as follows:

Task 1 instruction:
MVI A, 20H ; Load 20H as a first
; number in a register A
MVI B< 40H ; Load 40H as a second number
; in register B

Start
Load two hex
numbers

Add numbers

Store the result

Stop

Task 2 Instruction:
ADD B ; Add two numbers and save
; result in register A
Task 3 instruction:
STA 2200H ; Store the result in memory
; location 2000H
HLT ; Stop the program execution

We want to execute three tasks in a sequence thus writing corresponding


instructions in the same sequence constitute an assembly language program.

10. What do you understand by hand assembly? Explain with the help of an example.
Ans:
Once the assembly language program is ready, it is necessary to convert it in the
machine language program. It is possible to do this by referring the process hex code for
each assembly instruction from the 8085 instruction manual. This process is known as
hand assembly and the resulted machine language program is also known as hex code.

Hex code for our program:

Mnemonics Hex code

MVI A, 20H 3EH  Opcode


20H  operand

MVI B, 40H 06  Opcode

40H  Operand

ADD B 80H  Opcode

STA 2200H 32H  Opcode

00H  Operand
(lower byte if address)
22H  Operand
(higher byte of
address
HLT 76H  Opcode

10. Explain the process of executing the program on the microprocessor training kit.
Ans:
The microprocessor training kit provides a procedure to execute the program. To
activate the procedure we have to enter the starting address of the program (2000H in our
example). To enter this address we have to go into execute mode by pressing GO key and
enter the starting address using hex keys. Once the starting address is entered, the
program can be executed by pressing EXECUTE key. The EXECUTE key procedure
loads the starting address of our program, 2000H into the program counter and program
control is transferred from monitor program to our program.
After this microprocessor reads one hex code at a time, and when it fetches the
complete instruction, it executes that instruction. Then it fetches the next instruction and
this process continue until the last instruction in the program is executed.

You might also like