8085 microprocessor programming | 8085 instruction set
The computer you are using to read this page uses a microprocessor to do its work. The microprocessor is the heart of any normal computer, whether it is a desktop machine, a server or a laptop.The microprocessor you are using might be a Pentium, a K6, a PowerPC, a Sparc or any of the many other brands and types of microprocessors, but they all do approximately the same thing in approximately.
This 8085 microprocessor tutorial covers following sub-topics:
8085 architecture8085 programminginstructions8085 vs 8086
8085 architecture8085 programminginstructions8085 vs 8086
This page of 8085 microprocessor tutorial describes 8085 microprocessor programming.It also mentions 8085 instruction set.It covers 8085 addressing modes viz. Immediate addressing,Register addressing,Direct addressing,Indirect addressing. Instructions of various types 1-byte,2-byte and 3-byte are explained.Example assembly programs are also mentioned.
Refer 8085 microprocessor internal architecture➤ before understanding 8085 programming mentioned on this page.
Control Unit: It generates signals within the microprocessor unit to carry out instruction which has been decoded. It takes care of data movement as required so that ALU operations can be performed.
ALU Unit: It takes care of numerical and logical operations such as ADD, Substract, AND, OR etc. It utilizes data stored in memory, registers and Accumulator to perform arithmetic operations. The final result is stored in the Accumulator.
Registers: There are 6 important general purpose registers to store 8 bit of data. These are named as B,C,D,E,H,L. These can be combined into BC, DE and HL to store 16 bits of data. The other important registers are Accumulator, PC (Program Counter), SP(Stack Pointer), one flag register. Assembly programmer can store the data in these registers using data copy instruction types.
ALU Unit: It takes care of numerical and logical operations such as ADD, Substract, AND, OR etc. It utilizes data stored in memory, registers and Accumulator to perform arithmetic operations. The final result is stored in the Accumulator.
Registers: There are 6 important general purpose registers to store 8 bit of data. These are named as B,C,D,E,H,L. These can be combined into BC, DE and HL to store 16 bits of data. The other important registers are Accumulator, PC (Program Counter), SP(Stack Pointer), one flag register. Assembly programmer can store the data in these registers using data copy instruction types.
Figure-1 depicts these registers. As mentioned Accumulator is a 8 bit register and it is used to store the data and perform mathematical operations and finally result is also stored in the accumulator. It is designated as 'A'.
ALU includes five flipflops dedicated to use as flags. These are set or reset based on certain conditions during mathematical operations. The flags are denoted as S (Sign), Z (Zero), AC(Auxiliary Carry), P(Parity) and CY (Carry) from MSB positions as shown in the figure.
EXAMPLE: After two numbers are added and if the sum is larger than 8 bits to be accomodated in the accumulator then it is indicated by setting the CY flag to value '1'. Like wise each of the flags have significance in 8085 processor.
EXAMPLE: After two numbers are added and if the sum is larger than 8 bits to be accomodated in the accumulator then it is indicated by setting the CY flag to value '1'. Like wise each of the flags have significance in 8085 processor.
8085 programming item | Description |
---|---|
Registers | These are 8 bit general purpose registers such as B,C,D,E,H,L as mentioned. |
Accumulator | It is a 8 bit register used to store the result as well as intermediate operations of the mathematical operation. |
Flags | These are five flags , set and reset according to certain arithmetic and logical conditions. |
Program Counter(PC) | It is 16 bit in size. The microprocessor uses this register to sequence the executions of the instructions. It is also used as memory pointer. It holds memory address from where next byte is to be fetched. It basically points to the assembly codes stored in the form of opcodes. When a byte is fetched , PC is incremented by 1 to point to the next memory location. |
Stack Pointer (SP) | It is 16 bit in size. It points to the memory location in R/W memory known as stack. The beginning of stack is defined by loading 16 bit address in the SP. |
8085 Addressing Modes
• Immediate Addressing: Load the immediate data to the destination. Data is specified in the instruction itself. EXAMPLE: MVI R, Data
• Register Addressing: Data is stored first in the registers and operations are performed by using registers in the instructions. EXAMPLE: MOV Rd, Rs
Here Rd is the destination register and Rs is the source register.
• Direct Addressing: It is used to accept the data from outside devices to store in the Accumulator. (EXAMPLE: IN 00H )
It is also used to send data stored in the Accumulator to the outside device. (EXAMPLE: OUT 01H)
• Indirect Addressing: Here effective address is calculated by the microprocessor. This type os addressing requires several accesses to retrieve the data which is to be loaded into the register.
• Register Addressing: Data is stored first in the registers and operations are performed by using registers in the instructions. EXAMPLE: MOV Rd, Rs
Here Rd is the destination register and Rs is the source register.
• Direct Addressing: It is used to accept the data from outside devices to store in the Accumulator. (EXAMPLE: IN 00H )
It is also used to send data stored in the Accumulator to the outside device. (EXAMPLE: OUT 01H)
• Indirect Addressing: Here effective address is calculated by the microprocessor. This type os addressing requires several accesses to retrieve the data which is to be loaded into the register.
Instruction Set Classification
Instruction is a binary pattern designated inside microprocessor to perform specific function. The entire group of instructions are known as 'Instruction Set'.
The 8085 instructions are classified into following categories:
• Data Transfer Operations i.e. copy: This type is used to copy data from one location(source) to the other location(destination). Following are the type of data transfer operations:
Between Registers, specific data byte to a register or a memory location, between a memory location and a register, between an I/O device and the accumulator.
• Arithmetic Operations: These instructions are used to perform addition, substraction, increment and decrement.
• Logical Operations: These instructions are used to perform logical operations with the contents of the accumulator. Typical instructions perform AND, EX-OR, Rotate, Compare, Complement etc.
• Branching Operations: These instructions are used to alter the sequence of program execution either conditionally or unconditionally. EXAMPLES: Jump, Call, Return etc.
• Machine Control Operations: These instructions are used to control machine functions e.g. Halt, Interrupt, Do nothing
• Data Transfer Operations i.e. copy: This type is used to copy data from one location(source) to the other location(destination). Following are the type of data transfer operations:
Between Registers, specific data byte to a register or a memory location, between a memory location and a register, between an I/O device and the accumulator.
• Arithmetic Operations: These instructions are used to perform addition, substraction, increment and decrement.
• Logical Operations: These instructions are used to perform logical operations with the contents of the accumulator. Typical instructions perform AND, EX-OR, Rotate, Compare, Complement etc.
• Branching Operations: These instructions are used to alter the sequence of program execution either conditionally or unconditionally. EXAMPLES: Jump, Call, Return etc.
• Machine Control Operations: These instructions are used to control machine functions e.g. Halt, Interrupt, Do nothing
8085 Instruction Format
8085 instructions are classified into following three groups of instructions:
• One-word or 1-byte instructions
• Two-word or 2-byte instructions
• Three-word or 3-byte instructions
• One-word or 1-byte instructions
• Two-word or 2-byte instructions
• Three-word or 3-byte instructions
Instruction: It is a command given to the microprocessor to perform given task on specified data.
Each instruction has two parts viz. task to be performed known as operation code or opcode and second is the data to be operated upon known as operand. The Operand can be used in many different ways e.g. 8 bit data or 16 bit data or internal register or memory location or 8 bit or 16 bit address.
Each instruction has two parts viz. task to be performed known as operation code or opcode and second is the data to be operated upon known as operand. The Operand can be used in many different ways e.g. 8 bit data or 16 bit data or internal register or memory location or 8 bit or 16 bit address.
One Byte Instructions | ||||
---|---|---|---|---|
Task | Opcode | Operand | Binary Code | Hex code |
Add the contents of register B to contents of accumulator | ADD | B | 1000 0000 | 80H |
Copy contents of accumulator in register C | MOV | C,A | 01001111 | 4FH |
Two Byte Instructions | ||||
---|---|---|---|---|
Task | Opcode | Operand | Binary Code | Hex code |
Load 8 bit data byte in the accumulator | MVI | A, data | 0011 1110, data | 3E, data |
If the data byte is stored in the 32H which need to be moved in the accumulator then the instruction can be written as follows: MVI A, 32H
Hex code is : 3E 32H
Hex code is : 3E 32H
Three Byte Instructions | ||||
---|---|---|---|---|
Task | Opcode | Operand | Binary Code | Hex code |
Transfer the program sequence to memory location 2085H. | JMP | 2085H | 11000011 10000101 00100000 | C3 85 20 |
Sample 8085 Assembly Programs
Example-1: Write assembly program to add two numbers.
MVI D, 8CH
MVI C, 6EH
MOV A, C
ADD D
OUT PORT1
HLT
MVI C, 6EH
MOV A, C
ADD D
OUT PORT1
HLT
Example-2: Write assembly program to multiply a number by 8
Multiply by 2 is equivalent to shifting.
Multiply by 2 is equivalent to shifting.
Example-3: Write assembly program to find greatest between the two numbers.
MVI B, 30H
MVI C, 40H
MOV A, B
CMP C
JZ EQU
JC GRT
OUT PORT1
HLT
EQU: MVI A, 01H
OUT PORT1
HLT
GRT: MOV A, C
OUT PORT1
HLT
MVI C, 40H
MOV A, B
CMP C
JZ EQU
JC GRT
OUT PORT1
HLT
EQU: MVI A, 01H
OUT PORT1
HLT
GRT: MOV A, C
OUT PORT1
HLT
8085 Microprocessor Related Links
8085 microprocessor architecture➤
8085 programming➤
8085 instruction set➤
Difference between 8085 and 8086➤
8085 programming➤
8085 instruction set➤
Difference between 8085 and 8086➤
RELATED LINKS
Microcontroller tutorial
What is microcontroller
8051 Microcontroller Architecture
Microcontroller hardware Interfacing
Microcontroller Timers
Microcontroller Interrupts
Microcontroller Serial Communication
What is microcontroller
8051 Microcontroller Architecture
Microcontroller hardware Interfacing
Microcontroller Timers
Microcontroller Interrupts
Microcontroller Serial Communication
Share this page
Translate this page
- Microprocessor Tutorial
- 8085 Microprocessor
- 8086 Microprocessor
- Multiprocessor Configuration
- I/O Interfacing
- Microcontrollers
- Peripheral Devices
- Microprocessor Useful Resources
- Selected Reading
Microprocessor is a controlling unit of a micro-computer, fabricated on a small chip capable of performing ALU (Arithmetic Logical Unit) operations and communicating with the other devices connected to it.
Microprocessor consists of an ALU, register array, and a control unit. ALU performs arithmetical and logical operations on the data received from the memory or an input device. Register array consists of registers identified by letters like B, C, D, E, H, L and accumulator. The control unit controls the flow of data and instructions within the computer.
Block Diagram of a Basic Microcomputer
How does a Microprocessor Work?
The microprocessor follows a sequence: Fetch, Decode, and then Execute.
Initially, the instructions are stored in the memory in a sequential order. The microprocessor fetches those instructions from the memory, then decodes it and executes those instructions till STOP instruction is reached. Later, it sends the result in binary to the output port. Between these processes, the register stores the temporarily data and ALU performs the computing functions.
List of Terms Used in a Microprocessor
Here is a list of some of the frequently used terms in a microprocessor −
- Instruction Set − It is the set of instructions that the microprocessor can understand.
- Bandwidth − It is the number of bits processed in a single instruction.
- Clock Speed − It determines the number of operations per second the processor can perform. It is expressed in megahertz (MHz) or gigahertz (GHz).It is also known as Clock Rate.
- Word Length − It depends upon the width of internal data bus, registers, ALU, etc. An 8-bit microprocessor can process 8-bit data at a time. The word length ranges from 4 bits to 64 bits depending upon the type of the microcomputer.
- Data Types − The microprocessor has multiple data type formats like binary, BCD, ASCII, signed and unsigned numbers.
Features of a Microprocessor
Here is a list of some of the most prominent features of any microprocessor −
- Cost-effective − The microprocessor chips are available at low prices and results its low cost.
- Size − The microprocessor is of small size chip, hence is portable.
- Low Power Consumption − Microprocessors are manufactured by using metaloxide semiconductor technology, which has low power consumption.
- Versatility − The microprocessors are versatile as we can use the same chip in a number of applications by configuring the software program.
- Reliability − The failure rate of an IC in microprocessors is very low, hence it is reliable.