You are on page 1of 26

m

BASICS OF THE CENTRAL


PROCESSING UNIT
 brain of any computer system based on the Von Neumann
(Princeton) or Harvard architectures

 has three major parts: ALU, Registers and Control Unit


INSTRUCTION SET
 determines how all software must be structured at the machine level

 Machine Language Instructions

 computer program - a sequence of binary machine language


instructions to be performed in order

 machine language instruction - a collection of bits that are decoded


by logic inside the processor's control unit; each combination of bits
has a unique meaning to the control unit, telling it to perform an
operation on some item of data, move data from one place to
another, input or output data from or into a device, alter the flow of
the program execution or carry out some other tasks
MACHINE LANGUAGE INSTRUCTION
 May be fixed or variable in length

 normally divided into “fields” or group of bits

 sample: taken from IS of DEC's PDP-11 microcontroller

Opcode - stands for operation code


-define operation to be carried out
214 =16 instruction
4 to 16 decoder
FUNCTIONAL CATEGORIES OF
INSTRUCTIONS
 DATA TRANSFER INSTRUCTIONS

 COMPUTATIONAL INSTRUCTIONS

 CONTROL TRANSFER INSTRUCTIONS

 LESS COMMONLY USED

 SYSTEM INSTRUCTIONS

 INSTRUCTIONS THAT CANNOT BE EASILY CATEGORIZED


DATA TRANSFER INSTRUCTIONS
 most common instructions

 programs spend much of their time moving data around to get


values where they are neede and store them back into memory
when they are no longer needed

 from internal reg to another, from main mem to reg or from reg to
mem

 MOVE, LOAD, STORE, XCHG, PUSH, POP


COMPUTATIONAL INSTRUCTIONS
 instructions that “do the work”

 perform manipulations (arithmetic, logical shift or other operations)

 involve passing binary data through the processor's ALU and uses
some combination of logic gates to operate on it, producing a results
in the form of condition codes or flags (positive/negative,
zero/nonzero, carry/nocarry, etc)

 ADD, SUB, MUL, AND, OR, NOT, etc


CONTROL TRANSFER INSTRUCTIONS
 allow the normally sequential flow of execution to be altered, either
conditionally or unconditionally

 when an unconditional transfer of control is encountered, or a conditional


transfer of control succeeds, the next instruction executed is not the
sequential instruction in memory, instead, the processor goes to a new
location in memory and continues executing code at that location

 important as they allow programs to be logically organized in small blocks of


code that can call or be called by other blocks of code

 allow programs to make decisions based on input and the results of prior
calculations

 make it possible for high-level control structures such as IF and SWITCH


statements, loops etc to be implemented at the machine level

 JMP, BNZ, CALL, RET


LESS COMMONLY USED INSTRUCTIONS
 I/O, SYSTEM AND MISCELLANEOUS INSTRUCTIONS

 I/O INSTRUCTIONS

 provide for the transfer of data to and from I/O device interfaces

 only present on machines that employ separate I/O rather than


memory-mapped I/O

 SYSTEM INSTRUCTIONS

 special operations involving management of the processor and its


operating environment

 include such functions as virtual memory management, enabling


and freezing the cache, etc
continuation....
 MISCELLANEOUS INSTRUCTIONS

 EX. NOP - no operation instruction


INSTRUCTION ADDRESSING MODES
 IMMEDIATE ADDRESSING

 DIRECT ADDRESSING

 REGISTER ADDRESSING

 INDIRECT ADDRESSING

 INDEXED ADDRESSING

 PROGRAM COUNTER RELATIVE ADDRESSING


IMMEDIATE ADDRESSING
 embeds an operand into the machine language instruciton itself

 one of the bit fields of the instruction contains the binary value to to be
operated upon. the operand is available immediately because the
operand fetch phase of instruction execution is done concurrently with
the first phase, instruction fetch

 good for quick access to constants that known when the program is
written but not useful for access to variables

 costly
DIRECT ADDRESSING
 sometimes referred to as absolute addressing

 refers to a mode in which the location of the operand is given


explicitly in the instruction

 slower than immediate addressing

 useful for referencing scalar variables but has a limited utility for
strings, arrays and other data structures
REGISTER ADDRESSING
 where operand resides in the CPU register, logically equivalent to
