Professional Documents
Culture Documents
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.
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.
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)
BC 0 0
DE 0 1
Hl 1 0
AF or SP 1 1
No. B7 B6 B5 B4 B3 B2 B1 B0
1 MVI r, data 0 0 D D D 1 1 0
3 MOV rd, rs 0 1 D D D S S S
Addresses : The address is a 16-bit unsigned integer ,number used to refer a memory
location.
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. 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 ; BA
RLC (A):0001 1100
RLC (A):00111000
ORA B ; 00111000
00001110
------------
00111110
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.
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.
10. Explain the operation difference between the following pairs of instructions.
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.
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.
Example:
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.
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:
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
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
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.
40H Operand
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.