Mal CH1

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 40

CHAPTER ONE

INTRODUCTION TO MICROPROCESSOR AND ASSEMBLY LANGUAGE


INTRODUCTION


The term „micro‟ means extremely small and „processor ‟ means the thing that
accelerates tasks.

So in general sense the term „microprocessor‟ means an extremely small thing
that can accelerate different tasks as ordered. But the actual definition of
microprocessor is slightly different than this.

A microprocessor is a tiny electronic chip containing transistors found inside a
computer‟s central processing unit and other electronic devices.

Its basic function is to take input, process it and then provide appropriate output.

2
CLASSIFICATION


The very first microprocessor was of 4-bit. Then we got 8-bit, 16-bit,
32-bit,64-bit microprocessors gradually with time and with the
development of modern technology.

We can classify it in many ways but the most commonly and
popularly, microprocessors are classified into two categories, and
they are:-
1. According to working capability
2. According to characteristics
3
CONTINUED...

1. According to working capability:


 Dedicated microprocessors or Microcontroller
 General purpose microprocessors
 Bit-slice processors
2. According to characteristics:
 RISC processors
 CISC processors
 Special processors
4

ACCORDING TO WORKING CAPABILITY

1. DEDICATED MICROPROCESSORS OR MICROCONTROLLER



A dedicated microprocessor or microcontroller is a computer present in a single integrated
circuit which is dedicated to perform one task or one type of tasks.

They are used in situations where limited computing functions are required. It has a dedicated
input device and often has a display for output.

It contains memory, programmable input/output peripherals as well as a processor.

Mostly designed for embedded applications and are heavily used in automatically controlled
electronic devices such as cell-phones, cameras, microwave ovens, washing machines etc.

They are usually 4-bit and designed for low power consumption.

This type of microprocessors is also known as Application specific integrated circuits (ASICs).

5

2. GENERAL PURPOSE MICROPROCESSORS (GPM)


This type of microprocessors is designed for various uses.

They have a wide range of applications, not restricted to one
function. They can be applied to all or most number of members of a
category or group of application.

The microprocessors of computers and Android cell-phones are the
most common and popular example of it.

They can run most of the applications under certain conditions and
with the help of additional programming or applications.
6

3. BIT-SLICE PROCESSORS


Is a microprocessor designed as a module with the primary purpose
of being able to assemble multiple identical such microprocessors
to form a larger processor of some desired word size

Some processors have limited working capacity. They are not useful
in performing many difficult tasks, but they can be useful in making
big processors by adding them one by one.

That work is very expensive and time consuming.

We hardly use this type of microprocessor.
7

MICRO PROCESSORS ACCORDING TO CHARACTERISTICS

1. RISC processors
2. CISC processors
3. Special processors

8

RISC PROCESSORS(Reduced instruction set computer)


This microprocessor was designed to perform a smaller number of types of computer instructions so that it can
operate at a higher speed.

Characteristics of RISC processors are given below.

Relatively few instructions and addressing modes

• Memory access limited to load and store instructions.

• All operations done within the registers of CPU

• Fixed length, easily decoded instruction format

• Single cycle instruction execution i.e. required only one cycle to execute a definite instruction.

• The microprocessor is designed using hardwired control.

• It has several general purpose registers



Some popular RISC processors are: PA-RISC: HP700LC, POWER PC- 601,604,615,620
9

CISC PROCESSORS(Complex Instruction Set Computing)


Contains a large set of computer instructions that range from very simple to very complex and specialized.

The design was intended to compute complex instructions in the most efficient way.

Some characteristics of CISC processors are given below

• Large number of addressing modes and instructions

• Some instructions perform special task

• Variable length instruction format

• Instructions that manipulate control

• Several cycles may be required to execute one instruction.

• The microprocessor is designed using code control.

• It has small number of general purpose registers



Intel‟s processors of x86 Families are the best example of CISC processors.

10

SPECIAL PROCESSORS


There are several other processors, which are useful in special purposes. Some of these processors are
briefly discussed below.
COPROCESSOR

