Professional Documents
Culture Documents
1.Data Transfer Group. Instructions which are used to transfer data from one register to
another register, from memory to register or register to memory, come under this group.
Examples are: MOV, MVI, LXI, LDA, STA, etc.
Example: MOV A, B
LDA 2000
2. Arithmetic Group. It performs arithmetic operations addition, subtraction,
increment/decrement of content of a register or memory. Examples are: ADD, SUB, INR,
DAD, DCR, etc.
3.Logical Group. It performs logical operations such as AND, OR, compare, rotate, etc.
Examples are: ANA, XRA, ORA, CMP, RAL, etc.
4.Branch Control Group. It includes the instructions for conditional and unconditional
jump, subroutine call and return, and restart. Examples are: JMP, JC, JZ, CALL, etc.
5.I/O and Machine Control Group. It includes the instructions for I/O ports, stack and
machine control. Examples are: IN, OUT, PUSH, POP, HLT, etc.
Intel 8085 is an 8-bit microprocessor. It handles 8-bit data at a time. A memory location
for Intel 8085 microprocessor is designed to accommodate 8-bit data. If 16-bit data are to be
stored, they are stored in consecutive locations. The address of memory location is of 16 bits i.e.
2 bytes.
1
iv. Some instructions specify two registers. The contents of the registers are the
required data.
v. In some instructions data is implied. The most instruction of this type operate on
the content of the accumulator.
Due to different ways of specifying data for instructions, the machine codes of all
instructions are not of the same length.
There are three types of Intel 8085 instructions as described below:
1) Single-Byte Instruction
2) Two-Byte Instruction
3) There-Byte Instruction
STATUS FLAGS
There is a set of five flip-flops which indicate status (conditions) arising after the execution of
arithmetic and logic instructions.
Symbol/Addressing Meaning
------------------------- ------------
addr 16-bit address of memory location
data 8-bit data
data 16 16-bit data
r, r1, r2, one of the registers A, B, C, D, E, H or L
A, B, C, D, H, L 8-bit register
A Accumulator
H-L Register pair H-L
B-C Register pair B-C
D-E Register pair D-E
PSW Program Status Word
M Memory whose address is in H-L pair
H Appearing at the end of a group of digits specifies hexadecimal.
Eg. 2500H
rp One of the register pairs
Example : B represents B-C pair, B is the higher order
and C lower order, D represents D-C pair, D is higher order
register and E is the lower order register pair.
H represents H-L pair, H is the higher order register and
L is the lower order register. SP represents 16-bit stack
2
Pointer. SPH is high order 8-bits, and SPL is the low order 8 bits
^ AND operation
V OR operation
Some of Intel 8085 instructions are frequently, some occasionally and some seldom used by the
programmer. It is not necessary that one should learn all of the instructions to understand
simple programs.
1. MOV r1, r2
(Move data: move the content of the one register to another)
The content of register r2 is moved to register r1, for example, the instruction MOV A,B move
the content of register B to register A. the instruction MOV B,A moves the content of register A
to register B. the time for the execution of this instruction is 4 clock period. One clock period is
called state. No flag is affected.
[r1] ← [r2]
3
2. MOV r.M : (Move the content of memory to register)
[r] ← [[H-L]]
The content of the memory location, whose address is in H-L pair, is moved to register r.
Example:
LXI H,2000 H Load H-L pair by 2000H.
MOV B, M Move the content of the memory location 2000H to register B.
HLT Halt.
In this example the instruction LXI H,2000H loads H-L pair with 2000HWhich is the address of
a memory location, Then the instruction MOV B,M will move the content of the memory
location 2000H to register B.
3. MOV M, r: [move the content of register to memory]
[[H-L]] ← [r]
The content of register r is moved to the memory location addressed by H-L pair. For example,
MOV M, C moves the content of register C to the Memory location whose address is in H-L
pair.
4.MVI r, data: (Move immediate data to register)
[r]← data.
Here the 1st byte of the instruction is its opcode. The 2nd byte of the instruction is the data which
is moved to register r .For example, the instruction
MVI A,05 moves 05 to register A. The opcode is written as 3E,05
The opcode for MVI A is 3E and 05 is the data which is to be moved to register A.
5. MVI M, data. (Move immediate data to memory whose address is in HL pair).
[[H-L]] ← data.
The data is moved to memory location whose address is in H-L pair.
Example
LXI H, 2400H Load H-L pair with 2400H.
MVI M, 08 Move 08 to the memory location 2400H.
4
HLT Halt
In the above example the instruction LXI H,2400H loads H-L pair with 2400 H which is the
address of a memory location. Then the instruction MVI M,08 will move 08 to memory location
2400H. in the code form it is written as 36,08. The opcode for MVI M is 36 and 08 is the data
which is to be moved to the memory location 2400H.
6. LXI rp , data 16. (load register pair immediate).
[rp]←data 16bits, [rh]←8 MSBs,[rl] ← LSBs of data.
This instruction is for register pair; only high order register is mentioned after the
instruction. For example, H in the instruction LXI H stands for H-L pair. Similarly, LXI B is for
B-C pair. LXI D,2500H loads 2500H into D-E pair. H with 2500H denotes that the data 2500 is
in hexadecimal. In the code form it is written as 21, 00 ,25. The 1st byte of the instruction 21 is
the opcode for LXI H. the 2nd byte 00 is 8 LSBs of the data and it is loaded into register L. The
3rd byte 25 is 8MSBs of the data and it is loaded into register H.
5
10. SHLD addr. (store H-L pair direct)
[addr] ← [L], [addr+1] ← [H]
The content of register L is stored in the memory location whose address is specified by the 2nd
and 3rd bytes of the instruction. The content of register H is stored in the next memory location.
For example, SHLD 2500H will store the content of register L in the memory location 2500H.
The content of register H is stored in the memory location 2501H.
11. LDAX rp. (LOAD accumulator indirect)
[A] ← [[rp]]
The content of the memory location, whose address is in the register pair rp, is loaded into the
accumulator, For example, LDAX B will load the content of the memory location, whose
address is in the B-C pair, into the accumulator. This instruction is used only for B-C and D-E
register pairs.
12. STAX rp, (Store accumulator indirect)
[[rp]] ← [A]
The content of the accumulator is stored in the memory location whose address is in the register
pair rp. For example, STAX D will store the content of the accumulator in the memory location
whose address is in D-E pair. This instruction is true only for register pairs B-C and D-E.
13. XCHG. (exchange the content of H-L with D-E pair)
[H-L] ↔ [D-E]
The content of H-L pair are exchanged with contents of D-E pair.
6
2. ADD M. (add memory to accumulator).
[A]←[A] + [[H-L]].
The content of the memory location addressed by H-L pair is added to the content of the
accumulator. The sum is placed in the accumulator.
7
The content of register r is subtracted from the content of the accumulator ,and the result is
placed in the accumulator.
Eg. SUB B – The content of B register is subtracted from content of accumulator and the result
or sum is stored in accumulator.
8
The content of the memory location addressed by H-L pair is incremented by one. All flags
except CS are affected.
15.DCR r (decrement register content)
[r] ← [r] - 1
The content of register r is decremented by one. All flags except CS are affected.
16.DCR M. (decrement memory content)
[[H-L]] ← [[H-L]] -- 1
The content of memory location addressed by H-L pair is decremented by one. All flags except
CS are affected.
17.INX rp, (increment register pair)
[rp] ← [rp] + 1
The content of the register pair rp is incremented by one. No flag is affected.
18. DCX rp (decrement register pair)
[rp] ← [rp] - 1
The content of the register pair rp is decremented by one. No flag is affected.
19. DAA (Decimal Adjust Accumulator)
This instruction is used in the program after ADD, ADI, ACI and ADC instructions. After the
execution of ADD, ADC instructions, the result is in hexadecimal form and it is placed in the
accumulator. The DAA instruction operates on this result and gives the final result in the
decimal system.
The instructions of this group perform AND, OR, EX-OR operation, compare and rotate or
complement of the data stored in memory or register.
[ A] ← [A] ^ [ r ]
The content of register r is ANDed with the content of the accumulatore and the result is
placed in the accumulator.
ANA C , AND content of C register with accumulator and the result is stored in
accumulator.
9
2. ANA M. (AND memory with the Accumulator)
The content of memory location addressed by H-L pair is ANDed with the accumulator
and the result is placed in the accumulator.
The data which is the second byte of the instruction is ANDed with the content of the
accumulator and the result is placed in the Accumulator.
The content of register r is ORed with the content of the accumulator and the result is
placed in the accumulator.
ORA C , The content of Register C is Logically ORed with content of accumulator and
the result is stored in accumulator.
The content of memory location addressed by H-L pair is ORed with the content of the
accumulator and the result is placed in the accumulator.
The data which is the second byte of the instruction which is ORed with the content of
accumulator and the result is placed in the accumulator.
10
[A] ← [A] [r]
The content of register r is EXCLUSIVE-ORed with the content of accumulator and the
result is stored in accumulator.
XRA C , The content of C register is logically EX-ORed with content of accumulator and
the result is stored in accumulator.
[A ] ← [A] [[H-L]]
The content of memory location addressed by H-L pair is EXCLUSIVE-ORed with the
content of accumulator and the result is placed in accumulator.
The data which is the second byte of the instruction which is EXCLUSIVE-ORed with
the content of accumulator and the result is placed in the accumulator.
The one’s complement of the accumulator which is obtained and the result is placed in
the accumulator.
[CS] ← 1
[A] - [r]
11
The content of register r is subtracted from the content of accumulator. But the result
of the subtraction is discarded and the content of accumulator remain unchanged.
[A] - [[ H-L ]]
The content of memory location addressed by H-L pair is subtracted from the content of
the accumulator and the result of subtraction is discarded and the content of accumulator
remain unchanged.
[A] – data
The data which is the second byte of the instruction is subtracted from the content of
accumulator and the result of the subtraction is discarded. The content of accumulator
remains unchanged.
ROTATE INSTRCTIONS
The rotate instructions rotate the content of accumulator to left or right with carry or
without carry. In rotate instructions the default operand is accumulator. There are four
rotate instructions, they are RLC, RRC,RAL and RAR. The following diagram shows
accumulator with carry.
CS A7 A0
CS A7 A0
12
[An+1] ← [An] , [A0] ← [A7] , [CS] ← [A7]
The Content of accumulator is rotated left by one bit. The seventh bit of accumulator is
moved to carry bit as well as the zero bit of the accumulator . Only CS flag is affected.
CS A7 A0
The content of accumulator is rotated right by one bit. The zero bit of the accumulator is
moved to the seventh bit as well as carry bit. Only CS flag is affected.
CS A7 A0
The content of accumulator is rotated left one bit through carry. The seventh bit of the
accumulator is moved to carry and carry bit is moved to the zero bit of the accumulator.
Here only CS flag is affected.
CS A7 A0
13
[An] ←[An+1] , [CS] ← [A0] , [A7] ← [CS]
The content of the accumulator is rotated right one bit through carry. The zero bit of the
accumulator is moved to carry and the carry bit is moved to the seventh bit of the
accumulator. Only CS flag is affected.
The instructions of this group change the normal sequence of the program. There are two
types of branch instructions: conditional and unconditional. The conditional branch instructions
transfer the program to specified label when certain condition is specified. The unconditional
branch instructions transfer the program to specified label unconditionally.
Unconditional JUMP
JMP addr (label). (Jump to instruction specified by address)
[PC] ← Label.
2nd and 3rd byte of instruction give address of label where program jumps. The address of
label is address of memory location for next instruction to be executed. The program jumps to
the instruction specified by the address(label) unconditionally.
Conditional JUMP
Conditional Jump addr (label) : After execution of conditional jump the program
jumps to instruction specified by label if specified condition is fulfilled. The execution of
conditional jump takes 3 machine cycles: 10 states. If condition is not true, only 2 machine cycle;
7 states are required for execution of instruction.
14
(ii) JNZ addr (label). (jump if result is not zero)
Syntax : [PC] ← Label
The program jumps to instruction specified by label if result is non-zero.
UNCONDITONAL CALL
CALL addr (label) : (Unconditional CALL: call the subroutine identified by address)
15
pointer is decremented by two to indicate new stack top. Then the program jumps to
subroutine starting at address specified by label.
CONDITIONAL CALL
If the condition is true and program calls the specified subroutine, the execution of call
instruction takes 5 machine cycles; 18 states. If condition is not true, only 2 machine
cycles; 9 states are required for execution of instruction.
(i) CC addr (label) Call, if carry status CS=1.
(ii) CNC addr (label) Call, if carry status CS=0.
(iii) CZ addr (label) Call, if result is zero, zero status Z=1.
(iv) CNZ addr (label) Call, if result is non-zero, zero status Z=0.
(v) CP addr (label) Call, if result is plus, status S=0.
(vi) CM addr (label) Call, if result is minus, status S=1.
(vii) CPE addr (label) Call, if even parity, parity status P=1.
(viii) CPO addr (label) Call, if odd parity, parity status P=0.
UNCONDITIONAL RETURN
[PCL] ← [[SP]],
[PCH] ← [[SP] + 1],
[SP] ← [SP] + 2.
CONDITIONAL RETURN
16
RET ( Return from subroutine when condition is satisfied)
[PCL] ← [[SP]],
[PCH] ← [[SP] +1],
[SP] ← [SP] +2.
If condition is true and program returns from subroutine, the execution of conditional
return instruction takes 3 machine cycle, 12 states. If condition is not true only one
machine cycle, 6 state are required.
RST n (Restart)
17
[PC] ← [H-L], [PCH] ← [H], [PCL] ← [L]
The contents of H-L pair are transferred to PC. The contents of H are moved to high
order 8-bits of PC. The contents of L are transferred to low order 8-bits of PC.
[A] ← [Port]
The data available on port is moved to accumulator. After IN, address of port is specified.
The 2nd byte of instruction contains address of port. Address of port is an 8-bit address.
For ex., IN 01. The address of port B of an I/O port 8255.1 of a microprocessor kit is 01.
[Port] ← [A]
The content of accumulator is moved to port specified by its address. After OUT, port
address is specified. The 2nd byte of instruction contains address of port. Address of port
is an 8-bit address. For ex., OUT 00. The address of port A of an I/O port 8255.1 of a
microprocessor kit is 00.
18
4.PUSH PSW. (Push processor status word)
[[SP] – 1] ← [A],
[[SP] – 2] ← PSW (Processor Status Word),
[SP] ← [SP] – 2
The content of accumulator is pushed into the stack. The contents of status flags are also
pushed into stack. The content of register SP is decremented by 2 to indicate new stack
top.
5. POP rp. (Pop content of register pair, which was saved, from the stack)
[rl] ← [SP],
[rp] ← [[SP] + 1],
[SP] ← [SP] + 2
The content of register pair, which was saved earlier is moved from stack to register pair.
The PSW, which was saved earlier during the execution of program is moved from stack
PSW. The content of accumulator which was also saved is moved from stack to
accumulator.
7. HLT (Halt)
The execution of instruction HLT stops the microprocessor. The registers and status flags
remain unaffected.
19
10. EI (Enable Interrupt)
When this instruction is executed bits 0-5 of accumulator are used in programming the
restart interrupt masks. Bits 6-7 of accumulator are used in making serial output SOD.
When this instruction is executed, accumulator is loaded with pending interrupts, the
restart interrupt masks and contents of serial input SID.
No operation is performed when this instruction is executed. The registers and flags
remain unaffected.
ASSEMBLY LANGUAGE
Writing of program in machine language is very difficult, tiresome, boring and error.
Hence to facilitate programmers easily understandable languages have been developed.
Assembly language is one of them. A programmer easily write a program in alphanumeric
symbols instead of zeros and ones.
Examples are: ADD for addition, SUB for subtraction, CMP for comparison etc. Such
symbols are called Mnemonics. A program written in mnemonics is known as assembly
language program. The writing of a program in assembly language is much easier and faster
as compared to the writing of a program in machine language.
Both assembly language and machine language are microprocessor specific. A
microprocessor-specific language is known as a low-level language. When a program is written
in a language other than machine language, a computer cannot understand.
A program which translates an assembly language program into a machine language
program is called an assembler. A self-assembler/resident assembler is an assembler which
runs on microcomputer for which it produces object codes. A cross-assembler is an assembler
that runs on a computer other than that for which it produces object codes.
20
Disassembler is a software aid to convert a machine language program to an assembly
language program. Its role is complementary to that of an assembler. It is useful in situations
when a program is available in machine language and it is to be converted to assembly language
for better understanding.
An assembler which goes through an assembly language program only once is known as
one-pass assembler.the Such an assembler must have some technique to take the forward
references. The assembly labels that may appear later on in the program . Such labels are
called as forward references.
The assembler which goes through an assembly language program twice is called as a
two pass assembler. Such an assembler does not face difficulty with forward references.
During the first pass it collects all labels. During second pass it produces the machine code for
each instruction and assigns addresses to each of them. It assigns addresses to labels by
counting their positions from the starting address.
One-pass assembler is faster as it goes through a program only once. Its disadvantage is that it
does not provide many feature s as a two pass assembler can. The two pass assemblers are
commonly used.
An assembly language program for addition of two numbers placed in two consecutive memory
locations 2501H and 2502H is given below:
Example:
Mnemonics operands Comments
LXI H, 2501H Get the address of 1st number in H-L Pair
MOV A, M Get the 1st number in accumulator
INX H Increment content of H-L pair
ADD M Add the 1st and 2nd number
STA 2503H Store sum in 2503
HLT Stop
DATA
2501 – 49H
2502 – 56H
RESULT
2503 – 9F
21
The programmer first of all writes program in assembly language and then fills up
machine code corresponding to each mnemonic. This is called hand assembly. The codes are
written in hexadecimal system.
Advantages:
1. Computation time is less.
2. Faster to produce result.
Disadvantages:
1. Programming is difficult and time consuming.
2. Not portable.
3. Each statement in high-level language corresponds to many assembly language
instructions.
STACK
During execution of program sometimes it becomes necessary to save contents of certain
registers because the registers are required for some other operation in subsequent steps. These
contents are moved to certain memory locations by PUSH operation. Then these registers are
used for other operations. After completing operations those contents which were saved in
memory are transferred back to registers by POP operation. Memory locations for this purpose is
set by the programmer at the beginning. The set of memory locations kept for this purpose is
called stack. The last memory location of the occupied portion of the stack is called stack-top. A
special 16-bit register known as stack pointer holds the address of stack-top. Any area of RAM
can be used as stack. The stack pointer is initialized in the beginning of the program by LXI SP
or SPHL instruction.
Data are stored in stack on LIFO (Last-In-First-Out) memory. Stack is faster than
memory access. SP register holds the address of stack-top location. PUSH operation moved the
contents of register to stack. POP operation is used to transfer the contents from stack to register.
The following diagram shows the stack before PUSH and after PUSH operation. Also diagram
shows before POP and after POP operation.
22
The following diagram shows the stack before and after push operation.
The following diagram shows the stack before and after pop operation
23
SUBROUTINES
While writing the program certain operations may occur several times and they are
not available as individual instruction. The program for such operations are repeated again
and again in main program. The simple example of such operation is multiplication. The
Intel 8085 does not provide multiplication instruction.
The concept of subroutines is used to avoid the repetition of smaller programs. The
small program for a particular task is called subroutine. Subroutines are written
separately and stored in memory. They are called at various points of main program by
CALL instruction where they are required. The last instruction of subroutine is RET.
After completion of subroutine, main program begins from instruction immediately
following the CALL instruction.
There may be more than one subroutine in a program. The technique of subroutine saves
memory locations. The diagram shows CALL-RETURN structure.
When program execution jumps from the main program to a subroutine, the content of
PC is saved in the stack so that the program execution may come back to main program at proper
point after the completion of the subroutine. The diagram shows the CALL RETURN structure
of subroutine.
24
MACROS
A sequence of instructions to which a name is assigned is called a macro. The name of the
macro is used in assembly language programming. The macro facility is available with many
assemblers.
Example 1
LXI H,ADDRESS
MOV A,M
CMA
ENDM
In above example COMPLE is the name of the macro. MACRO is written in the beginning of
the definition Here ADDRESS is the parameter. ENDM is used to end of the macro. Suppose
if we write COMPLE 2500H in an assembly language program , the assembler will replace this
macro by the following sequence of instructions in the program
25
LXI H,2500H
MOV A,M
CMA
Example 2
SHIFT MACRO
ADD A
ENDM
26