You are on page 1of 11

TAO1221 Computer Architecture and Organization Tutorial 1

Microprocessor basic concepts and


8085 microprocessor architecture
Objectives:

Studying the organization of a microprocessor based system


Studying the basic working of a microprocessor
Studying some of the basic concepts of microprocessors
Architecture of Intel 8085 microprocessor with functional block diagram

- Registers
- Programmable
- General purpose (B, C, D, E, H, L Registers)
- Special Purpose (AC, FR, PC, SP)
- Non-Programmable IR, Temporary Registers

Page 1 of 11 1
TAO1221 Computer Architecture and Organization Tutorial 1

I. ORGANIZATION OF A MICROPROCESSOR-BASED SYSTEM

Main components of a microprocessor-based system are

Keyboard, through which instructions are entered into the microcomputer

Display device, through which the computer displays its messages and results

ROM (Read Only Memory), in which permanent programs (example monitor


program of a single board microcomputer) that do not need alterations are stored.
This program interprets the information entered through keyboard and provides
equivalent binary digits to the microprocessor

RAM (Random Access Memory or Read-Write Memory), in which temporary or


trial programs are written and it is also an area which the computer uses for storing
temporary information during program execution. In single board microcomputers,
the monitor program monitors the Hex keys and stores those instructions and data
in the R/W memory. The information stored in this memory can be easily read and
altered.

CPU (Central Processing Unit) (CPU on a single chip of silicon is called


microprocessor), the most important component which manages the entire
microcomputer operation; it takes inputs from the permanent programs stored in the
ROM or temporary programs stored in the RAM on the basis of an instruction set
that is recognized by the CPU. It also takes input from the keyboard (or from other
peripheral devices) or gives output to the display device (or to other peripheral
devices) through appropriate interfaces.

Clock (a square wave oscillator) which drives the CPU to perform at a certain rate.

System Bus, A communication path between microprocessor and peripherals. It is


a group of wires to carry the bits to be transferred. All peripherals and memory
share the same bus. The microprocessor communicates with only one peripheral
at a time.

Page 2 of 11 2
TAO1221 Computer Architecture and Organization Tutorial 1

There are several types of buses:


Address bus, which is unidirectional (bits flow in one direction-from
CPU to peripheral devices) and perform the function of identifying a
peripheral or a memory location.
Data Bus, which is bidirectional (bits flow in both directions between
CPU and peripheral devices) and perform the function of
transferring data
Control Bus, which is comprised of various single lines that carry
synchronization signals and perform the function of
providing timing signals

II. BASIC WORKING OF A MICROPROCESSOR


Assume that a program and data are already entered in the R/W memory. The
program includes binary instructions to perform certain operation on a given data and
to display the answer at some display unit.

The process of executing a program by the microprocessor can be summarized as


follows:
- The instructions are stored sequentially in R/W memory.
- The microprocessor fetches the first instruction from the memory, decodes it,
and executes that instruction.
- The sequence of fetch, decode, and execute is continued until the
microprocessor comes across an instruction to stop.

During the entire process, the microprocessor uses


- System bus to fetch the binary instructions and data from the memory (or
I/O devices)
- Registers to store data temporarily
- ALU unit to perform computation and
- Same bus lines to send the result in binary to display unit.

The actions performed by the microprocessor can be grouped into four categories:

1. CPU-Memory: Data may be transferred from the CPU to memory or from memory
to CPU.
2. CPU-I/O: Data maybe transferred to or from the outside world by transferring
between the CPU and an I/O module.
3. Data Processing: The CPU may perform some arithmetic or logic operations on
data.
4. Control: An instruction may specify that the sequence of execution be altered (e.g.,
a Jump instruction, which changes the content of the PC (program counter)). For
example, the CPU may fetch an instruction from memory location 149, which
specifies that the next instruction be fetched from location 182. The CPU will
remember this fact by setting the program counter to 182. Thus, on the next fetch
cycle, the instruction will be fetched from location 182 rather than 150.

Page 3 of 11 3
TAO1221 Computer Architecture and Organization Tutorial 1

III. BASIC CONCEPTS OF MICROPROCESSORS