Coprocessor is very similar to general purpose microprocessor. It is designed for a specific function.
But coprocessor can handle its particular function many times faster than the ordinary general
purpose microprocessor. The most well known coprocessor is math-coprocessor.
INPUT/OUTPUT PROCESSOR

This is one of the most important microprocessors. With this processor a large set of I/O device can be
controlled, with minimum CPU involvement.

The I/O processors take care of most of the tasks involved in controlling the terminals. The common
examples of I/O processors are keyboard/mouse controller, graphic display controller etc.

11
continued
TRANSPUTER (TRANSISTOR COMPUTER)

It is a high performance microprocessor designed to facilitate inter process and
inter processor communications and targeted at the efficient exploitation of very
large scale integration.

The most important feature of transputer is it external links, which enables it to
be used as a building block in the construction of low cost, high performance
multiprocessing system.
DSP (DIGITAL SIGNAL PROCESSOR)

This processor is specially designed to handle real world analog signals that have
been converted into digital representation.

Modem function, speech recognition, 2D and 3D graphics acceleration, audio and
video compression etc are the applications of DSP.
12
ORGANIZATION OF A MICROPROCESSOR

So we have mainly the 4 parts:-



Arithmetic/logic unit

Control unit

Registers

Bus unit

13

ARITHMETIC/ LOGIC UNIT (AL U)


The ALU performs the actual computations or processing of data.

ALU is the computer‟s calculator.

The functions of ALU are:-
• Arithmetic operations (addition, subtraction, multiplication and division)
• Logical operations (OR, AND, NOT etc)
• Decision making (ability of comparing two or more numbers or data).

14

CONTROL UNIT


The control unit controls the movement of data and instructions
into and out of the CPU.

It also controls operation of the ALU.

The control unit does not input, output, process, or store
data;rather, it initiates and controls these operations

The control unit also communicates with input devices to begin the
transfer of data or instructions into memory and with output
devices to begin the transfer of results from memory.
15

REGISTERS


The registers are special memory locations for storing temporary information much as a scratch pad
does. The ALU uses the data stored in the registers.

Different types of registers are used. Among them „accumulator register ‟ and „memory address
register‟ or just „address register‟ „instruction register‟ and buffer register are mostly important for
understanding the instruction execution.

Accumulator register stores the data until an instruction is completed. The result of an arithmetic
operation is also stored by it and it happens every time when an arithmetic operation occurs.

The memory address register contains the address where the data is coming from and from which
memory. The memory address register have the binary address where a data is stored somewhere in
the memory.

Instruction register gives the required instruction and the buffer register that stores the data being
transferred to and from the immediate access store.

16

BUS UNIT


Buses carry digital information throughout the chip and computer; and local
memory supports onchip computation.

There are so many bus connections like address bus, control bus, data bus
memory bus etc.

More complex microprocessors often contain other sections–such as sections of
specialized memory, called cache memory, to speed up access to external data-
storage devices.

Microprocessor can‟t work automatically. It requires some data called
instructions to perform a definite task. So while talking about microprocessors,
we need to know their instructions and how they execute them.

17

INSTRUCTION EXECUTION


Instruction is the information or the way with which the required task can be performed.

Instructions for the microprocessor in the storage must be in machine readable form.

These Instructions consist of two parts. The first one is „an operation code ‟ and „one or more
operand.

This is usually known as instruction format.

Instruction execution is one of the major functions of the microprocessor. Instructions are executed
One after one.

Instruction execution is usually performed by two cycles and they are;
Fetch cycle
Execute cycle

18

FETCH CYCLE

• At the beginning of the instruction execution, the central processing unit (CPU) fetches
some data and instruction (program) from its main memory and stores them in its own
internal temporary memory areas called „registers‟.
• The process of fetching data and instruction is possible through a path called bus.
• After that the CPU judges or makes sense of the instruction it has just fetched.
• This process is called „Decode‟. CPU decodes all instructions and prepares the areas within
the microprocessor for the next step.
• The whole process or cycle is known as fetch cycle. [In many
sources we got the „decode‟ process as an individual process.]

