unit-1 - notes

advertisement
UNIT I
8085
General Architecture of a Microcomputer System The hardware of a microcomputer system
can be divided into four functional sections: the Input unit,MicroprocessingUnit, Memory Unit,
and Output Unit.
MicroProcessorUnit (MPU) is the heart of a microcomputer.
 A microprocessor is a general purpose processing unit built into a single integrated circuit
(IC).
 The Microprocessor is the part of the microcomputer that executes instructions of the
program and processes data
 It is responsible for performing all arithmetic operations and making the logical decisions
initiated by the computer’s program.
 A microprocessor is abbreviated μP)
 One or more microprocessors typically serve as a central processing unit (CPU) in a
computer system or handheld device.
Input and Output units are the means by which the MPU communicates with the outside world
Input unit: keyboard, mouse, scanner, etc.
Output unit: monitor, printer, etc.
Memory unit:
Primary: is normally smaller in size and is used for temporary storage of active
information. Typically ROM, RAM.
Secondary: is normally larger in size and used for long-term storage of information. Like
Hard disk, Floppy, CD, etc.
Types of Microprocessors Microprocessors generally is categorized in terms of the maximum
number of binary bits in the data they process – that I, their word length. Over time, five standard
data widths have evolved for microprocessors: 4-bit, 8-bit, 16-bit, 32-bit, 64-bit. There are so
many manufacturers of Microprocessors, but only two companies have been produces popular
microprocessors: Intel and Motorola
μP
8085
8086
80286
80386EX , 80386DX
80486DX4
Pentium
Intel family:
Data bus width
8
16
16
16 , 32
32
64
PentiumIII , Pentium4
64
6800
68060
Motorola family:
8
64
Memory capacity
64K
1M
16M
64M , 4G
4G + 16K cache
4G + 16K cache
64G+32K L1 cache
+256 L2 cache
64K
4G + 16K cache
Microprocessors also control the logic of almost all digital devices, from clock radios to fuelinjection systems for automobiles. Hence it is necessary to understand the working of
microprocessors.
Microcontroller: A highly integrated chip that contains all the components comprising a
controller.
• Typically this 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.
• The great advantage of microcontrollers, as opposed to using larger microprocessors, is that
the parts-count and design costs of the item being controlled can be kept to a minimum.
• 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.
Micro processor
Single chip with Processing unit . Memory, I/O
Ports to be connected externally
Design for General purpose application
Micro controller
Single chip with CPU,I/O,Peripherals like
timer,RAM,ROM ,serial and parallel ports
Designed for Specific application
Eg: 8085,8086
Eg:8051
Advantages of Microprocessor based system
1. Computational/processing speed is high.
2. Intelligence has been brought to systems.
3. Automation of industrial processes and office administration.
4. Since the devices are programmable, there is flexibility to alter the system by changing the
software alone.
5. Less number of components, compact in size and cost less. Also it is more reliable.
6. Operation and maintenance are easier.
Disadvantages of Microprocessor based System
1. It has limitations on the size of data.
2. The applications are limited by the physical address space.
3. The analog signals cannot be processed directly and digitizing the analog signals introduces
errors.
4. The speed of execution is slow and so real time applications are not possible.
5. Most of the microprocessors does not support floating point operations.
• The History of Intel’s Microprocessors
•
•
•
•
•
•
•
•
•
•
•
Intel 4004
– 1971, 4-bit
Intel 8008
– 1972, 8-bit
– Originally designed for Datapoint Corp. as a CRT display controller
Intel 8080
– 1974, April - Altair 8800, 1975, MITS( 256 bytes of Mem, $395)
– Apple II -- Steve Jobs and Steve Wozniak 1976, Apple
– Bill Gates and a fellow student : BASIC, 1975 --> Microsoft
Intel 8086/8088
– 1978, 16 bit: 8088, 1979, 8-bit external bus
– IBM PC ; 1981
– 29,000 Trs
Intel 80286
– 1982, 16-bit architecture
– 24-bit addressing, memory protection and virtual memory
– 16 MB of physical MEM and 1 GB of virtual mem
– 130,000 Trs onto a single chip
– IBM PC/AT in 1984, IBM PS/2 Model 50 and 60
Intel 80386
– 1985, 32 bits
– 3~5 MIPS (7 MIPS on the 25 MHz chip)
– memory paging and enhanced I/O permission features
– 4GB programming model
Intel 80486
– 1989 Spring COMDEX show -> 1990 June : actual release
– 1,200,000 Trs
– 386+387+8K data and instruction cache, paging and MMU
Pentium
– 1993
– 110 MIPS on 66 Mhz Chip
– 16 KB on-chip cache and 64 bit data bus
– superscalar technology (two instructions/clock)
– 3.1 million transistors
Pentium Pro
– 1995, Superscalar(three-way issue)
– 5.5 million Trs in the CPU core + 15.5 million Trs in the secondary cache
– 8K data, 8K instr cache
– 256 KB SRAM secondary cache
– 200 SPECint92 at 133 MHz
2.9 V, 0.6 micron BICMOS
Pentium II
– Pentium Pro + MMX, 1997
– 233, 266, upto 450 MHz
– 7.5 million Trs in CPU
– 512KB in secondary cache
Pentium III,IV, Dual core ,Quad core etc
Basic Programming model
Once we understand the basic programming model for the 8085 and 8086 processors, we will be able to
understand the improvements made with the newer models.
8085 Microprocessor
The main features of 8085 μp are:
• It is a 8 bit microprocessor with 8 bit data bus and 16 bit address bus.
• It is manufactured with N-MOS technology.
16
• Since it has 16-bit address bus and hence can address up to 2 = 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 .
• It supports external interrupt request.
• A 16 bit program counter (PC)
• A 16 bit stack pointer (SP)
• Six 8-bit general purpose register arranged in pairs: BC, DE, HL.
• It requires a signal +5V power supply and operates at 3-6 MHZ single phase clock.
• It is enclosed with 40 pins DIP (Dual in line package).
System Bus is the group of wires used to carry data or address or control signals and hence classified into
data bus or address bus or control bus.
In 8085 ,
Address Bus : Consists of 16 unidirectional address lines: A0 – A15
– Address locations: 0000 (hex) – FFFF (hex)
– Can access 64K bytes of memory, each byte has 8 bits
– Can access 64K × 8 bits of memory
Data Bus : Consists of 8 data lines: D0 – D7
– Operates in bidirectional mode
– The data bits are sent from the MPU to I/O & vice versa
– Data range: 00 (hex) – FF (hex)
• Control Bus:
– Consists of various lines carrying the control signals such as read / write enable, flag bits
[ Question?: If you have a memory chip of size 256 kilobytes (256 x 1024 x 8 bits), how many wires does the
address bus need, in order to be able to specify an address in this memory? Note: the memory is organized in
groups of 8 bits per location, therefore, how many locations must you be able to specify?
256 X1024 locations and each are of size 8bit hence 262144 locations can be accessed:
256 =2 8 ,1024=2 10
Therefore 18 address lines are needed ]
The various functional blocks of 8085 micro processor are :
a) Registers
b) Arithmetic and Logic Unit
c) Instruction decoder and machine cycle encoder
d) Address buffer
e) Address/ Data buffer
f) Incrementor / Decrementor address latch
g) Interrupt control
h) Serial I/O control
i) Timing and control Circuit
a. Registers
It has eight addressable 8-bit registers: A, B, C, D, E, H, L and two 16-bit registers PC and SP. These
registers can be classified as:
a. General Purpose Registers - B, C, D, E, H, L
b. Temporary Registers
i) Temporary Data Register ii) W and Z registers
c. Special Purpose Registers
i) Accumulator ii) Flag Registers iii) Instruction Register
d. Sixteen bit Registers
i)Program counter ii) Stack pointer
A. General Purpose Registers:
– Six general purpose 8‐bit registers: B, C, D, E, H,L
– Combined as register pairs to perform 16‐bit operations: BC, DE, HL
– Registers are programmable (load, move, etc.)
B. Temporary Registers
Temporary Data register: The ALU has two inputs, one from the accumulator and other from temporary data
register. The programmer cannot access this temporary data register. b. W and Z registers: They are used to
hold 8-bit data during execution of some instructions and are not available for the programmer.
W and Z registers
1) The CALL instruction is used to transfer program control to a subprogram or subroutine. This instruction
pushes the current PC contents onto the stack and loads the given address into the PC. The given address is
temporarily stored in the W and Z registers and placed on the bus for the fetch cycle. Thus the program
control is transferred to the address given in the instruction.
2) XCHG instruction exchanges the contents of H with D and L with E. At the time of exchange W and Z
registers are used for temporary storage of data.
C. Special Purpose Registers
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) Flag Registers
- 8 bit register
- 5 flag bits
- Reflects the condition of accumulator
S- sign flag bit
If D7 bit of accumulator is 1, S=1(set) indicating negative number
If D7 bit of accumulator is 0, S=0(reset) indicating positive number
Z-Zero flag bit
If accumulator content is zero Z=1 else it is 0
P-Parity flag =1 if the parity is even
CY- Carry flag = 1 , if there was a carry /borrow
AC-Auxiliary carry flag=1 ,if there was a carry out from bit 3 to bit 4 of the result
{Note 1 : AC is the only flag that is not user accessible. Used by DAA instruction
alone}
{Note 2: The contents of accumulator and flag register together is called as program
Status word)
iii) Instruction Register -Instruction register temporarily stores the current instruction of a
program.
D. Sixteen bit Registers
Program Counter (PC)
- 16-bit register deals with sequencing the execution of instructions.
- is a memory pointer. Memory locations have 16-bit addresses, and hence this is a 16-bit register.
- points the memory address from which the next byte is to be fetched.
Stack Pointer (SP)
-16-bit register used as a memory pointer.
- points to a memory location in R/W memory, called the stack.
- beginning of the stack is defined by loading 16-bit address in the stack pointer.
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.
Instruction Decoder - Decoder then takes instruction and ‘decodes’ or interprets the instruction. Decoded
instruction is then passed to next stage.
Address Buffer: It is an 8-bit unidirectional buffer. It is used to drive external high order address bus. It is also
used to tri-state the high order address bus under certain conditions such as reset, hold, halt and when address
lines are not in use.
Address/ Data Buffer
It is an 8-bit bi-directional buffer. It is used to drive multiplexed address/data bus i.e., low order address bus
(A7- A0) and Data bus (D7- D0). It is also used to tri-state the multiplexed address/data bus under certain
conditions such as reset, hold, halt and when the bus is not in use.
The address and data buffers are used to drive external address and data buses respectively. Due to these buffers
the address and data buses can be tri-stated when they are not in use.
Incrementer / Decrementer Address Latch
This 16-bit register is used to increment or decrement the contents of program counter or stack pointer as a part
of execution of instructions related to them.
Timing and Control Unit
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.
Pin Diagram of the 8085 microprocessor
8085 pins can be grouped as
 Power supply pins
 Address and Data pins
 Control pins
 Status pins
 Interrupt pins
 Serial I/O pins
 Clock pins
 Reset pins
 DMA pins
 Power supply pins
Vcc : +5 volt supply.
Vss: Ground Reference.
 Address and Data pins
A8-A15 :Higher order Address Bus;
 The most significant 8 bits of the memory address or the 8 bits of the I/O address
 Tristated during Hold and Halt modes.
AD0 -AD 7 : Lower order Multiplexed Address/Data Bus;
 Lower 8 bits of the memory address (or I/O Address) appear on the bus during the first clock cycle
of a machine state.
 It then becomes the data bus during the second and third clock cycles.
 Tristated during Hold and Halt modes.
 Status Signals:
ALE (Output):Address Latch Enable:
 It occurs during the first clock cycle of a machine state
 When ALE= HIGH, Address is available in AD0 –AD7 multiplexed address and data lines.
 When ALE= LOW, Data is available in AD0 –AD7 multiplexed address and data lines.
S0, S1 (Output):
S1
S0
Operation
0
0
Halt
0
1
Write
1
0
Read
1
1
Fetch
S1 can be used as an advanced R/W status.
̅ (Output) :
𝑰𝑶/𝑴




IO/M indicates whether the Read/Write is to memory or l/O
̅ =1 if Read/write is IO related operation
𝐼𝑂/𝑀
̅ =0 if Read/write is Memory related operation
𝐼𝑂/𝑀
Tristated during Hold and Halt modes.
 Control pins:
̅̅̅̅̅ (Output 3state): READ;
𝑹𝑫
 = 0, indicates the selected memory or I/O device is to be read .
̅̅̅̅̅
𝑾𝑹 (Output 3state): WRITE;
 =0, indicates the data on the Data Bus is to be written into the selected memory or 1/0 location.
READY (Input)
 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 for Ready to go high before completing the read or write cycle.
 DMA control lines:
HOLD (Input)
 indicates that another Master is requesting the use of the Address and Data Buses.
 The CPU, upon receiving the Hold request , will relinquish/release the use of buses as soon as the
completion of the current machine cycle. Internal processing can continue.
 The processor can regain the buses only after the Hold is removed.
 When the Hold is acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output):HOLD ACKNOWLEDGE;
 indicates that the CPU has received the Hold request and that it will release the buses in the next clock
cycle.
 HLDA goes low after the Hold request is removed.
 The CPU takes the buses after HLDA goes low.
 Interrupt Pins:
̅̅̅̅̅̅̅)
5 hardware interrupts ( INTR,TRAP,RST 7.5,RST 6.5,RST 5.5 and 1 Interrupt acknowledgement (𝐼𝑁𝑇𝐴
INTR (Input): INTERRUPT REQUEST;
 is used as a general purpose interrupt.
 It is a maskable interrupts
 The INTR is enabled and disabled by software. It is disabled by Reset and immediately after an
interrupt is accepted.
 It is sampled only during the next to the last clock cycle of the instruction. If it is active, the Program
Counter (PC) will be inhibited from incrementing and an INTA will be issued. During this cycle a RESTART
or CALL instruction can be inserted to jump to the interrupt service routine.
̅̅̅̅̅̅̅ (Output) :INTERRUPT ACKNOWLEDGE;
𝐈𝐍𝐓𝐀
 It is an acknowledgement after an INTR is accepted.
 It can be used to activate the 8259 Interrupt chip or some other interrupt port.
RESTART INTERRUPTS; RST 5.5, RST 6.5, RST 7.5
 These three inputs have the same timing as INTR except they cause an internal RESTART to be
automatically inserted.
RST 7.5 ~~ Highest Priority
RST 6.5
RST 5.5 o Lowest Priority
 These interrupts have a higher priority than the INTR.
TRAP (Input)
 Trap interrupt is a nonmaskable(NMI) interrupt.
 It is unaffected by any mask or Interrupt Enable.
 It has the highest priority of any interrupt.
Reset Pins:
RESET IN (Input)
 Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA flipflops.
 None of the other flags or registers (except the instruction register) are affected
 The CPU is held in the reset condition as long as Reset is applied.
RESET OUT (Output)
 Indicates CPU is being reset.
 Can be used as a system RESET.
 The signal is synchronized to the processor clock.
 CLOCK pins:
X1, X2 (Input)
 Crystal or R/C network connections to set the internal clock generator
 X1 can also be an external clock input instead of a crystal.
 The input frequency is divided by 2 to give the internal operating frequency.
CLK (Output)
 Clock Output for use as a system clock when a crystal or R/ C network is used as an input to the CPU.
 The period of CLK is twice the X1, X2 input period.
Serial I/O lines:
SID (Input)
Serial input data line The data on this line is loaded into accumulator bit 7 whenever a RIM instruction is
executed.
SOD (output)
Serial output data line. The output SOD is set or reset as specified by the SIM instruction.
8085 Addressing modes:
The various formats for specifying operands are called the ADDRESSING MODES.
For 8085, they are:
1. Immediate addressing.
2. Register addressing.
3. Direct addressing.
4. Indirect addressing.
5.Implied Addressing.
Immediate addressing
Data is present in the instruction. Load the immediate data to the destination provided.
Example: MVI R,data
Register addressing
Data is provided through the registers.
Example: MOV Rd, Rs
Direct addressing
Address where the data has to be stored or retrieved is given in the instruction itself.
Example: LDA 4000H
Indirect Addressing
This means that the Effective Address is calculated by the processor. And the contents of the address (and
the one following) is used to form a second address. The second address is where the data is stored. Note that
this requires several memory accesses; two accesses to retrieve the 16-bit address and a further access (or
accesses) to retrieve the data which is to be loaded into the register.
Example :LDAX B
In simple
In indirect addressing modes instructions have their operand in memory and the 16-bit memory address is
specified in a register pair e.g. LDAX, STAX, PUSH, POP etc.
Implied Addressing:
These instruction have their operand implied in the op-code itself e.g. CMA, CMC, STC etc.
8085 Instruction Set
An instruction is assembled in the memory of a microcomputer system in binary form.
The instruction is of the form opcode,operand .
– an opcode, or operation code, tells the microprocessor which operation to perform
– an operand is the value on which the opcode has to operate
The size of an instruction signifies how much memory space is required to load an instruction in the memory.
8085 instructions are of following sizes:
 One-byte Instructions – has opcode alone
e.g. MOV, ADD, ANA, SUB, ORA etc.
 Two-byte instructions- has opcode and one byte operand
e.g. MVI, ADI, ANI, ORI, XRI etc.
 Three-byte instructions- has opcode and two byte operand
e.g. LXI, LDA, STA, LHLD, SHLD etc.
 Instruction set of 8085 can be classified in following groups:
 Data Transfer Instructions
 These instructions can perform data transfer operations between
 Registers of 8085 e.g. MOV
 8085 registers and main memory e.g. LDA, STA, MOV, LDAX, STAX, MVI,
LXI etc.
 Accumulator register and I/O devices e.g. IN, OUT
 Data transfer instructions never affect the flag bits
 Arithmetic Instructions
 8085 can perform only 8-bit addition, subtraction and compare operations. These operations are
always performed with accumulator as one of the operands. The status of the result can be
verified by the contents of the flag register.
 Op-codes for arithmetic instructions include ADD, ADI, ADC, ACI, SUB, SUI, SBB, SBI,
CMP, CPI
 Logical Instructions
 8085 can perform 8-bit basic logical operations -AND, OR, XOR, NOT with some special
operations such as rotate and shift operations
 Logical instructions also modify the flag bits.
 Op-codes for logical instructions include ANA, ANI, ORA, ORI, XRA, XRI, CMA, RAL, RLC,
RAR, RRC etc.
 Program Control Instructions
 These instructions are used to transfer the program control:
 to jump from one memory location to any other memory location within a program
 from one program to another program called as a subroutine
 8085 Instruction set consists of following program control instructions:
 Jump Instructions
 Call & Return Instructions
 Restart instructions
 Program control instructions
 Unconditional or Conditional
 Unconditional program control instructions perform branching operation
unconditionally
 Unconditional Program control instructions are
 JMP
 Call & RET
 RST n (n=0-7)
 Conditional program control instructions perform branching operation with
reference to the condition of flag bits.
 Conditional Program control instructions are
 JNC, JC, JNZ, JZ, JP, JM, JPE, JPO
 CNC, CC, CNZ, CZ, CP, CM, CPE, CPO
 RNC, RC, RNZ, RZ, RP, RM, RPE, RPO
 Machine control Instructions
These instructions include special instructions such as
 HLT – To halt the CPU
 NOP – To perform no operation
 SIM – To set the masking of hardware interrupts and serial output data
 RIM – To read the status of interrupt mask and serial input data
 EI – Enable Interrupt
 DI – Disable Interrupt
For more details refer Part 2 ( A separate pdf )
Review Questions:
1. Define microprocessor
2. Give some examples for 8 bit microprocessor
3. Give some examples for 16 bit microprocessor
4. Write the difference between microprocessor and microcontroller.
5. Write the flag structure of 8085 µP
6. Which is the only flag that is not user accessible in 8085?
7. What are the 16 bit registers of 8085.
8. Define stack.
9. What is the use of PC and SP?
10. What is the use of HOLD and HLDA pins.
11. Mention the hardware interrupts of 8085.
12. Write down the software interrupts of 8085.
13.Give example for vectored and non vectored interrupts of 8085.
14. Define addressing mode.
15. Give example for Direct and indirect addressing mode.
16. How 8085 instructions are classified.
17. Give example for 2 byte instruction.
18. Which is the only instruction that affects the AC flag.
19.What is the difference between jump and cll instruction.
20.Write the priorities of 8085 interrupt.
Download