Professional Documents
Culture Documents
Instruction Set and Programs For Intel 8085
Instruction Set and Programs For Intel 8085
Addressing Modes:
• Each instruction requires certain data on which it has to operate
• There are various techniques to specify data for instructions
• These techniques are called addressing modes
• The way of specifying data to be operated by an instruction is known as addressing modes
• Intel 8085 uses the following addressing modes:
• Direct addressing
• Register addressing
• Register Indirect addressing
• Immediate addressing
• Implicit addressing
Direct Addressing:
• In this mode of addressing the address of the operand (data) is given in the instruction itself
• Example are:
• STA 2500H: Store the content of the accumulator in the memory location 2500H
• 32, 00, 25: The instruction is in coded form
• LDA 26FFH: Load the content of the memory location 26FFH to the accumulator
• 3A, FF, 26: The instruction is in coded form
• IN 02: Read data from Port C
• DB, 02: The instruction is in coded form
Register Addressing:
• In this mode of addressing the operand is in one of the general purpose registers
• The opcode specifies the address of the register(s) in addition to the operation to be performed
• Example are:
• MOV A, B: Move the content of register B to register A
• 78: The instruction is in coded form
• ADD B: Add the content of register B to the content of register A [A] ← [A] + [B]
• 80: The instruction is in coded form
• SUB C: Subtract the content of register C from the content of register A [A] ← [A] – [C]
• 91: The instruction is in coded form
Register Indirect Addressing:
• In this mode of addressing the address of the operand is specified by a register pair
• Example are:
• MOV A, M: Move the content of the memory location, whose address is in H-L pair to the
accumulator
• 7E: The instruction is in coded form
• ADD M: Add the content of the memory location, whose address is in H-L pair, to the
content of the accumulator
• 86: The instruction is in coded form
• SUB M: Subtract the content of the memory location, whose address is in H-L pair, from the
content of the accumulator
• 96: The instruction is in coded form
Immediate Addressing:
• In this mode of addressing the operand (data) is specified within the instruction itself
• Example are:
• MVI A, 05: Move 05 in register A
• 3E, 05: The instruction is in coded form
• ADI 06: Add 06 to the content of the accumulator
• C6, 06: The instruction is in coded form
• LXI H, 2500: 2500 is 16-bit data which is given in the instruction itself to be loaded into H-L
pair
• 21, 00, 25: The instruction is in coded form
• SUI 06: Subtract 06 from the content of the accumulator
• D6, 06: The instruction is in coded form
Implicit Addressing:
• There are certain instructions which operate on the content of the accumulator
• Such instruction do not require the address of the operand
• Also, known as implied or inherent addressing mode
• Example are:
• CMA: complement the accumulator content
• he instruction is in co e form [A] ← [A]
• RAL: Rotate accumulator left through carry
• 17: opcode [An+1] ← [An], [CS] ← [A7], [A0] ← [CS]
• RAR: Rotate accumulator right through carry
• 1F: The instruction is in coded form
[An] ← [An+1], [CS] ← [A0], [A7] ← [CS]
Instruction set of Intel 8085:
• These instructions have been classified into the following five groups
• Arithmetic Group
• Logical Group
Arithmetic Group:
• DAA is use in the program after a ition instructions i.e. ADD, ADI, ADC etc…
• Result is placed in accumulator in hexadecimal
• The DAA instruction operates on result and gives the final result in decimal system
• It uses [CS] and [AC] for decimal adjustment
• 6 is added to 4 LSBs, if value lies A – F or [AC] = 1
• 6 is added to 4 MSBs, if value lies A – F or [CS] = 1
Example of DAA
• ADD 96D and 69D
Case 2:
Case 1:
84D = 1000 0100
96D = 1001 0110 92D = 1001 0010
69D = 0110 1001 16H = 0001 0110 and [CS ]= 1
FFH = 1111 1111 DAA + 0110
DAA + 0110 0110 = 0111 0110 = 01, 76D
= 0110 0101 = 01, 65D
Case 3:
Diagram of RLC:
RRC : Rotate Accumulator Right:
[A7] ← [A0],
[CS] ← [A0] ,
[An]←[An + 1]
Diagram of RRC:
Diagram of RAR:
The restart instruction as follows: RST 0, RST 1, RST 2, RST 3, RTS 4, RTS5, RST6 and RST 7
PCHL: The content of H-L pair are transferred to program counter
• A computer uses binary digits for its operation and understands information composed of only
0s and 1s
• Hence, the instructions are coded and stored in the memory in the form of zeros and ones
• A program written in the form of 0s and 1s is called a machine language program
• In the machine language there is a specific binary code for each instruction
• For example, in Intel 8085 to add the contents of register A and register B, the binary code is
10000000
• To move the content of register B to register A the binary code is 01111000
• The program can easily be written in hexadecimal system compared to binary system
Input:
2501 15
2502 20
2503 35 (Output)
Assembly Language:
• Meaningful and easily rememberable symbols are chosen for the purpose
• Examples are: ADD for addition, SUB for subtraction, CMP for comparison etc…, such
symbols called mnemonics
• The writing of a program in assembly language is much easier and faster as compared to
machine language
• A program which translates an assembly language program into a machine language is called
an assembler
• Mnemonics, operands, data of the program and starting address of for the program are fed to
computer
• The assembler converts the program into a machine language program before the execution of
the program
Mnemonics Operands
LXI H, 2501H
MOV A, M
INX H
ADD M
STA 2503H
HLT
Input:
2501 49H
2502 56H
9FH (Output)
Benefits:
• The programmer writes a program in mnemonics is easier to understand and faster to write
• An assembly language program is faster to produce result
Demerits:
• Programming is difficult and time consuming
• The assembly language is computer oriented
• Assembly language program is not portable
• Assembly language program is longer as compared to high level language
• Instructions written in high-level languages are called statements rather than mnemonics
• In a HLL, statements more clearly resemble English and mathematics than mnemonics
• Examples of HLLs are OR RAN, COBOL, BASIC, PASCAL, C, C++, JAVA, etc….
STACK:
• During the execution of a program, it becomes necessary to save the contents of certain
registers
• Contents are named to certain memory locations by PUSH operation, registers used for other
operation
• Contents which were saved in memory are transferred back to registers by POP operation
• Memory locations for this purpose is set by the programmer in 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
• The stack pointer is initialized in the beginning of the program by LXI SP or SPHL
instruction
• Any area of RAM can be used as stack, data are stored in LIFO principle (last-in-first-out)
• Stack access is faster than memory access, the SP register holds the stack-top location
• While writing a program certain operations may occur several times and
• they are not available as individual instructions
• The program for such operation are repeated again and again in the main program
• Example of such operation is multiplication, sine, cosine, logarithm, etc. for Intel 8085
• The concept of subroutine 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 the memory
• They are called at various points of the main program by CALL instruction where they are
required
• The last instruction of the subroutine is RET
• After the completion of a subroutine, the main program begins from the instruction
• immediately following the CALL instruction
• There may be more than one subroutine in a program
• The technique of subroutine saves memory location
MONITOR:
• A monitor is a program which resides in a ROM of PROM, carries out the following
functions:
• Initialization of the system
• Loading of programs into RAM
• Control of input & output devices
• Displaying of the contents of the internal CPU registers or memory location
• Modifying the contents of CPU registers or memory location
• Execution of the program which is in RAM or ROM
Monitor Program:
Ex3: Load the content of memory location 3550H directly to accumulator, then transfer to
register B. The content of memory location 3550H is 05
Ex4: Move the content of memory location 3550H to register C. The content of the memory
location 3550H is 08
DATA:
FC50 – 11H
FC51 – 12H
Ex6: Place 05 in the accumulator. Increment it by one and store the result in the memory
location 3600H
RESULT:
3600 H – 06 H
2503 – 9F H
By Method#2
Method#2
Add 84 D and 75 D.
DATA
2501 – 49 H
2502 – 32 H
Result
2503 – 17 H
2504 – 00 H
Method#2
DATA
2501 – 32 H
2502 – 49 H
Result
2503 – F9 H
2504 – 01 H
Subtract 38 D from 96 D. 96 – 38
st
The 1 number 96 D is in the memory location 2501 H.
The 2nd number 32 D is in the memory location 2502 H.
The result to be stored in the memory location 2503 H.
In ecimal subtraction, the number which is to be subtracte is converte into 10’s complement
DATA
2501 – 96 D
2502 – 38 D
Result
2503 – 58 D
Find One’s complement of an 8-bit number
96 H = 1001 0110
One’s complement = 0110 1001 = (69 H)
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502 H
DATA
2501 – 96 H
Result
2502 – 69 H
96 H = 1001 0110
One’s complement = 0110 1001 = (69 H)
A 01 in 1’s complement, after a ition = 6A H
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502 H
Number = A6 H
= 1010 0110
Mask-off Least Significant 4-bits
Result = 1010 0000 = A0 H
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502 H
Number = A6 H
= 1010 0110
Mask-off Most Significant 4-bits
Result = 0000 0110 = 06 H
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502 H
Number = 65 H
= 0110 0101
Shift one bit left = 1100 1010 = CA H (Result)
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502
0110 0101
0110 0101
1100 1010
Number = 65 H
= 0110 0101
Shift one bit left = 1100 1010 (1-bit left shift) = CA H
Shift again by one bit = 1001 0100 = 94 H
The number is placed in the memory location 2501 H
The result is stored in the memory location 2502 H
0110 0101
0110 0101
1100 1010
1100 1010
1001 0100
DATA
2501 – 65 H
Result
2502 – 94 H
Assignment-II
1. Discuss various types of addressing modes of Intel 8085 with suitable examples. Give atleast
five examples for each
2. Classify 8085 instructions in various groups. Give atleast five examples of instructions for
each group
3. Write the advantages and disadvantages of machine language over assembly language
4. Write the roles of stacks, subroutines and monitor program in an assembly language program
(i) ADC M, (ii) SUI data, (iii) XRA r, (iv) PUSH PSW, (v) LDAX D, (vi) POP B,
(vii) CPO addr(label), (viii) JNZ addr(label), (ix) RET (x) RAR
Program Assignment-II
1. Write an assembly language program for Intel 8085 to add two 16-bit numbers available at
memory locations 3401H, 3402H and 3403H, 3404H and store the result at memory location
3405H onward.
2. Write an assembly language program for Intel 8085 to subtract a 16-bit number stored at
memory locations 3501H & 3502H from a 16-bit number stored at memory location 3503H &
3504H and store the result at 3505H onward
3. Write an assembly language program to fin the ’s complement of an 8-bit number stored at
memory location 3600H and stores the complemented result at memory location 360AH.
4. Write an assembly language program for 8085 µp to subtract an 8-bit decimal number stored
at memory location 3500H from an 8-bit decimal number stored at memory location 3501H.
The program shall store the result and carry at memory locations 3502H onward
5. Write an assembly language program to fin the ’s complement of a 16-bit number stored at
memory locations 3601H & 3602H and stores the result at memory location 3603H & 3604H