19
EXECUTE CYCLE

• This step doesn‟t have many tasks to perform. In this step the decoded
instruction is performed and the result is made.
• Then the result is preserved for further uses in the register.
• So the cycle which actually executes the given instructions is called execute cycle.
• There is another kind cycle for explaining instruction execution, which is nothing
but the combination of the fetch cycle and execute cycle. It is called “Instruction
cycle”.
• It is also known as „fetch-execute cycle‟

20
INSTRUCTION CYCLE

• It is the cycle in which a single instruction is fetched, decoded and executed.

• The first half of the cycle transfers the instructions from the memory to the instruction register (accumulator) and
decodes it. In the second half executes the instruction

• operations of instruction cycle:

• Read an Instruction

• Decode the instruction

• Find the address of operand

• Retrieve an operand

• Perform desired operation

• Find the address of destination

• Store the result into the destination.


21
CLOCK CYCLE

• The speed of a computer microprocessor, or CPU, is determined by the clock cycle,


which is the amount of time between two pulses of an oscillator.
• Generally speaking, the higher number of pulses per second, the faster the computer
processor will be able to process information.
• The clock speed is measured in Hz, typically either megahertz (MHz) or gigahertz
(GHz). Computer microprocessors can execute one or more instructions per clock cycle,
depending on the type of microprocessor.
• Early computer microprocessors and slower microprocessors can only execute one
instruction per clock cycle, but faster, more advanced microprocessors can execute
multiple instructions per clock cycle, processing data more efficiently.

22
INSTRUCTION OF THE MICROPROCESSOR

• There is some definite things required for the execution of an


instruction like the
1. Addressing modes,
2. Instruction set,
3. Operation codes etc

23
ADDRESSING MODES

• The term addressing modes refers to how the operand of an instruction is


specified.
• The addressing mode specifies a rule for interpreting or modifying the address
field of the instruction before the operand is executed.
• The different ways in which the location of an operand is specified in
instruction are referred to as addressing modes.
• The addressing modes are divided into two:
1. Sequential Control Flow Addressing Mode: Focuses on data.
2. Transfer of Control Flow Addressing Mode: Focuses on instruction.
24
Why are Addressing Modes Used?

• Addressing modes shows the location of a required object in the computer.


• The object may be an instruction or data.
• The output of the addressing mode is an effective address [EA].
• The effective address is the actual address of an object.
• Therefore we can say the object is equal to the content of the effective address.
• The addressing mode is implemented in the instruction in two ways:
1. Implicit: The opcode itself specifies the addressing mode used.
2. Explicit: The mode field is used in the instruction format to specify the type of
addressing mode used.

25
Types of Addressing Modes

• The addressing modes are categorized into two types:


1. Memory-based addressing mode and
2. Transfer control addressing mode.
• The memory-based addressing mode is further classified into
different types that are as follows:

26
Memory-Based Addressing Modes

1. Implied Addressing Mode: In this mode, the operands are implicitly


specified in the instruction definition.
2. Immediate Addressing Mode: In this mode, the operand is specified in the
instruction itself, or we can say that an immediate mode instruction has
an operand rather than an address.
3. Direct Register Addressing Mode: In this mode, one of the operands is in
registers, and the other is taken from memory.
4. Direct Addressing Mode: In this mode, the address of the memory location
that holds the operand is included in the instruction. The effective address
is the address part of the instruction.
27
Continued...

5. Indirect Addressing Mode: In this mode, the address field of the


instruction gives the address where the effective address is stored in
memory.
6. Relative Addressing Mode: In this mode, the content of the program
counter is added to the address part of the instruction to calculate
the effective address.
7.Indexed Addressing Mode: In this mode, the effective address will be
calculated as the addition of the content of the index register and
the address part of the instruction.
28
Transfer Of Control Addressing Modes

1. PC Relative Addressing Mode: This addressing mode is used to access the