DIFFERENCES BETWEEN
Microprocessor, Microcomputer and Microcontroller
Machine Language, Assembly language and High-level language
bit, byte, nibble, word, instruction, program
Compiler, Interpreter, Assembler, Cross Assembler
Monitor Program and User Program
Writing and assembling a program using Manual/Hand Assembly and using cross
-Assembler

Basic Differences between Microprocessor, Microcomputer and Microcontroller:

Microprocessor: A semiconductor device manufactured by using Very Large Scale


Integration (VLSI) technique. It includes ALU, register arrays and control circuits on a
single chip of Silicon.

Microcomputer: A computer that is designed using a microprocessor as its CPU. It


includes microprocessor, memory and I/O

Microcontroller: A device that includes microprocessor, memory and I/O signal lines
on a single chip of silicon fabricated using VLSI technology.

Differences between Machine Language, Assembly language and High-level


language:

Machine Language: Binary medium of communication with a computer through a


designed set of instructions specific to the computer. (Machine dependent)

Assembly Language: A medium of communication with a computer in which


programs are written in mnemonics (memory aid). An assembly language is specific to
a given computer (machine dependent)

High-level language: A medium of communication that is independent of a given


computer (machine independent). Programs are written in English-like words, and they
can be executed on a machine using a translator (a compiler or an interpreter)

Relation between bit,byte,nibble,word,instruction,program:

Bit - a binary digit 0 or 1- A basic unit of information


Nibble - a group of 4 bits
Byte - a group of 8 bits
Word - a group of bits that the computer recognizes and processes at a time
Instruction - a command in binary that is recognized and executed by the computer to
accomplish a task

Page 4 of 11 4
TAO1221 Computer Architecture and Organization Tutorial 1

Program - A set of instructions written in specific sequence for the computer to


accomplish a given task
Software - A group of programs

Differences between Compiler, Interpreter, Assembler, Cross Assembler:

Compiler: A program that translates English like words of high level language into the
machine language of a computer. A compiler reads a given program, called a source
code, in its entirety and then translates the program into the machine language, which
is called the object code.

Interpreter: same function as compiler (A program that translates English like words of
high level language into the machine language of a computer.). Difference is it
translates one statement at a time from a source code to an object code.

Assembler: A computer program that translates an assembly language program from


mnemonics to the binary machine code of a computer.

Cross Assembler: Suppose we want to run programs of 8085 microprocessor in PC


with Pentium processor, a program known as cross assembler can be used to translate
the 8085 mnemonics into appropriate machine code.

Differences between Monitor Program and User Program:

Monitor Program: A program that interprets the input from a keyboard and converts
the input into its binary equivalent. It is stored in ROM since this does not need
alterations.

User Program: Read/Write memory is used for storing user programs and data. The
information stored in this memory can be easily read and altered.

Differences between writing and assembling a program using Manual/Hand


Assembly and using cross -Assembler:

Manual/Hand Assembly:

For small programs, in order to manually write and execute an assembly language
program on a single-board computer, with a Hex keyboard for input and LEDs for
output, the following steps are necessary.
1. Write the instructions in mnemonics obtained from the instruction set supplied by
the manufacturer.
2. Find the hexadecimal machine code for each instruction by searching through the
set of instructions.
3. Enter (load) the program in the user memory in a sequential order by using the
Hex keyboard as the input device.

Page 5 of 11 5
TAO1221 Computer Architecture and Organization Tutorial 1

4. Execute the program by pressing the Execute key. The answer will be displayed
by the LEDs.

When the user program is entered by the keys, each entry is interpreted and converted
into its binary equivalent by the monitor program, and the machine code is stored as
eight bits in each memory location in a sequence. When the Execute command is
given, the microprocessor fetches each instruction, decodes it, and executes it in a
sequence until the end of the program.

Using cross-assembler:

Steps involved in writing and assembling a program using a cross-assembler such as


X8085:

1. Call an Editor program and write an assembly language program in 8085


mnemonics. This is called a source file. Save this file and exit from the editor
program.