direct addressing because it explicitly specifies the operand's
location

 sometimes called register direct addressing

 advantage: quick access to operand


INDIRECT ADDRESSING
 instead of the instruction containing the operand itself or the
addresss fo the operand, it contains the specification of a pointer to
the operand

 tells the CPU where to find the operand's address

 pointer to the operand can be found in a specified register or in a


specified memory location

 principal advantage: not only the value of the operand can be


changed at run time (from variable to constant), the address of the
operand can also be modified - indirect addressing readily lends
itself to the processing of arrays, strings or any type of data
structure stored in contiguous memory locations.
 by incrementing and decrementing the pointer by the size of an
individual element, one can readily access the next or previous
element in the structure

 disadvantage: determining the operand's address takes time

 CPU must locate the pointer, obtain the contents and use those
contents as the address for reading and writing the operand

 if the pointer is in memory location, the memory must be accessed 3


times, once to read the instruction, second to read the pointer and
third to read or write the data. if the operand is both a source of data
and the destination of the result, a fourth access would be needed
INDEXED ADDRESSING
 known as displacement addressing

 works similarly to RIA but has the additional feature of a second,


constant value embedded in the instruction that is added to the
contents of the pointer register to form effective address of the
operand in memory

 involves encoding the starting address of an array as the constant


displacement and using the register to hold the array index or offset
of the particular element being processed
PROGRAM COUNTER RELATIVE
ADDRESSING
 used for handling control transfers

 the idea is that an offset is added to the current program counter


value to form the destination address. the value is copied back to
the PC, effectively transferring control to that address

 advantage: resulting code is position independent - it can be loaded


anywhere in the memory and it would still execute properly
STACK ADDRESSING
 involves references to a lLIFO data structure in memory

 PUSH and POP instructions facilitate storing items and retrieving


them from a stack in memory. these instructions use a given register
as stack pointer to identify the current “”top of the stack” location in
memory, automatically decrementing or incrementing the pointer as
items are pushed or pop.

 most arch. use stack addressing for data transfers but some
machines have computational instructions that retrieve an operand
and store a result in the memory stack.
Memory register vs. Load-store architecture
Memory Register

 Computations may be performed using data in memory and in


registers.

 Advantage
 Architecture are fairly obvious. First of all, assembly
language coding is simplified.

 Disadvantage
 it makes the control unit design more complex.
Memory register vs. Load-store architecture
Load-Store architecture

o only the data transfer instructions (typically named “load” for reading
data from memory and “store” for writing data to memory) are able
to access variables in memory.

o The advantages anddisadvantages of a load–store architecture are


essentially the converse of those of a memory–register architecture.
CISC and RISC instruction sets
When we discuss computer instruction sets, one of the fundamental
distinctions we make is whether a given machine is a CISC or a RISC.
Typical CISC and RISC architectures and implementations differ in
many ways, but as their name simply, one of the most important
differences between machines based on each of these competing
philosophies is the nature of their instruction sets.
CICS

 Architectures were dominant in the 1960s and 1970s

 Tended to have machine language instruction sets reminiscent of


high-level languages.

 Generally had many different machine instructions

 Usually had a wide variety of addressing modes to specify operands


in memory or registers.
RISC

 Gained favor in the 1980s and 1990s

 Fewer distinct machine language instructions

 Required more effort to develop good, efficient, optimizing compiler


shine language instructions
Datapath
Having looked at factors that are important to the design of a machine’s
instruction set, we now turn our attention to the datapath, the hardware
that is used to carry out the instructions. Regardless of the number or
type of instructions provided or the philosophy underlying the
instruction set design, any CPU needs circuitry to store binary numbers
and perform arithmetic and logical operations on them.

 Register set

 Integer Arithmetic Hardware


Control Unit
 The part of the CPU that puts everything else in motion

 Determines machine instruction is to be executed next, fetches it


from memory, decodes the instruction to find out which one it is, and
activates the proper signals to tell thedatapath (and external
hardware, such as I/O and memory devices) what to do and when to
do it in order to carry out that instruction and save the result.

 The rains of the outfit, the prime mover behind everything that
happens in the processor and the rest of the system.

 its design is a very important aspect of the overall system design


and a key factor in its performance.

You might also like