instruction within the segment. Therefore only one offset address is required.
EA= PC + Address field value
PC= PC + Relative value.
2. Base register Addressing Mode: This addressing mode is used to access the
instructions between two segments. Therefore, a base address, as well as an
offset, is required.
EA= Base register + Address field value.
PC= Base register + Relative value.
29
INSTRUCTION FORMAT

• The set of simple tasks that the processor can perform are called the
instruction set.
• The instruction set is usually composed of two parts: the first part is a
mnemonic called the OPCODE, which tells what the microprocessor is
supposed to do. The second part, which may be composed of one or two
words, contains either data, or addresses where data manipulation is to take
place.
• The actual values of these words depend upon the OPCODE. Usually, the data
which each OPCODE operates on is called operand(s).
• The entire instruction set and its syntactic rules form a grammar that the CPU
can understand and act upon. It is called assembly language.
30
MNEMONIC

• The word MNEMONIC means "A device such as a pattern of letters,


ideas, or associations that assists in remembering something".
• So, it is usually used by assembly language programmers to
remember the "OPERATIONS" a machine can do, like "ADD" and
"MUL" and "MOV" etc.

31
OP CODE (OPERATION CODE)

The OPCODE is part of an instruction word that is interpreted by the


processor as representing the operation to perform, such as read,
write, jump, add etc.
• Many instructions will also have OPERANDS that affect how the
instruction performs, such as saying from where in memory to read
or write, or where to jump.

32
ASSEMBLY LANGUAGE PROGRAMMING

• Assembly language programming is writing machine instructions in mnemonic


form, using an assembler to convert these mnemonics into actual processor
instructions and associated data.
• An assembly language is a low-level programming language for
microprocessors and other programmable devices.
• An assembly language is a type of low-level programming language that is
intended to communicate directly with a computer’s hardware.
• Unlike machine language, which consists of binary and hexadecimal
characters, assembly languages are designed to be readable by humans.

33
FEATURES OF ASSEMBLY LANGUAGE PROGRAMMING

• Assembly language is the most basic programming language available for any
processor.
• Assembly languages generally lack high-level conveniences such as variables
and functions.
• It has the same structures and set of commands as machine language, but it
allows a programmer to use names instead of numbers.
• This language is still useful for programmers when speed is necessary or when
they need to carry out an operation that is not possible in high-level
languages.

34
Some other important features of assembly language

Allows the programmer to use mnemonics when writing source code programs,
like „ADD‟ (addition), „SUB‟ (subtraction), JMP (jump) etc.
• Variables are represented by symbolic names, not as memory locations, like
MOV A, here „A‟ is the variable.
• Symbolic code,
• error checking,
• Changes can be quickly and easily incorporated with a re-assembly,
• Programming aids are included for relocation and expression evaluation.

35
ADVANTAGES OF ASSEMBLY LANGUAGE PROGRAMMING

• Easy to understand and use


• Easy to locate and correct errors
• Easy to modify
• No worry to address.
• Efficient than machine language programming

36
DISADVANTAGES OF ASSEMBLY LANGUAGE PROGRAMMING

• The programmer requires knowledge of the processor architecture


and instruction set.
• Machine language coding
• Many instructions are required to achieve small tasks
• Source programs tend to be large and difficult to follow

37
SOME INSTRUCTIONS SET OF INTEL 8085 MICROPROCESSOR
ACCORDING
TO ASSEMBLY LANGUAGE PROGRAMMING
• ADD r:- add
• ADD M:- Add to Memory
• ADC r:-add with carry
• ADC M:-add with carry to memory
• LDI :- This instruction stands for load immediate and it means load' (put) into a particular
named register a certain value named in the instruction
• LDA a:- load accumulator direct
• SLA: -means shift the contents of a register one place to the left.
• MOV:-means to move data from one place to desired place

38
Continued...

• MOV M A:- means to move the result from memory to register A


• STA:- Store on register(accumulator or others)
• STA a: - store to accumulator.
• JMP- Jump to somewhere
• SUB r :– subtract
• SUB M:- subtract memory
• CY:-carry

39
THE END

40

You might also like