Microprocessor Ppt1
Microprocessor Ppt1
MICROCONTROLLER
INTRODUCTION TO MICROPROCESSOR AND
MICROCOMPUTER ARCHITECTURE:
The central processing unit or CPU - it is here that all decisions are made
and the timing generated
The memory unit - is used to store the specific sequence of commands
that will be used to instruct the CPU to perform some task. This instructions
are called the computer program. Each cell in the memory has its own
unique identifying number or address. These numbers represents the
operations codes (op codes) for the various instruction in the CPUs
instruction set.
Finally, no useful task can be performed by the computer without the
input/output devices.
Fetch and Execute
1. Fetch data from the memory cell whose address is currently in the
program counter register. Put this data into the instruction register.
2. Add 1 to the address in the program counter.
3. Decode the command currently in the instruction register and do what it
tells you.
4. Go to step 1.
The Three-Bus Architecture
Address Bus: It carries the address, which is a unique binary pattern used to
identify a memory location or an I/O port. For example, an eight bit
address bus has eight lines and thus it can address 2^8 = 256 different
locations. The locations in hexadecimal format can be written as 00H
FFH.
Data Bus: The data bus is used to transfer data between memory and
processor or between I/O device and processor. For example, an 8-bit
processor will generally have an 8-bit data bus and a 16-bit processor will
have 16-bit data bus.
Control Bus: The control bus carry control signals, which consists of signals
for selection of memory or I/O device from the given address, direction of
data transfer and synchronization of data transfer in case of slow devices.
Memory Mapped I/O
Memory maps are useful to show how much of the memory space of the
microprocessor is actually implemented and if any I/O devices are
mapped into this area.
Capacity:
1 k = 2^10 = 1024 bytes
1 M = (2^10)(2^10) = 1024 KB
1 G = 1024 MB
Memory Mapped
Peripherals: 8 KB
1. Identify the address of each chip.
2. What is the total size of the
memory.
SRAM: 32 KB
EPROM: 24 KB
Memory Mapped
Example: Draw the memory map for a microcomputer with 16K of read/write
memory beginning at address 0000, 28K of read-only memory beginning at
address 5000H, and 16K of memory-mapped I/O beginning at C000H. Label
all unused memory space as open.
Based on architecture:
11011011 DB
00000000 00
01000111 47
11011011 DB
00000000 00
10000000 80
11010011 D3
00000000 00
01110110 76
Add Mnemonics
Binary Hex Mnemonics Comment
11011011 DB IN ;INPUT THE FIRST NUMBER
00000000 00 0 ;FROM PORT 0 AND SAVE IN REGISTER
A.
01000111 47 MOV B,A ;PUT A COPY OF REGISTER A IN
REGISTER B.
11011011 DB IN ;INPUT THE SECOND NUMBER
00000000 00 0 ;FROM PORT 0 AND SAVE IN REGISTER
A.
10000000 80 ADD B ;ADD REGISTERS A AND B, LEAVE THE
SUM IN REGISTER A.
11010011 D3 OUT ;OUTPUT REGISTER A
00000000 00 0 ;TO PORT 0.
01110110 76 HLT HALT.
Terms
The ALU performs the actual numerical and logical operations such as
Addition (ADD), Subtraction (SUB), AND, OR etc. It uses data from memory
and from Accumulator to perform operations. The results of the arithmetic
and logical operations are stored in the accumulator.
Registers
The 8085 includes six registers, one accumulator and one flag register. In
addition, it has two 16-bit registers: stack pointer and program counter.
The 8085 has six general-purpose registers to store 8-bit data; these 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. The programmer can use
these registers to store or copy data into the register by using data copy
instructions.
Register Organization
Accumulator
The accumulator is an 8-bit register that is a part of 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.
Flag register
The ALU includes five flip-flops, which are set or reset after an operation
according to data condition 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. Their bit positions in the flag register are shown in
Fig. 4. The microprocessor uses these flags to test data conditions.
If the result in the accumulator is larger than 8-bit, the flip-flop uses to indicate
a carry or borrow out of the high-order bit CY flag is set to 1.
When an arithmetic operation results in zero, Z flag is set to 1.
The S flag is just a copy of the bit D7 of the accumulator. If the most significant
bit of the result of the operation has the value 1, this flag is set; otherwise it is
reset.
A negative number has a 1 in bit D7 and a positive number has a 0 in 2s
complement representation.
The AC flag is set to 1, when a carry result from bit D3 and passes to bit D4.
The P flag is set to 1, when the result in accumulator contains even number of
1s.
Example #1
If register B = 03H and register A = 03H, what is the state of the flags after
the command SUB B is given?
Example #2
If register B = 80H and register A = 03H, what is the state of the flags after
the command ADD B is given?
Determine the condition of the flag
register.
#2. If register B = 80H and register A = 03H, what is the state of the flags
after the command ADD B is given?
#3. If register B = 01H and register A = FFH, what is the state of the flags
after the command ADD B is given?
Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This
register is a memory pointer. 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 is being fetched, the program counter is automatically incremented
by one to point to the next memory location.
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 stack. The beginning of
the stack is defined by loading 16bit address in the stack pointer.
Instruction Register/Decoder
It is an 8-bit register that temporarily stores 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.
Control Unit
Generates signals on data bus, address bus and control bus within
microprocessor to carry out the instruction, which has been decoded. Typical
buses and their timing are described as follows: