8085 up notes

44
1 Memory and I/O Memory: Where instructions (programs) and data are stored Organized in arrays of locations (addresses), each storing one byte (8 bits) in general A read operation to a particular location always returns the last value stored in that location I/O devices: Enable system to interact with the world Device interface (a.k.a. controller or adapter) hardware connects actual device to bus The CPU views the I/O device registers just like memory that can be accessed over the bus. However, I/O registers are connected to external wires, device control logic, etc. Reads may not return last value written Writes may have side effects

Upload: abhijit-chakrabarty

Post on 13-Nov-2014

1.908 views

Category:

Documents


0 download

DESCRIPTION

It is a very easy track to get into athe world of microprocessors...

TRANSCRIPT

Page 1: 8085 uP Notes

1

Memory and I/OMemory: Where instructions (programs) and data are stored

• Organized in arrays of locations (addresses), each storing one byte (8 bits) in general

• A read operation to a particular location always returns the last value stored in that location

I/O devices: Enable system to interact with the world

• Device interface (a.k.a. controller or adapter) hardware connects actual device to bus

• The CPU views the I/O device registers just like memory that can be accessed over the bus. However, I/O registers are connected to external wires, device control logic, etc.• Reads may not return last value written• Writes may have side effects

Page 2: 8085 uP Notes

BusBus: A shared group of wires used for communicating signals among devices

• address bus: the device and the location within the device that is being accessed• data bus: the data value being communicated• control bus: describes the action on the address and data

buses

Page 3: 8085 uP Notes

3

8085 Microprocessor Architecture

Now we will examine these components more closely by using the Intel 8085 microprocessor architecture as an example:

Page 4: 8085 uP Notes

4

The 8085 Bus Structure

The 8-bit 8085 CPU (or MPU – Micro Processing Unit) communicates with the other units using a 16-bit address bus, an 8-bit data bus and a control bus.

Page 5: 8085 uP Notes

5

The 8085: CPU Internal Structure

The internal architecture of the 8085 CPU is capable of performing the following operations:

Store 8-bit data (Registers, Accumulator)

Perform arithmetic and logic operations (ALU)

Test for conditions (IF / THEN)

Sequence the execution of instructions

Store temporary data in RAM during execution

Page 6: 8085 uP Notes

6

The 8085 Bus Structure

Address Bus

Consists of 16 address lines: A0 – A15

Operates in unidirectional mode: The address bits are always sent from the MPU to peripheral devices, not reverse.

16 address lines are capable of addressing a total of 216 = 65,536 (64k) memory locations.

Address locations: 0000 (hex) – FFFF (hex)

Page 7: 8085 uP Notes

7

The 8085 Bus Structure Data Bus

Consists of 8 data lines: D0 – D7

Operates in bidirectional mode: The data bits are sent from the MPU to peripheral devices, as well as from the peripheral devices to the MPU.

Data range: 00 (hex) – FF (hex)

Control Bus

Consists of various lines carrying the control signals such as read / write enable, flag bits.

Page 8: 8085 uP Notes

8

The 8085: CPU Internal Structure

Simplified block diagram

Page 9: 8085 uP Notes

9

The 8085: Registers

Page 10: 8085 uP Notes

Registers

• The 8085programming model includes six registers, one accumulator, and one flag register. In addition, it has two 16-bit registers: the stack pointer and the program counter.

• 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.

Page 11: 8085 uP Notes

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.

Page 12: 8085 uP Notes

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 The microprocessor uses these flags to test data conditions.

Page 13: 8085 uP Notes

Flag Registers

D7 D6 D5 D4 D3 D2 D1 D0

S Z AC P CY

Page 14: 8085 uP Notes

Carry Flag

• Carry holds the carry after addition or the borrow after subtraction.

• The carry flag also indicates error conditions as dictated by some programs and procedures.

3A = 00111010+7C = 01111100

B6 = 10110110

CF=0

AA = 10101010+7C = 01111100

126 =100100110

CF=1

This is the carry flag.

Page 15: 8085 uP Notes

Parity Flag

• Parity is a count of ones in a number expressed as even or odd.

• Parity is a logic 0 for odd parity and a logic 1 for even parity.• If a number contains odd binary one bits, it has odd parity.

If a number contains zero or even binary one bits, it has even parity.

3A = 00111010+7C = 01111100

B6 = 10110110PF=0

3A = 10101010+78 = 01111000

B2 = 10110010PF=1

Page 16: 8085 uP Notes

Auxillary Carry Flag

• If the carry propagates from the 4th bit of the result to the 5th bit, then this bit is set.

3A=00111010 +7C=01111100

B6=10110110 AC=1 AC=1

Page 17: 8085 uP Notes

Zero Flag

• The zero flag shows that the result of an arithmetic or logic operation is zero.

• If the result is zero, ZF=1; If the result is not zero, ZF=0.

3A = 00111010+7C = 01111100

B6 = 10110110

ZF=0

84 = 10000100+7C = 01111100

100 =100000000

ZF=1

Don’t worry. This is the carry flag.

Page 18: 8085 uP Notes

Sign Flag

• The sign flag holds the arithmetic sign of the result after an arithmetic or logic instruction executes.

• If SF=1, the sign bit (leftmost bit of a number) is set or negative ; If SF=0, the sign bit is cleared or positive .

3A = 00111010+7C = 01111100

B6 = 10110110