2. Call a cross-assembler such as X8085 and assemble the source file saved in step1.
The X8085 generates an intermediate binary file called an object file and provides a
list of errors. Go back and repeat step1 to correct errors. Repeat step 2 and
reassemble the program. Repeat steps 1 and 2 until the cross-assembler gives a
message of zero errors.
The cross-assembler also generates a list file that includes memory addresses,
machine codes in Hex, labels, and comments. This file is used for documentation.

3. Call a link program and use the intermediate file to generate Hex file.

4. Download Hex file into Target system (single board microcomputer) and execute
program.

5. If the expected results are not achieved, troubleshoot using single step and /or
breakpoint technique. Once you find an error, you must go back to step 1 and
repeat all the steps.

Page 6 of 11 6
TAO1221 Computer Architecture and Organization Tutorial 1

IV. ARCHITECTURE OF INTEL 8085 MICROPROCESSOR:

Functional Block Diagram of 8085 Microprocessor

1. Highlights:
The 8085 is an 8 bit microprocessor capable of addressing up to 64K bytes of
memory
It has eight addressable 8 bit registers, six of which can also be used as three pairs
of 16 bit registers. Besides this the accumulator and flag register are special
purpose 8 bit registers. Program counter and Stack pointer are special purpose 16
bit registers.
The five hardware interrupts, in order of decreasing priority are: TRAP, RST 7.5,
RST 6.5, RST 5.5, and INTR. TRAP is unmaskable
The 40 pin device, powered by +5V DC, has provisions for generating its own clock
signal. Of the sixteen address lines, the low-order eight lines are multiplexed with
the eight data lines.
The timing operation is based on seven types of machine cycles: Opcode Fetch,
Memory Read/Write, I/O Read/Write, INTR Acknowledge, and Bus Idle

Page 7 of 11 7
TAO1221 Computer Architecture and Organization Tutorial 1

2. FUNCTIONAL DESCRIPTION:
2.1 REGISTERS
Registers of 8085 microprocessor are classified into programmable and
nonprogrammable registers.

2.1.1 PROGRAMMABLE

Registers which can be used for data manipulation by writing instructions.


Programmable registers are classified into General Purpose Registers and Special
Purpose Registers.

2.1.1.1 General Purpose Registers:

The 8085 has six general-purpose registers (B, C, D, E, H and L) to store 8 bit data
during a program execution. They can be used either singly, or as 16 bit register pairs
BC, DE, and HL.
The register pair HL, besides its possible use as two independent 8 bit
registers, functions as a data pointer. It can hold memory addresses that are referred
to in a number of instructions which use Register Indirect Addressing

2.1.1.2 Special Purpose Registers:

8-BIT REGISTERS

Accumulator:

Used to store 8 bit data (one of the operands) during arithmetic, logic, load and
store operations.
Used to store the result of an operation
Used to store 8 bit data during programmed I/O type of data transfer

Flag Register (Status Register):

It is an 8-bit register, in which five of the bits carry significant information in the form
of flags:
S (sign flag), Z (zero flag), AC (auxiliary carry flag), P (parity flag), and CY
carry flag), as given in the following diagram.

D7 D6 D5 D4 D3 D2 D1 D0

S Z X AC X P X CY

Format of the Flag Register (8085)

Dl, D3, and D5 are not used.

Page 8 of 11 8
TAO1221 Computer Architecture and Organization Tutorial 1

A description of the various flags is given below:

i) The Sign flag (S):

If the least significant seven out of the eight bits of the Accumulator are used for data
and the bit 7 (the most significant bit) is used for the sign of the data in the
Accumulator, then numbers can be used in the range -128 to + 127, After the execution
of an arithmetic or a logic instruction, the sign flag is set ('0' for positive, '1' for
negative), according to the most significant bit of the accumulator contents.

ii) The Zero flag (Z):

If the result obtained after executing an instruction is zero, the zero flag is set (that is, it
becomes 1 '), When the result is non-zero, the zero flag is cleared (that is, it becomes
'0'), If any result has zero for the byte value and also has a Carry, then both the zero
flag and the carry flag are set.

For example consider the following operation in binary.

1011 0011 (B3H)


