Professional Documents
Culture Documents
Bael
BSEE – III
Answer:
Data transfer operations, arithmetic operations, logical operations, branching operations,
and Stack, Input/output, machine-control operations are the five functional categories of
these instructions. Data transfer instructions are used to transfer data between registers or
between memory and registers. A data transfer instruction with a „X‟ in its name deals
with a register pair (16-bits). These instructions have no effect on the processor‟s flag
register. Data in registers or on condition flags. The logical AND, OR, and Exclusive OR
instructions allow you to turn specific accumulator bits ON or OFF. The branching
instructions either unconditionally or conditionally change the normal sequential program
flow. Conditional branching instructions check the status of one of four condition flags to
determine whether or not to execute the specified branch. The stack instructions allow the
transfer of data from register pair to stack memory memory is added, subtracted,
incremented, or decremented using arithmetic instructions. The logical operations
function performs logical (Boolean) operations on data in registers and memory, as well
as and from stack memory to the register pair. The input/output instructions allow the
transfer of 8-bit data to input/output port. On the other hand, machine instructions control
the machine operations such as interrupt, halt, or do nothing.
Each Instruction Format of 8085 and Data Format of 8085 microprocessor has specific
information fields. These information fields of instructions are called elements of
instruction. These are:
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 the Instruction Format of 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 Format of 8085 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 of the operand. Such operand is known as
destination operand. The Instruction and Data Format of 8085 which produce 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 instructions, 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.
Answer:
Instruction Formats:
The Instruction Format of 8085 set consists of one, two and three byte instructions. The
first byte is always the opcode; in two-byte instructions the second byte is usually data; in
three byte instructions the last two-bytes present address or 16-bit data.
One-byte instruction:
For Example: MOV A, B whose opcode is 78H which is one byte. This Instruction and
Data Format of 8085 copies the contents of B register in A register.
Two-byte instruction:
For Example: MVI B, 02H. The opcode for this instruction is 06H and is always followed
by a byte data (02H in this case). This instruction is a two-byte instruction which copies
immediate data into B register.
Three-byte instruction:
For Example: JMP 6200H. The opcode for this instruction is C3H and is always followed by
16-bit address (6200H in this case). This instruction is a three-byte instruction which loads
16-bit address into program counter.
Answer:
Opcode Format of 8085:
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.2(b).
Similarly, there are different codes for each opera are identified as follows:
Note: DDD defines the destination register, SSS defines the source register and DD defines
the register pair
The operand is another name for data. It may appear in different forms:
Addresses
Numbers/Logical data and
Characters
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 digits BCD
The two ways to initialize stack pointer at FFFFH are the PUSH and POP. When the
information is written on the stack, it is called PUSH. When the information is read
from the stack, the operation is called POP. During PUSH and POP operation, stack
pointer register gives the address of the memory where the information is to be stored
or to be read
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
Answer:
LHLD 8850- In 8085 Instruction set LHLD is a mnemonic that stands for
Load HL pair using Direct addressing from memory location whose 16-bit
address is denoted as a16. This instruction will copy the contents of L register
at address 2500H and the contents of H register at address 2501H.
DAD H- DAD is a mnemonic, which stands for Double ADd and also rp
specifically HL. In this instruction, HL register pair works as Accumulator.
Because the 16-bit content of rp will be added with HL register pair content
and sum thus produced will be stored back on to HL again. It is a sample
instruction of this category. As It is 1-Byte instruction so it occupies a single
Byte place in the memory.
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.
11. Explain restart as software instructions. Explain the implementation of RST5.
Answer:
In 8085 Instruction set, RSTn is actually standing for “Restart n”. And in this case, n
has a value from 0 to 7 only. Thus the eight possible RST instructions are there, e.g.
RST 0, RST 1, …, RST 7. They are 1-Byte call instructions. RST 5 causes a branch
to a subroutine at 5*8 = 0028H
In 8085 Instruction set, SIM stands for “Set Interrupt Mask”. It is 1-Byte instruction
and it is a multi-purpose instruction.
14. Explain the operation difference between the following pairs of instructions.
Answer:
a.) SPHL and XTHL
SPHL - This 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.
XTHL- This 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.
b.) LHLD and SHLD addr
LHLD addr 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 H register.
SHLD addr stores the contents of L register in the memory location given within the
instruction and contents of H register at address next to it. This instruction is used to store
the contents of H and L registers directly into the memory. The contents of the H and L
registers remain unchanged.
Whereas, ADI is an 8-bit data which adds the immediate to the accumulator. The 8-bit data
is added to the contents of the accumulator and the result is stored in the accumulator.
Under Unconditional CALL, CALL addr calls the subroutine identified by the address.
Under Conditional CALL, CALL addr calls the subroutine identified by the address if the
specified condition is fulfilled.
JMP addr, under Unconditional Jump, JMP addr jumps to the instruction specified by the
address. Under Conditional Jump, JMP addr jumps to the instruction specified by the
address if the specified condition is fulfilled.
JMP addr loads the PC with the address given within the instruction and resumes program
execution from this location.
DAA instruction then adjusts accumulator to packed BCD after adding two BCD numbers.
15. Explain the operation of following instructions and specify addressing mode and number
of M/C required:
Answer:
a.) DAA- DAA instruction then adjusts accumulator to packed BCD after adding two BCD
numbers.
b.) DAD B- DAD B is a sample instruction. It is 1-Byte instruction so it occupies a single Byte
place in the memory. So this instruction DAD B requires 1-Byte, 3 Machine Cycle (Opcode
Fetch, Bus Idle, Bus Idle) and 10 T-States for execution. This instruction takes 10 T states
including opcode fetch. The opcode fetch cycle takes 4 T states and the remaining 6 T
states, divided into two Machine Cycles, are for the instruction execution. During these 6 T
(two Machine Cycles) states no bus operations are performed.
c.) XTHL- This instruction exchanges the contents of memory location pointed by the stack
pointer with the contents of L registers and the contents of the next memory location with
the 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.
16. Explain the operation perform by 8085 when the following instructions are executed,
Answer:
a.) SBB C- this instruction will subtract the contents of C register (20H) and carry flag (1) from
the contents of accumulator (40H). It will store the result (40H-20H-1-1FH) in the
accumulator.
b.) RRC-stands for “Rotate Right Accumulator”. With the help of this instruction, we can
rotate the Accumulator current content to the right by 1- bit position. 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- LDAX B requires 1-Byte, 2-Machine Cycles (Opcode Fetch, Memory Read) and
7 T-States for execution. LDAX B- loads the accumulator with the contents of memory
location pointed by BC register pair.
d.) XTHL– This instruction exchanges the contents of memory location pointed by the stack
pointer with the contents of L registers and the contents of the next memory location with
the contents of H register. This instruction does not modify stack pointer contents.
Answer:
DAA instruction belongs to arithmetic group that adjusts accumulator to packed BCD
(Binary Coded Decimal) after adding 2 BCD numbers. Example:
22. Explain the process of writing an assembly language program with the help of an example.
Answer:
In writing assembly language, 3 tasks are involved for this example, „write an assembly
program to add two numbers‟. Task 1 is to load 2 hex numbers, task 2 is add numbers then task
3 is store result in the memory. Example:
23. What do you understand by hand assembly? Explain with the help of an example.
Answer:
Hand assembly is the process of converting assembly language to machine language program
by referring the proper hex code for each assembly instruction from 8085 instruction set
manual. Example is MVI A,20H to 3EH for Opcode and 20H for Operand.
24. Explain the process of executing the program on the microprocessor training kit.
Answer:
In executing the program, the microprocessor training kit provides a procedure to execute it.
Entering the starting address of the program to activate the procedure by going to execute mode
by pressing GO key and entering the starting address using hex keys. Once the starting address
is entered, the program can be executed by pressing EXECUTE key