Microprocessor Notes
Microprocessor Notes
Microprocessor:
- Digital electronic component with transistors fabricated on a single semiconductor
integrated circuit (IC).
- One or more microprocessors typically serve as a central processing unit (CPU) in a
computer system or handheld device.
- Also controls the logic of almost all digital devices, from clock radios to fuel-
injection systems for automobiles.
Supercomputer:
- Fastest speed computer.
- Typically used for scientific and engineering applications that must handle very large
databases or do a great amount of computation.
- Most supercomputers are really multiple computers that perform parallel processing.
- In general, there are two parallel processing approaches: symmetric multiprocessing
(SMP) and massively parallel processing (MPP).
-
Microcontroller:
- A highly integrated chip that contains all the components comprising a controller.
- Typically includes a CPU, RAM, some form of ROM, I/O ports, and timers.
- Unlike a general-purpose computer, which also includes all of these components, a
microcontroller is designed for a very specific task - to control a particular system.
- A microcontroller differs from a microprocessor, which is a general-purpose chip that
is used to create a multi-function computer or device and requires multiple chips to
handle various tasks.
- A microcontroller is meant to be more self-contained and independent, and functions
as a tiny, dedicated computer.
- They are typically designed using CMOS (complementary metal oxide
semiconductor) technology, an efficient fabrication technique that uses less power
and is more immune to power spikes than other techniques.
- Microcontrollers are sometimes called embedded microcontrollers, which just means
that they are part of an embedded system that is, one part of a larger device or system.
Controller:
- A device that controls the transfer of data from a computer to a peripheral device and
vice versa.
- For example, disk drives, display screens, keyboards and printers all require
controllers.
- In personal computers, the controllers are often single chips.
- When we purchase a computer, it comes with all the necessary controllers for
standard components, such as the display screen, keyboard, and disk drives.
- If we attach additional devices, however, we may need to insert new controllers that
come on expansion boards.
- Controllers must be designed to communicate with the computer's expansion bus.
- There are three standard bus architectures for PCs - the AT bus, PCI (Peripheral
Component Interconnect ) and SCSI.
- When we purchase a controller, therefore, we must ensure that it conforms to the bus
architecture that computer uses.
Evolution of Microprocessors
We can categorize the microprocessor according to the generations or according to the size of the
microprocessor:
The first generation microprocessors were introduced in the year 1971-1972 by Intel
Corporation. It was named Intel 4004 since it was a 4-bit processor.
It was a processor on a single chip. It could perform simple arithmetic and logical operations
such as addition, subtraction, Boolean OR and Boolean AND.
It had a control unit capable of performing control functions like fetching an instruction from
storage memory, decoding it, and then generating control pulses to execute it.
The third generation microprocessors, introduced in 1978 were represented by Intel's 8086,
Zilog Z800 and 80286, which were 16 - bit processors with a performance like minicomputers.
Several different companies introduced the 32-bit microprocessors, but the most popular one is
the Intel 80386.
From 1995 to now we are in the fifth generation. After 80856, Intel came out with a new
processor namely Pentium processor followed by Pentium Pro CPU, which allows multiple
CPUs in a single system to achieve multiprocessing.
Other improved 64-bit processors are Celeron, Dual, Quad, Octa Core processors .
8085 Microprocessor
- It is 8 bit microprocessor.
- It is manufactured with N-MOS technology.
- It has 16-bit address bus and hence can address up to 216 = 65536 bytes (64KB)
memory locations through A0-A15.
- The first 8 lines of address bus and 8 lines of data bus are multiplexed AD0 – AD7.
- Data bus is a group of 8 lines D0 – D7.
- It supports external interrupt request.
- It has 16 bit program counter (PC)
- It has 16 bit stack pointer (SP)
- It has six 8-bit general purpose register arranged in pairs: BC, DE, HL.
- It requires a signal +5V power supply and operates at 3.2 MHZ single phase clock.
- It is enclosed with 40 pins DIP (Dual in line package).
Memory
- Program, data and stack memories occupy the same memory space. The total
addressable memory size is 64 KB.
- Program memory - program can be located anywhere in memory. Jump, branch and
call instructions use 16-bit addresses, i.e. they can be used to jump/branch anywhere
within 64 KB. All jump/branch instructions use absolute addressing.
- Data memory - the processor always uses 16-bit addresses so that data can be placed
anywhere.
- Stack memory is limited only by the size of memory. Stack grows downward.
- First 64 bytes in a zero memory page should be reserved for vectors used by RST
instructions.
Interrupts
- The processor has 5 interrupts. They are presented below in the order of their priority
(from lowest to highest):
- INTR is maskable 8080A compatible interrupt. When the interrupt occurs the
processor fetches from the bus one instruction, usually one of these instructions:
- One of the 8 RST instructions (RST0 - RST7). The processor saves current program
counter into stack and branches to memory location N * 8 (where N is a 3-bit number
from 0 to 7 supplied with the RST instruction).
- CALL instruction (3 byte instruction). The processor calls the subroutine, address of
which is specified in the second and third bytes of the instruction.
- RST5.5 is a maskable interrupt. When this interrupt is received the processor saves
the contents of the PC register into stack and branches to 2CH (hexadecimal) address.
- RST6.5 is a maskable interrupt. When this interrupt is received the processor saves
the contents of the PC register into stack and branches to 34H (hexadecimal) address.
- RST7.5 is a maskable interrupt. When this interrupt is received the processor saves
the contents of the PC register into stack and branches to 3CH (hexadecimal) address.
- TRAP is a non-maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 24H (hexadecimal)
address.
- All maskable interrupts can be enabled or disabled using EI and DI instructions. RST
5.5, RST6.5 and RST7.5 interrupts can be enabled or disabled individually using SIM
instruction.
Reset Signals
- RESET IN: When this signal goes low, the program counter (PC) is set to Zero, μp is
reset and resets the interrupt enable and HLDA flip-flops.
- The data and address buses and the control lines are 3-stated during RESET and
because of asynchronous nature of RESET, the processor internal registers and flags
may be altered by RESET with unpredictable results.
- RESET IN is a Schmitt-triggered input, allowing connection to an R-C network for
power-on RESET delay.
- Upon power-up, RESET IN must remain low for at least 10 ms after minimum Vcc
has been reached.
- For proper reset operation after the power – up duration, RESET IN should be kept
low a minimum of three clock periods.
- The CPU is held in the reset condition as long as RESET IN is applied. Typical
Power-on RESET RC values R1 = 75KΩ, C1 = 1μF.
- RESET OUT: This signal indicates that μp is being reset. This signal can be used to
reset other devices. The signal is synchronized to the processor clock and lasts an
integral number of clock periods.
DMA Signals
- HOLD: Indicates that another master is requesting the use of the address and data
buses. The CPU, upon receiving the hold request, will relinquish the use of the bus as
soon as the completion of the current bus transfer.
- Internal processing can continue. The processor can regain the bus only after the
HOLD is removed.
- When the HOLD is acknowledged, the Address, Data RD, WR and IO/M lines are 3-
stated.
- HLDA: Hold Acknowledge : Indicates that the CPU has received the HOLD request
and that it will relinquish the bus in the next clock cycle.
- HLDA goes low after the Hold request is removed. The CPU takes the bus one half-
clock cycle after HLDA goes low.
- READY: This signal Synchronizes the fast CPU and the slow memory, peripherals.
- If READY is high during a read or write cycle, it indicates that the memory or
peripheral is ready to send or receive data.
- If READY is low, the CPU will wait an integral number of clock cycle for READY
to go high before completing the read or write cycle.
- READY must conform to specified setup and hold times.
Registers
- Accumulator or A register is an 8-bit register used for arithmetic, logic, I/O and
load/store operations.
- Flag Register has five 1-bit flags.
o Sign - set if the most significant bit of the result is set.
o Zero - set if the result is zero.
o Auxiliary carry - set if there was a carry out from bit 3 to bit 4 of the result.
o Parity - set if the parity (the number of set bits in the result) is even.
o Carry - set if there was a carry during addition, or borrow during
subtraction/comparison/rotation.
Internal architecture of 8085:
ALU
- In addition to the arithmetic & logic circuits, the ALU includes the accumulator,
which is part of every arithmetic & logic operation.
- Also, the ALU includes a temporary register used for holding data temporarily during
the execution of the operation. This temporary register is not accessible by the
programmer.
Registers
General Purpose Registers
- B, C, D, E, H & L (8 bit registers)
- Can be used singly
- Or can be used as 16 bit register pairs BC, DE& HL
- HL used as a data pointer (holds memory address)
Accumulator
- Stores 8 bit data
- Store the result of an operation
- Store 8 bit data during I/O transfer Address
Flag Register
- 8 bit register – shows the status of the microprocessor before/after an operation. S
(sign flag), Z (zero flag), AC (auxiliary carry flag), P (parity flag) & CY (carry flag)
Sign Flag
- Used for indicating the sign of the data in the accumulator
- The sign flag is set if negative (1 – negative)
- The sign flag is reset if positive (0 –positive)
Zero Flag
- Is set if result obtained after an operation is 0
- Is set following an increment or decrement operation of that register
Carry Flag
- Is set if there is a carry or borrow from arithmetic operation
Parity Flag
- Is set if parity is even
- Is cleared if parity is odd
Program Counter
- This is a register that is used to control the sequencing of the execution of
instructions.
- This register always holds the address of the next instruction.
- Since it holds an address, it must be 16 bits wide.
Stack Pointer
- The stack pointer is also a 16-bit register that is used to point into memory.
- The memory this register points to is a special area called the stack. The stack is an
area of memory used to hold data that will be retrieved soon.
- The stack is usually accessed in a Last in First out (LIFO) fashion.
Demultiplexing AD7-AD0
- From the above description, it becomes obvious that the AD7– AD0 lines are serving
a dual purpose and that they need to be demultiplexed to get all the information.
- The high order bits of the address remain on the bus for three clock periods.
However, the low order bits remain for only one clock period and they would be lost
if they are not saved externally. Also, notice that the low order bits of the address
disappear when they are needed most.
- To make sure we have the entire address for the full three clock cycles, we will use an
external latch to save the value of AD7– AD0 when it is carrying the address bits. We
use the ALE signal to enable this latch.
Demultiplexing AD7-AD0 13
- Given that ALE operates as a pulse during T1, we will be able to latch the address.
Then when ALE goes low, the address is saved and the AD7– AD0 lines can be used
for their purpose as the bi-directional data lines.
Addressing Modes
The microprocessor has different ways of specifying the data for the instruction. These
are called addressing modes.
The 8085 has four addressing modes:
– Implied (Register) addressing, example CMA
– Immediate addressing, example MVI B, 45
– Direct addressing, example LDA 4000
– Indirect addressing, example LDAX B
Register Addressing
- This type of addressing mode specifies register or register pair that contains data.ie
(only the register need be specified as the address of the operands).
- Example MOV B, A (the content of A is copied into the register B)
Direct Addressing Mode
- Data is directly copied from the given address to the register.
- Example LDA 3000H (The content at the location 3000H is copied to the register A).
Register Indirect Addressing
- In this mode, the address of operand is specified by a register pair
- Example MOV A, M (Move data from memory location specified by H-L pair to
accumulator)
Immediate Addressing Mode
- In this mode, the operand is specified within the instruction itself.
- Example MVI A, 05 H (Move 05 H in accumulator.)
Implied Addressing Mode
- This mode doesn't require any operand. The data is specified by opcode itself.
- Example RAL, CMP
- The interfacing of the I/O devices in 8085 can be done in two ways :
- 1. Memory-Mapped I/O Interfacing :
In this kind of interfacing, we assign a memory address that can be used in the same
manner as we use a normal memory location.
- 2. I/O Mapped I/O Interfacing :
A kind of interfacing in which we assign an 8-bit address value to the input/output
devices which can be accessed using IN and OUT instruction is called I/O Mapped
I/O Interfacing.
-
- Basis for - Memory
- I/O mapped I/O
Comparison mapped I/O
Programmed I/O: It is due to the result of the I/O instructions that are written in the computer
program. Each data item transfer is initiated by an instruction in the program. Usually the
transfer is from a CPU register and memory. In this case it requires constant monitoring by the
CPU of the peripheral devices.
Interrupt- initiated I/O: Since in the above case we saw the CPU is kept busy unnecessarily.
This situation can very well be avoided by using an interrupt driven method for data transfer.
By using interrupt facility and special commands to inform the interface to issue an interrupt
request signal whenever data is available from any device. In the meantime the CPU can
proceed for any other program execution. The interface meanwhile keeps monitoring the
device. Whenever it is determined that the device is ready for data transfer it initiates an
interrupt request signal to the computer. Upon detection of an external interrupt signal the CPU
stops momentarily the task that it was already performing, branches to the service program to
process the I/O transfer, and then return to the task it was originally performing.
Direct Memory Access: The data transfer between a fast storage media such as magnetic disk
and memory unit is limited by the speed of the CPU. Thus we can allow the peripherals
directly communicate with each other using the memory buses, removing the intervention of
the CPU. This type of data transfer technique is known as DMA or direct memory access.
During DMA the CPU is idle and it has no control over the memory buses. The DMA
controller takes over the buses to manage the transfer directly between the I/O devices and the
memory unit.
Burst Transfer :
DMA returns the bus after complete data transfer. A register is used as a byte count,being
decremented for each byte transfer, and upon the byte count reaching zero, the DMAC will
release the bus. When the DMAC operates in burst mode, the CPU is halted for the duration of
the data
transfer.
Cyclic Stealing :
An alternative method in which DMA controller transfers one word at a time after which it
must return the control of the buses to the CPU. The CPU delays its operation only for one
memory cycle to allow the direct memory I/O transfer to “steal” one memory cycle.
Interleaved mode:
In this technique , the DMA controller takes over the system bus when the
microprocessor is not using it.An alternate half cycle i.e. half cycle DMA + half cycle
processor.
Interrupt controller:
When microprocessor receives any interrupt signal from peripheral(s) which are requesting its
services, it stops its current execution and program control is transferred to a sub-routine by
generating CALL signal and after executing sub-routine by generating RET signal again
program control is transferred to main program from where it had stopped.
When microprocessor receives interrupt signals, it sends an acknowledgement (INTA) to the
peripheral which is requesting for its service.
Interrupts can be classified into various categories based on different parameters:
Hardware and Software Interrupts –
When microprocessors receive interrupt signals through pins (hardware) of microprocessor,
they are known as Hardware Interrupts. There are 5 Hardware Interrupts in 8085
microprocessor. They are – INTR, RST 7.5, RST 6.5, RST 5.5, TRAP.
Software Interrupts are those which are inserted in between the program which means these are
mnemonics of microprocessor. There are 8 software interrupts in 8085 microprocessor. They
are – RST 0, RST 1, RST 2, RST 3, RST 4, RST 5, RST 6, RST 7.
Example programs:
//Write assembly language program (ALP) to calculate sum of two 8-bit numbers.
LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 2501H"
MOV A, M : "Get first operand in accumulator"
INX H : "Increment content of H-L pair. Now, H-L points 2502H"
ADD M : "Add first and second operand"
INX H : "H-L points 4002H"
MOV M, A : "Store result at 2503H"
HLT : "Stop"
//Write assembly language program (ALP) to calculate difference of two 8-bit numbers.
LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 2501H"
MOV A, M : "Get first operand in accumulator"
INX H : "Increment content of H-L pair. Now, H-L points 2502H"
SUB M : "Subtract first to second operand"
INX H : "H-L points 4002H"
MOV M, A : "Store result at 2503H"
HLT : "Stop"
//Write assembly language program (ALP) to calculate sum of two 16-bit numbers.
LHLD 2501H : "Get 1st 16-bit number in H-L pair"
XCHG : "Save 1st 16-bit number in DE"
LHLD 2503H : "Get 2nd 16-bit number in H-L pair"
MOV A, E : "Get lower byte of the 1st number"
ADD L : "Add lower byte of the 2nd number"
MOV L, A : "Store result in L-register"
MOV A, D : "Get higher byte of the 1st number"
ADC H : "Add higher byte of the 2nd number with CARRY"
MOV H, A : "Store result in H-register"
SHLD 4004H : "Store 16-bit result in memory locations 2505H and 2506H"
HLT : "Stop"
//Write assembly language program (ALP) to calculate difference of two 16-bit numbers.
LHLD 2500H : "Get first 16-bit number in HL"
XCHG : "Save first 16-bit number in DE"
LHLD 2502H : "Get second 16-bit number in HL"
MOV A, E : "Get lower byte of the first number"
SUB L : "Subtract lower byte of the second number"
MOV L, A : "Store the result in L register"
MOV A, D : "Get higher byte of the first number"
SBB H : "Subtract higher byte of second number with borrow"
MOV H, A : "Store l6-bit result in memory locations 2504H and 2505H"
SHLD 2504H : "Store l6-bit result in memory locations 2504H and 2505H"
HLT : "Terminate program execution"