Professional Documents
Culture Documents
Unit 2
Unit 2
2.1 INTRODUCTION
The microprocessor is in many ways similar to the CPU, but includes all the logic
circuitry, including the control unit, on one chip.
The microprocessor can be divided into three segments for the sake of clarity,
arithmetic/logic unit (ALU), register array, and control unit.
30
Register Array: This area of the microprocessor consists of various registers identified by letters
such as B, C, D, E, H, and L. These registers are primarily used to store data temporarily during
the execution of a program and are accessible to the user through instructions.
Control Unit: The control unit provides the necessary timing and control signals to all the
operations in the microcomputer. It controls the flow of data between the microprocessor and
memory and peripherals.
Memory: Memory stores such binary information as instructions and data, and provides that
information to the microprocessor whenever necessary. To execute programs, the microprocessor
reads instructions and data from memory and performs the computing operations in its ALU
section. Results are either transferred to the output section for display or stored in memory for
later use. Read-Only memory (ROM) and Read/Write memory (R/WM), popularly known as
Random-Access memory (RAM).
1. The ROM is used to store programs that do not need alterations. The monitor
program of a single-board microcomputer is generally stored in the ROM. This
program interprets the information entered through a keyboard and provides
equivalent binary digits to the microprocessor. Programs stored in the ROM can
only be read; they cannot be altered.
I/O (Input/Output): It communicates with the outside world. I/O includes two types of devices:
input and output; these I/O devices are also known as peripherals.
System Bus: The system bus is a communication path between the microprocessor and
peripherals: it is nothing but a group of wires to carry bits
Address Bus:
The address bus is a group of 16 lines generally identified as A0 to A15. The
address bus is unidirectional: bits flow in one direction —from the MPU to peripheral
devices. The MPU uses the address bus to perform the first function: identifying a
peripheral or a memory location.
Data Bus:
The data bus is a group of eight lines used for data flow. These lines are bidirectional
-data flow in both directions between the MPU and memory and peripheral devices. The
MPU uses the data bus to perform the second function: transferring binary
information .The eight data lines enable the MPU to manipulate 8-bit data ranging from
00 to FF (28 = 256 numbers). The largest number that can appear on the data bus is
11111111.
31
Fig 2.2 Architecture of 8085 Microprocessor
Control Bus:
The control bus is comprised of various single lines that carry synchronization
signals, providing timing signals. The MPU generates specific control signals for every
operation it performs. These signals are used to identify a device type with which the
MPU intends to communicate.
Registers:
The 8085 have six general-purpose registers to perform the first operation listed
above; that is, to store 8-bit data during program execution. These registers are identified
as B, C, D, E, H, and L. They can be combined as register pairs —BC, DE, and HL —to
perform some 16-bit operations.
Fig 2.2
32
Accumulator:
The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU).
This register is used to store 8-bit data and to perform arithmetic and logical
operations. The result of an operation is stored in the accumulator. The
accumulator is also identified as register A.
Flags:
The ALU includes five flip-flops that are set or reset according to the result of an
opera tion. The microprocessor uses them to perform the third operation; namely, testing
for data conditions. They are Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary
Carry (AC) flags. The most commonly used flags are Sign, Zero, and Carry; the others
will be explained as necessary.
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
(1) Sign Flag (S): After execution of any arithmetic and logical operation, if D7
of the result is 1, the sign flag is set. Otherwise it is reset. D 7 is reserved for
indicating the sign; the remaining is the magnitude of number. If D 7 is 1, the
number will be viewed as negative number. If D 7 is 0, the number will be
viewed as positive number.
(2) Zero Flag (z): If the result of arithmetic and logical operation is zero, then
zero flag is set otherwise it is reset.
(3) Auxiliary Carry Flag (AC): If D3 generates any carry when doing any
arithmetic and logical operation, this flag is set. Otherwise it is reset.
(4) Parity Flag (P): If the result of arithmetic and logical operation contains
even number of 1’ s then this flag will be set and if it is odd number of 1’ s it
will be reset.
(5) Carry Flag (CY): If any arithmetic and logical operation results any carry
then carry flag is set otherwise it is reset.
This 16-bit register deals with the fourth operation, sequencing the execution of
instructions. This register is a memory pointer.
The microprocessor uses this register to sequence the execution of instructions. The
function of the program counter is to point to the memory address from which the
next byte is to be fetched.
When a byte (machine code) is being fetched, the program counter is incremented by
one to point to the next memory location.
33
Stack Pointer (Sp):
The stack pointer is also a 16-bit register used as a memory pointer; initially, it
will be called the stack pointer register to emphasize that it is a register. It pointsto a
memory location in R/W memory, called the stack. The beginning of the stack is defined
by loading a 16-bit address in the stack pointer (register).
Temporary Register: It is used to hold the data during the arithmetic and logical
operations.
Instruction Register: When an instruction is fetched from the memory, it is loaded in
the instruction register.
Instruction Decoder: It gets the instruction from the instruction register and decodes the
instruction. It identifies the instruction to be performed.
Serial I/O Control: It has to control signals named SID and SOD for serial data
transmission.
Timing and Control unit: It has control and status signals. It provide control signal to
synchronize the components of microprocessor and timing for instruction to perform the
operation.
Interrupt Control Unit: It is used to receive an interrupt signal for process the operation
and send an acknowledgement for receiving the interrupt signal.
34
2.3.1 Introduction to 8085
36
2.5 INSTRUCTION SET OF 8085
The 8085 instruction set can be classified into the following five functional headings.
2. ARITHMETIC INSTRUCTIONS
Includes the instructions, which performs the addition, subtraction, increment or
decrement operations. The flag conditions are altered after execution of an instruction in this
group.
Examples:
ACI: Add Immediate to Accumulator with Carry.
Description: The 8-bit data (operand) and the Carry flag are added to the contents of the
accumulator, and the result is stored in the accumulator. All flags are modified to reflect the
result of the addition.
ADC: Add Register to Accumulator with Carry
Description: The contents of the operand (register or memory) and the Carry flag are added to
the contents of the accumulator and the result is placed in the accumulator. The contents of the
operand are not altered; however, the previous Carry flag is reset. All flags are modified to
reflect the result of the addition.
ADD: Add Register to Accumulator
Description: The contents of the operand (register or memory) are added to the contents of the
accumulator and the result is stored in the accumulator. If the operand is a memory location, that
is indicated by the 16-bit address in the HL register. All flags are modified to reflect the result of
the addition.
ADI: Add Immediate to Accumulator
Description: The 8-bit data (operand) are added to the contents of the accumulator, and the
result is placed in the accumulator. All flags are modified to reflect the result of the addition.
37
3. LOGICAL INSTRUCTIONS
The instructions which performs the logical operations like AND, OR, EXCLUSIVE-
OR, complement, compare and rotate instructions are grouped under this heading. The flag
conditions are altered after execution of an instruction in this group.
Examples:
4. BRANCHING INSTRUCTIONS:
The instructions that are used to transfer the program control from one memory location
to another memory location are grouped under this heading.
5. MACHINE CONTROL INSTRUCTIONS:
Includes the instructions related to interrupts and the instruction used to halt program
execution.
ANA: Logical AND with Accumulator
Description: The contents of the accumulator are logically AND ed with the contents of the
operand (register or memory), and the result is placed in the accumulator. If the operand is a
memory location, its address is specified by the contents of HL registers. Flags S, Z, P are
modified to reflect the result of the operation. CY is reset. In 8085 AC is set.
ANI: AND Immediate with Accumulator
Description: The contents of the accumulator are logically AND ed with the 8-bit data (operand)
and the results are placed in the accumulator. Flags S, Z, P are modified to reflect the results of
the operation. CY is reset. In 8085, AC is set.
CALL: Unconditional Subroutine Call
Description: The program sequence is transferred to the address specified by the operand.
Before the transfer, the address of the next instruction to CALL (the contents of the program
counter) is pushed on the stack.
CMA: Complement Accumulator
Description: The contents of the accumulator are complemented. No flags are affected.
CMC: Complement Carry.
Description: The carry flag is complemented.
CMP: Compare with Accumulator.
Description: The contents of the operand (register or memory) are compared with the contents
of the accumulator.
CPI: Compare Immediate with Accumulator
Description: The second byte (8-bit data) is compared with the contents of the accumulator.
INR: Increment Contents of Register/Memory by 1
Description: The contents of the designated register/memory are incremented by I and the
results are stored in the same place. If the operand is a memory location, it is specified by the
contents of HL register pair. Flags S. Z, P, AC are modified to reflect the result of the operation.
CY is not modified.
INX: Increment Register Pair by 1
Description: The contents of the specified register pair are incremented by 1. The instruction
views the contents of the two registers as a 16-bit number. No flags are affected.
JMP: Jump Unconditionally.
Description: The program sequence is transferred to the memory location specified by the 16-bit
address. This is a 3-byte instruction; the second byte specified the low order byte and the third
byte specifies the high-order byte. No flags are affected.
Jump Conditionally:
Description:
Jump on carry
Jump on No carry
Jump on Positive
38
Jump on minus
Jump on Parity Even
Jump on parity Odd
Jump on Zero
Jump on No Zero
LD: Load H and L Registers Direct
Description: The instruction copies the contents of the memory location pointed out by the 16-
bit address in register L and copies the contents of the next memory location in register H. The
contents of source memory locations are not altered. No flags are affected.
2.7 INTRODUCTION
The microcontroller incorporates all the features that are found in microprocessor. The
microcontroller has built in ROM, RAM, Input Output ports, Serial Port, timers,
interrupts and clock circuit. A microcontroller is an entire computer manufactured on a
single chip. Microcontrollers are usually dedicated devices embedded within an
application. For example, microcontrollers are used as engine controllers in automobiles
and as exposure and focus controllers in cameras.
40
Fig 2.5 Block diagram 8051
42
Part-A
1. Define microprocessors?
A semiconductor device (integrated circuit) manufactured by using the LSI technique. It includes
the ALU, register arrays, and control circuits on a single chip.
2. Define microcomputer?
A computer that is designed using a microprocessor as its CPU. It includes microprocessor,
memory and I/O.
3. Define ROM?
A memory that stores binary information permanently. The information can be read from this
memory but cannot be altered.
4. What is an ALU?
The group of circuit that provides timing and signals to all operation in the computer and
controls data flow.
6. What is an Assembler?
A computer program that translate an assembly language program from mnemonics to the binary
machine code of a computer.
43
13. What are the addressing modes available in 8051 microcontroller?
Register addressing
Direct addressing
Register-indirect addressing
Immediate addressing
Base register plus index register indirect addressing
44