+ 0100 1101 (4DH)
--------------
Carry 1 0000 0000 (00H)
---------------
Further, the Zero flag is also set if a certain register content becomes 00H (H for
hexadecimal representation), following an increment or decrement operation of that
register.

(iii) The Carry flag (CY):

In arithmetic operations, such as addition and subtraction involving two 8-bit numbers,
there are situations where an addition results in an overflow from the highest order bit
(to a non-existent 9th bit position), or in subtraction, a borrow. In both the examples
shown below, the Carry/borrow flag is set.

Addition (B5H+6CH) Subtraction (B5H-CCH)

1011 0101 (B5H) CCH = 1100 1100


+ 0110 1100 (6CH) 2s complement of CCH = 0011 0100
--------------- B5H = 1011 0101
Carry 1 0010 0001 (21H) ---------------
---------------- 0 1110 1001 (E9H)
----------------
Complement carry/borrow flag =1

Page 9 of 11 9
TAO1221 Computer Architecture and Organization Tutorial 1

(iv) The Auxiliary Carry flag (AC):

This flag is set for an overflow out of bit 3 of the Accumulator in the same way as the
overflow out of bit 7 shown above. This flag is used in BCD (Binary Coded Decimal)
arithmetic.

(v) The Parity flag (P):

Parity is defined by the number of 1-bits present in the Accumulator. If the parity is
even, the parity flag is set (to '1 '); if the parity is odd, the parity flag is cleared (it
becomes '0').

The Accumulator, the flag register, along with a few temporary registers (that are
inaccessible to the programmer) constitute the Arithmetic Logic Unit (ALU). The ALU
performs arithmetic, logic, and rotate operations; the results of these operations could
be placed in the Accumulator, or placed elsewhere through the internal data bus.

16-Bit REGISTERS:

Program Counter (PC):

Program Counter acts as a pointer to the next instruction to be executed, and always
contains the 16-bit address of the memory location of the next instruction.
The PC is updated by the processor and points to the next instruction after the
processor has fetched an instruction (the exact number by which the processor
updates, depends on the nature of the instruction; for example, for one-byte
instructions it updates the PC by one, for three-byte instructions, it updates the PC by
three).

Stack Pointer (SP):

Stack is an area of the read-write-memory (RAM) in which temporary information is


stored on first-in-last-out (FILO) basis. After initialization, an address is assigned in the
RAM area to the first Stack entry position (where the first information is stored);
afterwards, Stack writing instructions fill memory positions in progressively decreasing
addresses.

Stack Pointer register ordinarily holds the address of the last byte written onto the
Stack. This is also called Top of Stack or simply Stack Top. The Stack Pointer is
decremented automatically each time data is pushed onto the Stack and is
incremented automatically when data is popped off the Stack. This decrementing and
incrementing is always by two bytes since all Stack operations involve register pairs.

Page 10 of 11 10
TAO1221 Computer Architecture and Organization Tutorial 1

2.1.2 NON PROGRAMMABLE REGISTERS

INSTRUCTION REGISTER AND DECODER:

These functional entities are not accessible to the programmer. After fetching an
instruction from the memory, the processor loads it in the Instruction Register. This
instruction is decoded by the Decoder and the processor then executes the instruction.

The first step in the execution of an instruction by the CPU is fetching the
instruction, byte by byte, from the memory. The instruction can be of 1 to 3 bytes in the
case of 8085A. The first byte contains the Opcode (which specifies the nature of
operation, and indicates whether the overall instruction is of 1, 2, or 3 bytes). The first
byte retrieved from the memory is transferred through the internal bus of the CPU to
the 8-bit Instruction Register; this in turn becomes available to the Decoder which
decodes it, and the output, gated by timing signals, controls the registers, the data and
address buffers, and the ALU. The state and machine cycle timing signals, which
would depend on the nature of the instruction to be executed, are generated by the
outputs of the Instruction Decoder and the internal clock generator.

Reference:

Ramesh S.Gaonkar (2002). Microprocessor Architecture, Programming, and


Applications with the 8085, 5/E. Prentice Hall.

Page 11 of 11 11

You might also like