Internal Architecture of 8085 Microprocessor: A. Control Unit
Internal Architecture of 8085 Microprocessor: A. Control Unit
microcontroller system, Architecture of MCS 51 /ATMEL /PIC controller, Pin diagram of 8051,
Addressing modes, Instruction types and set, Selection and Applications of Microcontroller
a. Control Unit
Generates signals within Microprocessor to carry out the instruction, which has been decoded. In reality
causes certain connections between blocks of the Microprocessor to be opened or closed, so that data goes
where it is required, and so that ALU operations occur.
b. Arithmetic Logic Unit
The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’, ‘AND’, ‘OR’, etc.
Uses data from memory and from Accumulator to perform arithmetic. Always stores result of operation
in Accumulator.
c. Registers
The 8085/8080A-programming model includes six registers, one accumulator, and one flag
register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and the
program counter. They are described briefly as follows.
The 8085/8080A has six general-purpose registers to store 8-bit data; these are identified as
B, C, D, E, H, and L as shown in the figure. They can be combined as register pairs - BC, DE,
and HL - to perform some 16-bit operations. The programmer can use these registers to store or
copy data into the registers by using data copy instructions.
i. Accumulator
The accumulator is an 8-bit register that is a part of 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.
ii. Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero(Z), Carry
(CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; they are listed in the Table and their
bit positions in the flag register are shown in the Figure below.
The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to
test data conditions..
Carry (CY) :- after an addition of two numbers, if the sum in the accumulator id larger
than eight bits, the flip-flop uses to indicate a carry -- called the Carry flag (CY) – is set
to one.
Zero flag (Z) :-When an arithmetic operation results in zero, the flip-flop called the
Zero(Z) flag is set to one.
Flag register:- The first Figure shows an 8-bit register, called the flag register, adjacent
to the accumulator. However, it is not used as a register; five bit positions out of eight are
used to store the outputs of the five flip-flops. The flags are stored in the 8-bit register so
that the programmer can examine these flags (data conditions) by accessing the register
through an instruction. These flags have critical importance in the decision-making
process of the microprocessor. The conditions (set or reset) of the flags are tested through
the software instructions.
For example, the instruction JC (Jump on Carry) is implemented to change the sequence of a
program when CY flag is set. The thorough understanding of flag is essential in writing assembly
language programs.
d. Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit
register. The microprocessor uses this register to sequence the execution of the 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.
e. Stack Pointer (SP)
The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory
Location in R/W memory, called the stack. The beginning of the stack is defined by loading 16-
bit address in the stack pointer. The stack concept is explained in the chapter "Stack and
Subroutines.
f. Instruction Register/Decoder
Temporary store for the current instruction of a program. Latest instruction sent here from
memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction then passed to next stage.
g. Memory Address Register
Holds address, received from PC, of next program instruction. Feeds the address bus with
addresses of location of the program under execution.
h. Control Generator
Generates signals within uP to carry out the instruction which has been decoded. In reality causes
certain connections between blocks of the uP to be opened or closed, so that data goes where it is
required, and so that ALU operations occur.
i. Register Selector
This block controls the use of the register stack in the example. Just a logic circuit which
Switches between different registers in the set will receive instructions from Control Unit.
j. General Purpose Registers
uP requires extra registers for versatility. Can be used to store additional data during a program.
More complex processors may have a variety of differently named registers.
c. Logical Operations
These instructions perform various logical operations with the contents of the accumulator.
AND, OR Exclusive-OR - Any 8-bit number, or the contents of a register, or of
a memory location can be logically AND, Or, or Exclusive-OR with the contents of the
accumulator. The results are stored in the accumulator.
Rotate- Each bit in the accumulator can be shifted either left or right to the next position.
Compare- Any 8-bit number, or the contents of a register, or a memory location can be
Compared for equality, greater than, or less than, with the contents of the accumulator.
Complement - The contents of the accumulator can be complemented. All 0s are
replaced by 1s and all 1s are replaced by 0s.
d. Branching Operations
This group of instructions alters the sequence of program execution either conditionally or
unconditionally.
Jump - Conditional jumps are an important aspect of the decision-making process in the
programming. These instructions test for a certain conditions (e.g., Zero or Carry flag)
and alter the program sequence when the condition is met. In addition, the instruction set
includes an instruction called unconditional jump.
Call, Return, and Restart - These instructions change the sequence of a program either
by calling a subroutine or returning from a subroutine. The conditional Call and Return
instructions also can test condition flags.
e. Machine Control Operations
These instructions control machine functions such as Halt, Interrupt, or do nothing. The
microprocessor operations related to data manipulation can be summarized in four functions:
i. Copying data
ii. Performing arithmetic operations
iii. Performing logical operations
iv. Testing for a given condition and alerting the program sequence
Some important aspects of the instruction set are noted below:
i. In data transfer, the contents of the source are not destroyed; only the contents of the
destination are changed. The data copy instructions do not affect the flags.
ii. Arithmetic and Logical operations are performed with the contents of the accumulator, and the
results are stored in the accumulator (with some expectations). The flags are affected according
to the results.
iii. Any register including the memory can be used for increment and decrement.
iv. A program sequence can be changed either conditionally or by testing for a given data
condition.
5. Instruction Format
An instruction is a command to the microprocessor to perform a given task on a specified data.
Each instruction has two parts: one is task to be performed, called the operation code (op-code),
and the second is the data to be operated on, called the operand. The operand (or data) can be
specified in various ways. It may include 8-bit (or 16-bit ) data, an internal register, a memory
location, or 8-bit (or 16-bit) address. In some instructions, the operand is implicit.
Instruction word size The 8085 instruction set is classified into the following three groups
according to word size:
One-word or 1-byte instructions
Two-word or 2-byte instructions
Three-word or 3-byte instructions
In the 8085, "byte" and "word" are synonymous because it is an 8-bit microprocessor. However,
instructions are commonly referred to in terms of bytes rather than words.
One-Byte Instructions
A 1-byte instruction includes the op-code and operand in the same byte. Operand(s)
are internal register and are coded into the instruction.
For example:
Task Op code Operand
Copy the contents of the MOV C,A
accumulator in the register C.
Add the contents of register B ADD B
to the contents of the
accumulator
Invert (compliment) each bit CMA
in the accumulator.
These instructions are 1-byte instructions performing three different tasks. In the first
instruction, both operand registers are specified. In the second instruction, the operand . B is
specified and the accumulator is assumed. Similarly, in the third instruction, the accumulator is
assumed to be the implicit operand. These instructions are stored in 8-bit binary format in
memory; each requires one memory location.
MOV rd, rs
rd <-- rs copies contents of rs into rd.
Example: MOV A,B
Two-Byte Instructions
In a two-byte instruction, the first byte specifies the operation code and the second byte
specifies the operand. Source operand is a data byte immediately following the opcode.
For example:
Task Op code Operand
Load an 8-bit data byte in the MVI MVI
accumulator.
MVI r,data
r <-- data
Example: MVI A, 30H
Three-Byte Instructions
In a three-byte instruction, the first byte specifies the opcode , and the following two bytes
specify the 16-bit address. Note that the second byte is the low-order address and the third byte is
the high-order address. Opcode + data byte + data byte
For example
Task Op code Operand
Transfer the program JMP 2085H
sequence to
the memory
location
2085H.
This instruction would require three memory locations to store in memory.
Three byte instructions - opcode + data byte + data byte
LXI rp, data16
rp is one of the pairs of registers BC, DE, HL used as 16-bit registers. The two data
bytes are 16-bit data in L H order of significance.
rp <-- data16
Example:
LXI H,0520H coded as 21H 20H 50H in three bytes. This is also immediate addressing
Oscillator:
Microcontroller 8051 consists of an on-chip oscillator which toils as a time source for CPU
(Central Processing Unit). As the productivity thumps of oscillator are steady as a result, it
facilitates harmonized employment of all pieces of 8051 Microcontroller.
Input/output Port:
Micro-controller 8051 consists of 4 input/output ports to unite it to other peripherals.
Timers/Counters:
Micro-controller 8051 is incorporated with two 16 bit counters & timers. The counters are
separated into 8 bit registers. The timers are utilized for measuring the intervals, to find out pulse
width etc.
Special Function Registers (SFRs)
Special Function Registers (SFRs) are a sort of control table used for running and monitoring the
operation of the microcontroller. Each of these registers as well as each bit they include, has its
name, address in the scope of RAM and precisely defined purpose such as timer control,
interrupt control, serial communication control etc. Even though there are 128 memory locations
intended to be occupied by them, the basic core, shared by all types of 8051 microcontrollers,
has only 21 such registers. Rest of locations is intentionally left unoccupied in order to enable the
manufacturers to further develop microcontrollers keeping them compatible with the previous
versions.
A Register (Accumulator)
A register is a general-purpose register used for storing intermediate results obtained during
operation. Prior to executing an instruction upon any number or operand it is necessary to store it
in the accumulator first. All results obtained from arithmtical operations performed by the ALU
are stored in the accumulator. Data to be moved from one register to another must go through the
accumulator. In other words, the A register is the most commonly used register and it is
impossible to imagine a microcontroller without it. More than half instructions used by the 8051
microcontroller use somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in the A and B registers.
All other instructions in the program can use this register as a spare accumulator (A).
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even though they are
not true SFRs, they deserve to be discussed here because of their purpose. They occupy 4 banks
within RAM. Similar to the accumulator, they are used for temporary storing variables and
intermediate results during operation. Which one of these banks is to be active depends on two
bits of the PSW Register. Active bank is a bank the registers of which are currently used.
Program Status Word (PSW) Register
PSW register is one of the most important SFRs. It contains several status bits that reflect the
current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register
bank select bits, Overflow flag, parity bit and user-definable status flag.
i. P - Parity bit. If a number stored in the accumulator is even then this bit will be automatically
set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via
serial communication.
- Bit 1. This bit is intended to be used in the future versions of microcontrollers. OV Overflow
occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one
register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0).
RS0, RS1 - Register bank select bits. These two bits are used to select one of four register banks
of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of
RAM.
ii. F0 - Flag 0. This is a general-purpose bit available for use.
iii. AC - Auxiliary Carry Flag is used for BCD operations only.
iv. CY - Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and shift
instructions.
Selection of Microcontroller
There are many factors to consider.
Power efficiency:-There is a trade-off between processing performance and power
onsumption: a device with higher processing power will consume more energy.
Therefore, if your microcontroller is wireless and running on a rechargeable battery, you
need to weigh sacrificing power efficiency against getting more processing power, or
vice versa.
Temperature tolerance:-Depending on the environment in which your microcontrollers
operate, you may want devices that withstand extreme temperature. There will be a trade-
off between temperature tolerance and cost.
Security.:- Hacking which targets IoT devices is rising, a threat that is especially relevant
to microcontrollers used in automobiles. In response, microcontroller makers are
implementing layers of security such as cryptography and physical security. Now, users
can purchase microcontrollers that have been certified to the latest security standards or
use MCUs with on-chip secure hardware.
Hardware architecture.:- A microcontroller’s packaging directly influences its size and
performance. Dual in-line packaging is the most common type. Small-outline transistors
have a small footprint, and quad flat packs take up more areas but less vertical space.
Wafer level chip-scales are much smaller and pack in more processing power but are
more expensive to manufacture. Flat no-lead packages are better in heat diffusion. Ball
grid arrays (BGAs) have high performance due to the compact package but also cost
more to fabricate.
Processing power:- How much processing power do you require for the task, will a
single core processor suffice, or do you need a dual-core? A multi-core processor will be
significantly faster, but it will also consume more energy. Also, will a graphics
processing unit (GPU) be necessary?
Memory:- The amount of memory (RAM and ROM) you need will depend on the
programs you will be running. More programs need more random access memory
(RAM). In addition, a GPU will require not only more RAM but faster read/write time as
well.
Hardware interface:- The nature of the task will dictate the need for hardware interfaces
such as USB, Wi-Fi, Bluetooth, audio, video, or camera.
Software architecture: Some microcontrollers are operable on multiple OSs, and others
are not. If you need to scale, it is better to use the same software architecture to increase
interoperability.
Cost:- Microcontrollers fall within a wide price range, from a hundred units for a few
dollars to a few dollars per unit. If you want to scale, you need to consider the overall
cost versus the individual performance power of a microcontroller.
Application of Microcontroller
1. Write a program to add the values of locations 50H and 51H and store the result in
locations in 52h and 53H.
2. Write a program to multiply two 8 bit numbers stored at locations 70H and 71H and
store the result at memory locations 52H and 53H. Assume that the least significant byte of
the result is stored in low address.
ORG 0000H ; Set program counter 00 OH
MOV A, 70H ; Load the contents of memory location 70h into A
MOV B, 71H ; Load the contents of memory location 71H into B
MUL AB ; Perform multiplication
MOV 52H,A ; Save the least significant byte of the result in location 52H MOV 53H,B ; Save
the most significant byte of the result in location 53
END