SF=1

84 = 10000100+7C = 01111100

100 =100000000

SF=0

Don’t worry. This is the carry flag.

Page 19: 8085 uP Notes

The Flags register• S-sign flag

– The sign flag is set if bit D7 of the accumulator is set after an arithmetic or logic operation.

• Z-zero flag– Set if the result of the ALU operation is 0. Otherwise is reset. This flag is

affected by operations on the accumulator as well as other registers. AC-Auxiliary Carry

– This flag is set when a carry is generated from bit D3 and passed to D4 . This flag is used only internally for BCD operations.

• P-Parity flag– After an ALU operation if the result has an even no: of 1’s the p-flag is set.

Otherwise it is cleared. So, the flag can be used to indicate even parity.• CY-carry flag

If an arithmetic operation results in a carry, the CY flag is set; otherwise it is reset

Page 20: 8085 uP Notes

Just A Minute!!!

• Let the contents of register A = 59 & B= C8. The contents are summed up using the ADD

instruction. What would the contents of accumulator and flag register after the instruction is executed?

Page 21: 8085 uP Notes

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

Page 22: 8085 uP Notes

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.

Page 23: 8085 uP Notes

Instruction Set Classification

• An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions, called the instruction set, determines what functions the microprocessor can perform.

Page 24: 8085 uP Notes

Instruction Set Classification

• These instructions can be classified into the following five functional categories:

data transfer (copy) operations, arithmetic operations, logical operations, branching operations, machine-control operations.

Page 25: 8085 uP Notes

Data Transfer (Copy) Operations

• This group of instructions copy data from a location called a source to another location called a destination, without modifying the contents of the source.

Page 26: 8085 uP Notes

Types Examples

1. Between Registers. 1. Copy the contents of the register B into register D.

2. Specific data byte to a register or a

memory location.

2. Load register B with the data byte 32H.

3. Between a memory location and a

register.

3. From a memory location 2000H to register B.

4. Between an I/O device and the

accumulator.

4.From an input keyboard to the

accumulator

Page 27: 8085 uP Notes

Arithmetic Operations

• These instructions perform arithmetic operations such as addition, subtraction,increment, and decrement.

Page 28: 8085 uP Notes

Addition

• Any 8-bit number, or the contents of a register or the contents of a memory location can be added to the contents of the accumulator and the sum is stored in the accumulator. No two other 8-bit registers can be added directly

• (e.g., the contents of register B cannot be added directly to the contents of the register C). The instruction DAD is an exception; it adds 16-bit data directly in register pairs.

Page 29: 8085 uP Notes

Subtraction

• Any 8-bit number, or the contents of a register, or the contents of a memory location can be subtracted from the contents of the accumulator and the results stored in the accumulator. The subtraction is performed in 2's compliment, and the results if negative, are expressed in 2's complement. No two other registers can be subtracted directly.

Page 30: 8085 uP Notes

Increment/Decrement

• The 8-bit contents of a register or a memory location can be incremented or decrement by 1. Similarly, the 16-bit contents of a register pair (such as BC) can be incremented or decrement by 1.

Page 31: 8085 uP Notes

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 ANDed, Ored, or Exclusive-ORed 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.

Page 32: 8085 uP Notes

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.

Page 33: 8085 uP Notes

Machine Control Operations

• These instructions control machine functions such as Halt, Interrupt, or do nothing

Page 34: 8085 uP Notes

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 (opcode), 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.

Page 35: 8085 uP Notes

Instruction word size

• The 8085 instruction set is classified into the following three groups according to word size:

• 1. One-word or 1-byte instructions• 2. Two-word or 2-byte instructions• 3. Three-word or 3-byte instructions

Page 36: 8085 uP Notes

• A 1-byte instruction includes the opcode and operand in the same byte. Operand(s)

are internal register and are coded into the instruction.

• For example:

Page 37: 8085 uP Notes

Task Opcode Operand

Binary

Code

Hex

Code

Copy contents Of the accumulator into the register C MOV C,A 0100 1111 4FH Add the contents of register B to the contents of the accumulator.

ADD B 1000 0000 80H

Invert (compliment) each bit in the accumulator. CMA 0010 1111 2FH

Page 38: 8085 uP Notes

• 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.

Page 39: 8085 uP Notes

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:

Page 40: 8085 uP Notes

Task Opcode Operand Binary

Code

Hex Code

Load an 8-bit data

byte in the accumulator.

MVI A, 32H 0011 1110

0011 0010

3E

32H

First Byte

Second Byte

Load an 8-bit data

byte in register B.

MVI B,F2H 0000 0110

1111 0010

06

F2

First Byte

Second Byte

Page 41: 8085 uP Notes

• The instruction would require two memory locations to store in memory.

Page 42: 8085 uP Notes

Task Opcode Operand Binary

Code

Hex Code

.Load

contents of

memory

2050H into

A

LDA 2050H 0011 1010

0101 0000

0010 0000

3A

50

20

First Byte

Second Byte

Third Byte

Transfer the program

sequence to the memory

location

2085H.

JMP 2085H 1100 0011

1000 0101

0010 0000

C3

85

20

First Byte

Second Byte

Third Byte

Page 43: 8085 uP Notes

• This instruction would require three memory locations to store in memory

• Three byte instructions - opcode + data byte + data byte

Page 44: 8085 uP Notes

Post your comments [email protected]