0% found this document useful (0 votes)
105 views146 pages

Unit 1-Basic Structure of Computers

Uploaded by

biharigamers0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views146 pages

Unit 1-Basic Structure of Computers

Uploaded by

biharigamers0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 146

Computer Architecture UNIT - 1

and Organization

© Kalasalingam Academy of Research and Education


About the Course

 When the computer introduced in


1946.

 First successful electronic


computer called “Electronic
Numeric Integrated And
Calculator (ENIAC)”.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


About the Course

 This course explains about the different components


are available in a computer and how all these are
interconnected.

 In this course you will learn about the data Input,


Storing, Processing and Displaying.

 This course also explores about how the Machines are


designed, Built and Operate at the different level.

 Computer accepts Binary (0,1) only

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


About the Course

Switch Mode Power


Secondary Memory –CD-ROM
Supply (SMPS)

Primary Memory -RAM (Random


Processor Access Memory

Secondary Memory -ROM


(Read Only Memory
Motherboard

CMOS Battery
BUS

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Course Outline

Course Description
This course aims to provide a strong foundation
for students to understand computer system
architecture and to apply these in sights and
principles to future computer designs. The course
is structured around the three primary building
blocks of general purpose computing systems:
processors, memories and input/output.

This course includes the organization and


architecture of computer systems hardware,
instruction set architectures, addressing modes,
register transfer notation, processor design and
computer arithmetic, memory systems, hardware
implementations of virtual memory and
input/output control and devices.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Syllabus
Functional Units - Basic Operational
Concepts - Bus Structures – Software-
Performance – Memory Locations and
Addresses – Memory Operations – Unit 1
Instruction and Instruction
Sequencing – Addressing Modes –
Assembly Language – Basic I/O
Operations – Stacks and Queues

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Unit 1 Outline

Lesson 1.
Basic Structure of
Computers

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Course Progress (use before starting new
lesson)

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 1:Functional Units

Topic 2:Basic Operational Concepts

Topic 3:Bus Structures


Topic 4:Software
Topic 5:Performance
Topic 6:Memory Locations and
Addresses
Topic 7:Memory Operations
Topic 8:Instruction and Instruction
Sequencing
Topic 9:Addressing Modes
Topic 10:Assembly Language
Topic 11:Basic I/O Operations
Topic 12:Stacks and Queues First Lesson Summary
We will learn about the functional components of a computer.
How the data are transferred between processor and memory
through bus

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 1: Functional Units of a Computer

A Computer consists of five functionally independent main parts. They


are

1. Input Unit
2. Memory Unit
3. Arithmetic and Logic Unit (ALU)
4. Output Unit
5. Control Unit

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Basic Functional Units of a Computer

I/O Processor

 Input and Output Unit is collectively referred to as Input – Output (I/O) Unit

 Arithmetic and Logic Unit in conjunction with control unit is known as Processor

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Input Unit
 The input unit consists of input devices that are attached to the computer.
These input devices take input from user.
 Following are some of the important input devices which are used in a computer
1. Keyboard

2. Mouse 2
1

3. Joy Stick

4. Light Pens

5. Microphones
5
3 4 5

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Memory Unit
Main Functions:

 It is used to store the programs and data.


 Program -A list of instructions that performs a task.

 Data -Are numbers and encoded characters that are used as operands (the value on
which an operation is to be done) by the instructions.

 Programs and Data can be written into memory or read out from memory under
the control of processor.

 There are two types of storage


1.Primary Storage
2.Secondary Storage
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Primary Storage
 Programs must be stored in primary memory while they are being executed.
 Memory contains a large number of semiconductor storage cells, each capable of storing
one bit of information.
 Semiconductor cells are processed in groups of fixed size called words.
 To provide easy access to any word in memory, a distinct address is associated with each
word location. But when the memory is accessed, only one word of data is read or written.
 Word Length-Number of bits in each word.
 Typical word lengths range from 16 to 64 bits.
 Capacity of the memory is one factor that characterizes the size of a computer.
Ex. Small Machines have only a few tens of million of words
 Medium and Large machines have may tens or hundreds of millions of words will be there

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Primary Storage
Contd…..
Random Access Memory (RAM):
Memory in which any location can be reached in a short and fixed amount of
time after specifying its addresses.
Memory Access Time:
The time required to access one word from memory. This time is fixed,
independent of the location of the word being accessed. It typically ranges from
a few nanoseconds (ns) to about 100 ns for modern RAM units.
Caches:
The small, fast RAM units are called caches.
Main Drawback of Primary Storage: Expensive

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Secondary Storage
 Secondary Storage is used when large amounts of data and many
programs have to be stored.

 Wide Selection of Secondary Storage Devices available are


1) Magnetic Disks and Tapes
2) Optical Disks (CD-ROMS)

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Comparison –Primary & Secondary Storage

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Arithmetic and Logic Unit (ALU)
 The ALU performs mathematical calculations and takes logical decisions.

 Arithmetic calculations include addition, subtraction, multiplication and


division.

 Logical decisions involve comparison of two data to see which one is larger
or smaller or equal.

 Most of the computer operations are executed in ALU of the Processor.


Ex: Suppose two numbers (Operands) located in the memory are to be
added.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Arithmetic and Logic Unit (ALU)
 First operands are brought into the processor and actual addition is
carried out by ALU.

 The resulting sum may then be stored in the memory or retained in the
processor for immediate use.

 When operands are brought into processor, they are stored in high speed
storage elements-Registers. Each register can store one word of data.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Output Unit
 The output unit consists of output devices that are attached with the
computer.

 Examples of output devices include


1. Printers
2. Monitors
3. Speakers
4. Projector
5. Plotter

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Control Unit
 The memory, ALU, input and output units store and process information
and perform input and output operations.

 The operations of all units must be coordinated in some way.

 This is the task of control unit.

 Control unit is the nerve center that sends control signals to other units
and senses their status.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Control Unit
 Operations of a computer

All these activities are directed by control unit

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary
 Computer has many different units/devices.

 Functions of each unit/device is different.

 Units/devices gets the data, process the data and stores/displays the data.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 2: Basic Operational Concepts
 To perform a given task, an appropriate program consist of a list of
instructions is stored in the memory.
 Then individual instructions are brought from memory into the processor
which executes the specified operations.
 A typical instruction may be
Add LOCA, RO
 This instruction adds the operand at memory location LOCA to the operand
in a register in the processor R0 and places the resulting sum in R0.
 The original contents of location LOCA are preserved whereas the content
of Register R0 are overwritten.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Add LOCA, R0 instruction requires the performance of several steps.
1) The instruction is fetched from memory into the processor.
2) Next the operand at LOCA is fetched and added to the contents of R0.
3) Finally the resulting sum is stored in register R0.

 Add Instruction combines memory access operation with an ALU


Operation.

 In most modern computers, memory access operation and ALU operations


are performed by separate instructions for performance reasons.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Add LOCA,R0 can be realized by the two instruction sequence
Load LOCA,R0 Instruction transfers the
contents of memory
Add R1,R0 location LOCA into
processor register R0

Instruction adds the R1 and


R0 Register contents and
places the sum value in to
R0.
 In such case also, the former contents of register R1 and R0 get destroyed,
whereas the original contents of memory location LOCA are preserved.
 Transfers between the memory and processor register are started by sending
the address of the memory location to be accessed to the memory unit and
issuing the appropriate control signals. Then the data are transferred to or from
the memory.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Connection Between Processor and
Memory
Memory

Memory Address Memory Data


Register Register
Control Unit
(MAR) (MDR)
(CU)
R0
Processor Program Counter
(PC) R1
Arithmetic
and Logic
Instruction Register Unit
Rn-1 (ALU)
(IR)
General Purpose
Registers
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Contd….

Instruction Register (IR)


 Holds the instruction that is currently being executed.

 Output of this register is available to the control unit which generate timing
signals that control the various processing elements involved in executing the
instruction.

Program Counter (PC)


 Keep tracks of the execution of a program.

 Contain the memory address of the next instruction to be fetched and executed.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….

General Purpose Registers (R0 to Rn-1)


 Holds either data or an address

Memory Address Register (MAR)


 Holds the address of the memory location to be accessed

Memory Data Register (MDR)


 Contains the data to be written into or read out of the addressed
location
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Some Typical Operating Steps
 Programs reside in the memory are get there through input unit.
 Execution of the program starts when PC is set to point to the first instruction
of the program. Content of PC is transferred to MAR and a read control signal is
sent to memory.
 After the time required to access the memory elapes, the addressed word (First
instruction of the program) is read out of the memory and loaded in to MDR.
 Next the content of MDR is transferred to IR. At this point, the instruction is
ready to be executed.
 If the instruction involves an operation to be performed by the ALU, it is
necessary to obtain the required operands.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 If an operand resides in the memory (it could also be in general purpose
registers in the processor), it has to be fetched by sending its address to MAR
and initiating read cycle.
 After the time required to access the memory elapse, the addressed
word(operands) is read out of the memory and loaded in to MDR and then to
ALU. After one or more operands are fetched in this way, ALU can perform the
desired operation.
 If the resulting sum is to be stored in memory, then the result is then sent to
MDR and address of the location where the result is to be stored is sent to the
MAR and a write cycle is initiated.
 In addition to transferring data between memory and the processor, the
computer accepts data from input devices and sends data to output devices.
Some machine have instructions with the ability to handle I/O transfers.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Summary
 Processor used to process (Addition, Subtraction, Multiplication & Division)
the data.

 Processor has different temporary memory is called registers.

 Each register is used for different purpose.

 Data should be in binary only ( 0 or 1 )

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 3: Bus Structure
 A group of lines that serve as a connecting path for several
devices is called a bus.
 To do the operation, functional parts of computers must be
connected in some organized ways.
 To achieve a reasonable speed of operation, a computer must be
organized so that all its units can handle one full word of data at
a given time.
 When a word of data is transferred between units, all its bits are
transferred in parallel (i.e all bits are transferred simultaneously
over many wires or lines, one bit per line).
 In addition to lines that carry the data, bus must have lines for
address and control purposes.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Single Bus
 The simplest way to interconnect functional units is to use single bus.

Input Output Memory Processor

BUS

 All units can be connected using bus.


 Single bus can be used for only one transfer at a time.
 Only two units can actively use the single bus at any given time.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Single Bus
 Advantages of Single Bus Structure:
1) Low Cost
2) Flexibility for attaching Peripheral Devices

 Systems that contain multiple buses achieve concurrency in operations by


allowing two or more transfers to be carried out at the same time.
 This leads to better performance but at an increased cost.
 The devices connected to the bus vary in their speed of operation.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…

 Memory and processor units are fast unit.

 Input and Output units are slow units

 An efficient transfer mechanism can be used to smooth out the timing


differences among processor, memory and Input Output Unit.

 A common approach is to include buffer registers with the devices to hold the
information during transfers.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 Consider the transfer of an character from processor to printer:
1. The processor sends the character over the bus to the printer buffer.
2. Once the buffer is loaded, the printer can start printing and is not available for
further transfers until this process is completed.

0 , 1 , 0 , 0 , 1 , ……..

 The bus and the processor are no longer needed and can be released for
other activity.
 Thus Buffer Registers smooth out the timing differences among
processors, memories and I/O Devices.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 Bus is used for connecting the different devices with low cost.

 Bus is used to transfer the data between different devices which are
connected in it.

 Bus is known as transfer medium.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 4: Software
Definition:
 Is a collection of computer instructions that tell the computer how
to work.

Two Types of Software:


1)Application Software
2)System Software
Vs

Application Software System Software

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
1) Application Software
 Is a program that is designed for end users and usually written in high
level language such as C, C++, JAVA and FORTRAN.

 The most common application software programs are used by millions


every day and include:
I. Microsoft Suite of Products (Office, Excel, Word, PowerPoint, Outlook, etc.)
II. Internet browsers like Firefox and Chrome

 In-order for a user to enter and run the application software, the computer
must contain system software in its memory.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
2) System Software:
 System Software is a collection of programs that are executed as needed
to perform functions such as
I. Receiving and Interpreting user commands.
II. Entering and editing application programs and storing them as files in secondary storage
devices.
III. Managing the storage and retrieval of files in secondary storage devices.
IV. Running standard application programs such as word processors, spread sheets or games
with data supplied by the user.
V. Controlling I/O units to receiving input information and produce output results.
VI. Translating programs from source form prepared by the user into object form consist of
machine instructions.
VII. Linking and running user written application programs with existing standard library
routines.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Contd…
 Application Programs are usually written in a high level programming
language such as C, C++, JAVA or FORTRAN in which programmer
specifies mathematical or text processing operations.
 These operations are described in a format that is independent of the
particular computer.
 A system software program called a compiler
 Compiler translates the high level language program into suitable
machine level language program.
 Another important system program that all programmers use is Text
Editor.
 Text Editor is mainly used for entering and editing application programs.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Key System Software Component -
Operating System
 OS-Is a large program used to control the interaction among various
computer units as they execute application programs.
 OS-is system software that manages computer hardware, computer
software and provides common services for computer programs.
 OS routines perform the tasks required to assign computer resources to
individual application programs.
 Tasks include
 Assigning memory and magnetic disk space to individual application
programs.
 Moving data between memory and disk units.
 Handling I/O Operations.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Understanding the Concept of OS
 Steps involved in running one application Program:
 Consider a System with one processor, one disk and one printer.

Printer

Disk

OS
routine

Program

t1
t1 t2 t3 t4 t5 Time

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 Assume that application program has been compiled from a high level
language to machine language form and stored on the disk.
 During the time period t0 to t1, an OS routine initiates loading the application
program from disk to memory, waits until the transfer is completed and then
passes execution control back to the application program.
 During the time period t2 to t3 also, an OS routine initiates loading the
application program from disk to memory, waits until the transfer is completed
and then passes execution control back to the application program.
 When the operating system transfers the data file from disk, it prints the result
during the time period t4 to t5.
 At time t5, the operating system may load and execute another application
program.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Multiprogramming or Multitasking
 Disk and Processor are idle during most of the time period t 4 to t5.

 Printer is idle during time period t0 to t1 and t2 to t3.

 During t0 to t1 and t2 to t3, operating system can arrange to print the previous
programs result.
 During t4 to t5, the operating system can load the next program to be executed
in the memory from the disk.
 Operating system manages the concurrent execution of several application
programs to make the best possible use of computer resources.
 This pattern of concurrent execution is called Multiprogramming or
Multitasking.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 Software is for System and Applications.

 It enables the communication between different hardware.

 Software used to enable the multitasking.

 It also used to control the hardware which are connected in that particular
system.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 5: Performance
 The most important measure of the performance of a computer is how
quickly it can execute programs.

 Three factors affect performance:


1. Hardware design
2. Instruction set
3. Compiler

 For best performance, these three factors must be coordinated in a


coordinated way.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 5: Performance

 The total time required to execute the program is from t0 to t5.

 This elapsed time is a measure of the performance of the entire computer


system.

 It is affected by speed of the processor, disk and the printer (i.e elapsed time for
the execution of a program depends on all units in a computer system).

 Processor time depends only on the hardware involved in the execution


of individual machine instructions.

 The hardware comprise of processor and main memory connected by a


bus.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.1 - The Processor Cache

Cache
memory

Bus

 At the start of execution, all program instructions and data are stored in the
main memory.
 As execution proceeds, instructions are fetched one by one over the bus into
processor and a copy is placed in the cache.
 Later if the same instruction or data item is needed second time, it is read
directly from the cache.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
5.2 - Processor Clock
 Processor circuits are controlled by a timing signal called clock.

 The clock defines regular time intervals called clock cycles.


 To execute a machine instruction, the processor divides the action into
sequence of basic steps, each step can be completed in one clock cycle.
 The length P of one clock cycle is an important parameter that affects
processor performance.
 Clock Rate R=1/P

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.2 - Processor Clock
 Cycles per second (Hz)

 Processors used in todays PC and workstations have clock rates ranging


from few hundred million to over a billion cycles per second.

 The term
 Million is denoted by  Mega(M)
 Billion is denoted by  Giga (G).
 500 million cycles per second  500 Megahertz (Mhz)
 1250 million cycles per second  1250 Gigahertz (Ghz)

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.3 - Basic Performance Equation

Basic Performance
Calculation Equation

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.3 - Basic Performance Equation
 Each machine instructions takes one or more cycle time for execution.
This time is required to perform various steps needed to execute machine
instruction.

 Thus Program execution time is denoted by

 To achieve high performance, the computer designer must seek ways


to reduce the value of T,
Which means reducing N and S and increasing R.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.4 -Pipelining and Superscalar
Operation
 Instructions are executed one after the another. Hence the value of S is the
total number of basic steps or clock cycles required to execute an instruction.

 A substantial improvement in performance can be achieved by overlapping the


execution of successive instructions using a technique called pipelining.

 Consider the instruction ADD R1, R2, R3

 Adds the contents of registers R1 & R2 and places the sum into R3.

 The contents of R1 and R2 are first transferred to the inputs of the ALU. After
the add operation is performed, the sum is transferred to R3.

 The processor can read the next instruction from the memory while the
addition operation is being performed.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Then if that instruction also uses the ALU, its operands can be
transferred to the ALU inputs at the same time that the result of
Add instruction is being transferred to R3.
 A higher degree of concurrency can be achieved if multiple instruction
pipelines are implemented in the processor.
 This means that multiple functional units are used, creating parallel
paths through which different instructions can be executed in parallel.
 With such an arrangement, it becomes possible to start the execution of
several instructions in every clock cycle.
 This mode of operation is called superscalar operation.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.5 - Clock Rate

There are two possibilities for increasing the clock rate R.


1. Improving the IC technology makes logic circuit faster which reduces
the time needed to complete a basic step.
 This allows the clock period P to be reduced and clock rate R to be increased.

2. Reducing the amount of processing done in one basic step also makes it
possible to reduce the clock period P.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.6 – Instruction Set

There are two different sets.


1. CISC – Complex Instruction Set Computers.
 Complex instructions involve a large number of steps.

2. RISC – Reduced Instruction Set Computers.


 Simple instructions require a small number of basic steps to execute.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


5.7 – Compiler
 A compiler translates a High-level language program into a sequence of
machine instructions.
 To reduce N in performance of a computer, we need to have a suitable
machine instructions set.
 High quality compiler must be closed linked to processor architecture

 Compiler and Processor are designed at the same time.

X=A+B Compiler 01101110


High-level language Machine Instructions

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 To calculate the system efficiency, performance is used in different ways.

 By calculating the Performance using different parameters, a system may


be defined.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 6: Memory Locations and
Addresses
 Number and Characters operands, as well as instructions are n bits
stored in the memory of a computer.
 Consider how the memory is organized
 Memory consist of millions of storage cells, each of which can
store a bit of information (0 or 1). A single bit represent small
amount of information, bits are rarely handled individually.
 The usual approach is to deal bit in groups of fixed size. For
this purpose, memory is organized so that a group of n bits
can be stored or retrieved in a single basic operation.
 Each group of n bits is referred to as a word of
Information(Word) and number of bits in a word is known as
Word Length(Modern computers have word lengths range
from 16 to 64 bits).
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Memory Words
n bits

First word
Second word
Third word

ith word

Last word

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 In-order to store or retrieve a single bit of information, byte or word in to
memory or from memory, memory addresses for each item location is required.
 Use numbers from 0 to 2^k-1 as addresses of successive location in the memory
Ex.
1) 24 bit address can create an address space of 2^24 (i.e 16,777,216 locations)
--- written as 16M (16 mega)
2) 32 bit address create an address space of 2^32 (i.e 4294967296 locations)
--- written as 4G (4 giga)
 Other Conventions are also commonly used
1) K (Kilo) for the number 2^10 (1024 Locations)
2) T (Tera) for the number 2^40 (1.0995116e + 12 Locations)

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Byte Addressability
 Byte - Group of 8 bits

 Word - Group of n bits --- ranges from 16 to 64 bits.

 Practical Problem:

It is impossible to assign different address for individual bit in the


memory.
 Most Practical Assignment used in most modern Computers - Byte
Addressable Memory

 Successive address refers to successive byte location in the memory


(i.e. byte locations have address 0, 1, 2, 3 ….).

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Big Endian and Little Endian
Assignments
 There are two ways that byte addresses can be assigned across words.
Word Word
address Byte Address address Byte Address

0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4

2k–4 2k–4 2k–3 2k–2 2k–1 2k–4 2k–1 2k–2 2k–3 2k–4
Big-endian assignment Little-endian assignment

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…..
 Big Endian Assignment
 Is used when lower byte addresses are used for More Significant Bytes of
the word.
 Little Endian Assignment
 Is used when lower byte addresses are used for the Less Significant Bytes
of the word.
 Both Big Endian and Little Endian are used in commercial
machines
 In both cases, byte addresses 0, 4, 8…. are taken as the addresses of
successive words in memory and are the addresses used when specifying
read and write operations for word.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Word Alignment
 Words are said to be aligned in memory if they begin at a byte address
that is a multiple of the number of bytes in a word.
 If the word length is 16 bit (2 Byte), aligned words begin at byte address
0, 2, 4, 6, 8 …..
 If the word length is 32 bit (4 Byte), aligned words begin at byte address
0, 4, 8, 12, 16 …..
 If the word length is 64 bit (8 Byte), aligned words begin at byte address
0, 8, 16, 32 …..
 If words begin at arbitrary byte address, then words are said to
have unaligned addresses.
 Most machine use only aligned addresses, some computer use unaligned
word addresses.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Accessing Numbers, Characters and
Character Strings
 Number usually occupies one word.

 It can be accessed in the memory by specifying its word address.

 Individual Characters can be accessed in the memory by specifying its byte


address.

 Character String-Sequence of character stored in or processed by


computer

 Beginning of the string is indicated by giving the byte address containing its first
character.

 Successive byte locations contain successive characters of the string.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 All the data will be stored in memory only

 Data will store in memory as binary only

 In memory data will be stored by assigning memory locations

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 7: Memory Operations
 Both program instructions and data operands are stored in the memory.

 To execute an instruction, the processor control circuits must cause the word
containing the instructions to be transferred from the memory to the processor.

 Operands and results must also be moved between memory and the processor.

 Thus, two basic operations involving the memory are needed


1) Load or Read or Fetch
2) Store or Write

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Load Operation
 Transfers a copy of the contents of a specific memory location to the
processor.

 The memory contents remain unchanged.

 To start a load operation, the processor sends the address of the desired
locations to the memory and requests that its contents be read.

 The memory reads the data stored at that address and sends them to the
processor.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Store Operation
 Transfers an item of information from the processor to a specific memory
location, destroying the former contents of that location.

 The processor sends the address of the desired location to the memory,
together with the data to be written into that location.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 8: Instruction and Instruction

Sequencing
 The task carried out by a computer program consist of sequence of small steps.

 Computer must have instructions capable of performing four types of


operations.

1) Data Transfers between Memory and Processor

2) Arithmetic and Logic Operations on data

3) Program Sequencing and Control

4) I/O Transfers

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 Data Transfer - Transfer of Information from one location to another
location.
 Possible locations are memory, processor registers and I/O Subsystem.
 We identify a location by symbolic name
1) Names for the addresses of memory locations may be LOC, PLACE, A, VAR2
2) Names for processor register may be R0, R5

3) Names of I/O Register names may be DATAIN, OUTSTATUS


 I/O Subsystem: Provides an efficient communication between central
system and outside environment.
 There are four registers - Status, Control, Data in and Data Out.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Register and Assembly Transfer
Notation
 Register Transfer Notation: - Transfer the information from one location
in the computer to another location
 Means data transfer flow at the register level of an architecture.

Ex: 1) R1 [LOC]
2) R3 [R1] + [R2]
 Right hand side of an RTN Expression always denote a value, Left hand
side of an expression is the name of the location where the value is to be
placed.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Register and Assembly Transfer
Notation
 Assembly Language Notation:
 To represent machine instructions and programs, assembly language
format is used.

Ex: 1) Move LOC, R1


2) Add R1, R2, R3

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Basic Instruction Types
 Consider a Statement
C=A+B
 Assumption: This action is to be accomplished by a single machine
instruction. Furthermore, assume that instruction contain memory address
of the three operands. This three address instruction can be
represented as

Add A,B,C
 This instruction has the format
Operation, Source1, Source2, Destination

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Problems in Three Address Instruction
 Address of one operand = 32 bits
 Here three operands (A,B,C) are there. In addition to that, opcode (Add) is
also there.
 Therefore Instruction Length = 3 * 32 + 4 = 100 bits.
 So if k bits are needed to specify the memory address of one operand,
then the encoded form of three address instruction must contain 3k bits.
 In addition to this, some bits are needed to denote Add Instruction.
 Therefore for a modern processor, 3 address instruction is too large to fit in
one word.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Alternative Approach
 Is to use a sequence of simpler instructions to perform the same
task(C=A+B),ie with each instruction having only one or two operands.
 Two address instruction of the form
Operation Source, Destination
 Sequence of two address instruction for performing C=A+B
Add A,B
Mov B,C
 Two address instruction also will not fit into one word.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Alternative Approach
 Is to have machine instruction that specify only one memory operand.
 In such a case, when a second operand is needed, accumulator may be
used.
 Early computer were designed around a single accumulator structure.
Ex: Add A
 Consider one address instruction
Load A Store A
 Using only one address instruction, operation C=A+B can be performed by
executing sequence of instructions.
Load A, Add B, Store C
 One address instruction also will not fit into one word.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Zero Address Instruction

Is an instruction in which location of all operands are defined implicitly.

Such instructions are found in machines that store the operands in a


structure called pushdown stack.

In this case, this instruction is known as zero address instruction.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Solution
 Most modern computers have a number of general purpose registers-
typically 8 to 32 and even considerably more in some cases.
 Access to data in general purpose register is much faster than to data
stored in memory locations because registers are inside the processor.
 Number of registers is relatively small, only a few bits are needed to
specify which register takes part in an operation.
Ex: for 32 registers ,only 5 bits are needed.
 This is much less than the number of bits needed to give the address of a
location in the memory.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


General Purpose Registers(Ri)
Load A, Ri
Store Ri, A
Add A, Ri
Here Register Ri performs the function of the accumulator. In all cases, one
memory address is directly specified in an instruction, the instruction may
not fit into one word.
Therefore, in most modern processors, computations can be performed
directly only on data held in processor registers.
Consider an Instruction
Add Ri, Rj Add Ri, Rj, Rk
Here only register names are contained in the instruction, will normally fit
into one word.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Contd….
 Data transferred between different location is achieved with the
instruction
Move Source, Destination
 i.e copy the content of source into destination.
Move A, Ri  Is same as Load A
Move Ri, A  Is same as Store A
 C=A+B can be performed by the following instruction sequence
Move A, Ri
Move B, Rj
Add Ri, Rj
Move Rj, C
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Instruction Execution and Straight Line
Sequencing
Consider a task C=A+B
Assumptions:
In a processor, one operand may be in the memory and other operand must be in
processor register. An instruction sequence required for performing the task C=A+B is
Move A,R0
Add B,R0
Move R0,C
Word Length of the computer is 32 bits and memory is byte addressable. The three
instructions of the program are in successive word locations, starting at location i.
Second and third instruction start at addresses i+4,i+8.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


A Program of C=A+B
Address Contents
Execution
i Move A, R0
begins here 3 – instruction
i+4 Move B, R0
program segment
i+8 Move R0, C

B Data for the program

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Execution of a Program
 Execution of the program begins when the PC is set to point to the first
instruction of the program.
 In this case, address of the first instruction is (i).
 Then the processor control circuits use the information present in PC for
fetching and executing the instructions, one at a time, in the order of
increasing addresses.
 This is called straight line sequencing.
 During execution of each instruction, PC is incremented by 4 to point to
the next instruction.
 Thus after the Move instruction at location i+8 is executed, PC contains
the value i+12, which is the address of the first instruction of the next
program segment.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Execution of a Program
 Executing a given instruction is a two phase procedure.
1) First Phase-Instruction Fetch - The instruction is fetched from memory
locations whose address is in PC and instruction is placed in Instruction Register.
2) Second Phase-Instruction Execute - The instruction in IR Register is first
examined to determine which operation is to be performed and then carried out
by the processor.
This involves fetching operands from memory or from processor registers, perform
arithmetic and logical operation and then store the result in the destination
location.
 When the execute phase of an instruction is completed, PC contains the
address of the next instruction, and a new instruction fetch phase can
begin.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Branching
i Move NUM 1, R0
i+4 Add NUM 2, R0
A Straight Line i+8 Add NUM 3, R0
Program for
adding n numbers

i + 4n - 4 Add NUMn, R0
i + 4n Move NUMn, R0
 The addresses of the memory locations
containing the n numbers are symbolically
given as NUM1, Num2 …… Num n and a SUM
separate add instruction is used to add each NUM 1
number to the contents of register R0. NUM 2

 After all the numbers have been added, the


result is placed in memory location SUM. NUM n

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Using a loop to adding n numbers
Move N, R1
Clear R0  Instead of using a long list of Add instructions,
Determine address of “Next” it is possible to place a single Add instruction
number and add “Next”
Program number to R0 in a program loop.
Loop LOOP Decrease R1
Branch > 0 LOOP  The loop is a straight line sequence of
Move R0, SUM instructions executed as many times as
needed.
SUM
N n  It starts at location LOOP and ends at the
NUM 1 instruction Branch>0.
NUM 2
 During each pass through this loop, the
address of the next list entry is determined
and that entry is fetched and added to R0.
NUM n

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Condition Codes
 Processor keeps track of information about the results of various operations.
 This is accomplished by recording the required information in individual bits
called Condition codes.
 Individual condition codes are set to 1 or cleared to 0.
 Condition code flags are grouped together in a special purpose register
called condition code register or status register.
 Four Commonly used flags are
1) N (Negative) - Set to 1 if the result is negative otherwise set to zero
2) Z (Zero) - Set to 1 if the result is zero, otherwise zero.
3) V (Overflow) - Set to 1 if arithmetic overflow occurs, otherwise zero
4) C (Carry) - Set to 1 if a carry out results from the operation otherwise zero.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary
 All the commands will be passed through Instruction only.

 Operating System (OS) may be 32 bits or 64 bits.

 Word length is depends on the bits used in OS.

 Numbers of instructions depends on the programmer.

 If total number of instructions are less, then execution time will be less
and branching/loop may be used to reduce the execution time .

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 9: Addressing Modes
 The different way in which location of an operand is specified in an
instruction is known as addressing modes.
 In general, Program operates on data that reside in the computer memory.
 Data can be organized in variety of ways (i.e programmers use data
structure to represent the data).
Is a particular way of organizing data in a
computer so that it can be used
effectively.

Ex: List, Linked List, Stack and Queue

 Programs are usually written in high level language which enables the
programmer to use constants, variables, pointers and arrays.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Implementation of Variables and
Constants
 Variables and Constants are the simplest data types and are found in
almost every computer program.
 Variable gives data to the computer for processing.= sign is used to
assign a value to variables.
Ex. A=3 (The operand to the left of the = sign is known as name of the variable
and the operand to the right of the = sign is known as value assigned to the
variable.
 Constant is a type of variable whose value cannot be changed.
 In assembly language, a variable is represented by allocating a register or
memory location to hold its value.
 User can access an operand by specifying the name of the register or
address of the memory location where the operand is located.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 To access variables, two modes are there.
1) Register Mode
2) Absolute Mode or Direct Mode

Register Mode: The operand is the contents of a processor register, the


name of the register is given in the instruction.
Ex: Add R1,R0

Absolute or Direct Mode: The operand is in memory location, the address


of the memory location is given in the instruction directly.
Ex: Load 8008

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 The following instruction uses both these modes.

Move LOC, R2

 Operand is in memory location LOC, address of the memory location is


given in the instruction explicitly - Direct Mode

 Operand is the contents of a processor register, name of the processor


register is given in the instruction explicitly - Register Mode

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
Representation of Constants:
 Immediate Mode: The operand is given explicitly in the instruction itself.

Move 200, R0
 This instruction places the value 200 in register R0 immediately.
 The Immediate mode is only used to specify the value of a source operand.
 Immediate operand is represented by placing the sharp sign(#) infront of the
value.
Move #200, R0
 Constant Values are used frequently in high level language.

A=B+6 Where 6 is constant, A & B are variables

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Indirection and Pointers
 Indirection:
 The instruction does not give the operand or its address explicitly.
 Instead it provides information from which the memory address of the operand
can be determined. This address is known as Effective Address (EA)
 In simple, Effective Address means the address where the operand is actually
found.

 Indirect Mode:
 The effective address of the operand is the contents of register or memory
locations whose address appears in the instruction.
 Indirection is denoted by placing the name of the register or memory address
given in the instruction in parentheses.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Indirect Addressing
 Indirect addressing can possible through General Purpose Register or
through a Memory Location.

Through a register Through memory location

Add (R1), R0 Add (A), R0

Main
memory

B Operand A B

R1 B Register B Operand

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Indirect Addressing –Through a General
Purpose Register

 To execute Add Instruction, Processor uses the value B which is in register


R1,as the effective address of the operand.

 Then processor requests a read operation from the memory to read the
content of location B.

 The value read is the desired operand is added to the content of register
R0.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Indirect Addressing-Through a Memory
Location

 Here processor first read the contents of memory location A (i.e B, effective
address of the operand).

 Processor request a read operation from the memory to read the contents of
memory location B.

 The value read is the desired operand, is added to the content of register R0.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Pointer
 The register or memory location that contains the address of an operand is called
a pointer.
 Use of Indirect Addressing mode in the Program

Address Contents
Move N, R1
Move #NUM1, R2 Initialization
Clear R0
Add (R2), R0
Add #4, R2
LOOP Decrement R1
Branch > 0 LOOP
Move R0, SUM

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Indirect Addressing can be used to access successive numbers in the list.
 Register R2 is used as a pointer to the numbers in the list and the
operands are accessed indirectly through R2.
 N-Number of entries in the list n is stored in memory location N and is
loaded into register R1.
 R1 is used as a counter to determine the number of times the loop is
executed.
 NUM1 is the address of the first number in the list immediately moved into
R2.
 Clear the content of R0 to zero.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Add (R2), R0 - Fetches the operand at location NUM1 and add it to content
present in R0.
 Add #4, R2 - add 4 to the content of the pointer, so that it will contain the
address value NUM2.
 Decrement R1-Reduce the content of R1 by 1 each time.
 Execution of the loop continues as long as the result of decrement
operation is greater than zero.
 Branch >0 Loop-Conditional Branch Instruction
 Branch is an instruction that can cause a computer to begin executing a
different instruction sequence and loads a new value into Program
Counter.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Conditional Branch Instruction causes a branch only if a specified condition is
satisfied.

 If the condition is not satisfied, PC gets incremented and next condition in sequential
order is fetched and executed.

 This means that loop is repeated as long as there are entries in the list that are yet to be
added to R0.

 At the end of the nth pass through the loop, decrement instruction produces a value of 0
and hence branching does not occur. Instead Move instruction is fetched and executed.

 Move R0, SUM - Content present in R0 is moved into memory location SUM.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Indexing and Arrays
Index Mode:
 The effective address of the operand is generated by adding a constant
value to a content of a register.
 Is represented symbolically as X(Ri). Where X is a constant value contained in
the instruction
 Ri –name of the register involved. Register may be either a special purpose
register or it may be one of a set of general purpose register in the
processor. In both cases, it is referred to as index register.
Effective Address(EA)=X+[Ri]
 There are two ways of using Index Mode

1) Case I - Offset is given as a constant


2) Case II - Offset is in the index register
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Case I - Offset is given as a constant

 Here, the index register R1


Add 20(R1), R2
contains the address of a memory
location and the value X defines
an offset from this address where
the operand is found.
1000 1000 R1

Offset = 20

1020 Operand

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Case II - Offset is in the Index Register

 The constant X corresponds to


a memory address and the Add 1000(R1), R2

content of index register define


the offset to the operand.

1000 20 R1

Offset = 20

1020 Operand

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Consider a simple example involving a
list of test scores for students taking a
given course
Word Length of the Computer = 32 bits N n
A four word memory block comprises a record that LIST Student ID
stores the relevant information for each student. LIST + 4 Test 1
Student 1
LIST + 8 Test 2
Each record consist of student identification number LIST + 12 Test 3

(ID) followed by scores the students earned on three LIST + 16 Student ID

tests. Test 1
Student 2
Test 2
Represents a 2D Array having n rows and n columns. Test 3
.

Each row contain the entries for one student and the .
.
columns gives the student ID and Test Scores.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Indexed Addressing used in accessing
test scores in the list
Move #LIST, R1
Clear R1
 This is the program for computing the sum of all
scores obtained on each tests and store these Clear R2
sums in memory locations SUM1, SUM2, SUM3. Clear R3

 Indexing Addressing Mode is used in the body Move N, R4

of the loop for accessing each test scores in a Add 4(R0), R1


students record. Add 8(R0), R2

 Here register R0 is used as index register. Add 12(R0), R3


Add #16, R0
 Initially R0 is set to point to ID location of the
first student record. Thus it contains the Decrement R4
LOOP
address LIST. Branch > 0 LOOP

 N- Number of students in the list Move R1, SUM1


Move R2, SUM2
Move R3, SUM3

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Another Version of Index Mode

 Uses two registers(Ri, Rj) plus a constant.


X (Ri, Rj)

 Here effective address is the sum of the content of X and the contents of
registers Ri and Rj.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Relative Addressing

Relative Mode:

 The effective address of the operand is determined by adding a constant


value to the content of program counter.
X ( PC )

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Additional Modes
 Auto increment and Auto decrement modes are useful for accessing data
items in successive locations in the memory.
Autoincrement Mode:
 Is denoted by putting the specified register in parentheses followed by
plus sign.
(Ri)+
 The effective address of the operand is the contents of register specified in
the instruction. After accessing the operand, the contents of the register
are automatically incremented to point to the next item in a list.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
Autodecrement Mode:
Is denoted by putting the specified register in parentheses, preceded by a
minus sign.
-(Ri)
The contents of a register specified in the instruction are first automatically
decremented and are then used as the effective address of the operand.

3302 3300
6B

7F
3302

Register Set

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary
 Addressing modes are important to fetch the data.

 There are different ways are there to mention the address.

 Each address mode can be used in different places to reduce the number
instructions.

 Addressing modes are used to increase the performance of a computer.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 10: Assembly Language
Assembly Language Definition:
 Machine Instructions are represented by patterns of 0 and 1. Use symbolic
names to represent the patterns.
 So far, normal words such as Move, Add, Increment and Branch for the
instruction operations are used to represent the corresponding binary code
patters.
 When writing programs for a specific computer, such words are normally
replaced by acronyms called Mnemonics, such as MOV, ADD, INC and BR.
 Similarly, use the notation R3 to refer to register 3, LOC to refer to a memory
location.
 A complete set of symbolic names and rules for their use constitute a
programming language, generally referred as Assembly Language.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Contd…
Assembler
Programs written in an assembly language can be automatically translated
in to a sequence of machine instructions by a program called as assembler.
Assembler is stored as a sequence of machine instructions in the
memory of the computer.
User Program also known as source program is usually entered in to the
computer through a keyboard and stored either in memory or in magnetic disk.
When the assembler program is executed, it reads the user program, analyses
it and then generate the desired machine language program.
The assembled machine language program is called object program.
Assembly Language program for a given computer may or may not be case
sensitive.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Types of Instructions
 Transfer of data from one location to another
Data Transfer Instructions
location.
 Common transfers may be between memory Name Mnemonics
and processor registers, processor Load LD
registers and input/output. Store ST
Move MOV
Ex. MOVE R0, SUM Exchange XCH
Here MOVE is Mnemonic Source operand is in register R0.
Input IN

This information is followed by the specification of the Output OUT


destination operand, separated from source operand by a Push PUSH
comma. Pop POP

The destination operand is in memory location SUM.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 Several possible addressing modes for specifying operand locations,
assembly language must indicate which mode is being used.
Addressing Modes
Direct Address
Indirect Address
Relative Address
Immediate Address
Index Address
Register address mode (Direct)
Indirect address mode
Auto Increment
Auto Decrement

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Data Manipulation Instructions
 Operates on data and provide computational capability for the computer
 Arithmetic
 Logical & Bit Manipulation
 Shift

Name Mnemonic Name Mnemonic


Clear CLR Name Mnemonic Increment INC
Complement COM Logical shift right SHR Decrement DEC
AND AND Logical shift left SHL
Add ADD
OR OR Arithmetic shift right SHRA
Subtract SUB
Exclusive-OR XOR Arithmetic shift left SHLA
Multiply MUL
Clear carry CLRC Rotate right ROR
Set carry SETC Divide DIV
Rotate left ROL
Complement carry COMC Rotate right through carry RORC Add with carry ADDC
Enable interrupt EI Rotate left through carry ROLC Subtract with borrow SUBB
Disable interrupt DI Negate NEG

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Program Control Instructions

 Specify the conditions for altering the content of Program Counter.

Name Mnemonic
Branch BR
Jump JMP
Skip SKP
Call CALL
Return RET

Compare (Subtract) CMP

Test (AND) TST

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Conditional Branch Instructions

Tested
Mnemonic Branch Condition
Condition
BZ Branch if zero Z=1
BNZ Branch if not zero Z=0
BC Branch if carry C=1
BNC Branch if no carry C=0
BP Branch if plus S=0
BM Branch if minus S=1
BV Branch if overflow V=1
BNV Branch if no overflow V=0

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Assembler Directives(Commands)

Assigning any numerical values to any names.


Suppose the name SUM is used to represent the value 200.
This may be conveyed to the assembler program through a statement.
SUM EQU 200
This statement simply informs the assembler that the name SUM should be
replaced by the value 200 wherever it appears in the program. Such
statement is called Assembler Directives or Commands.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Use of Assembly Language
Program for adding a list of numbers: Memory Arrangement of the
Indirect Addressing Modes can be used to program
access successive numbers in the list.

 To run this program on a computer, it is necessary to


write this program in the required assembly language,
specifying all the information needed to generate the
corresponding object program.
© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION
Assembly Language Representation of
the Program
Memory Address Operation Addressing or data
Label information
Assembler directions SUM EQU 200
ORIGIN 204
N DATAWORD 100
NUM1 RESERVE 400
ORIGIN 100
START MOVE N, R1
Statement that generate machine MOVE #NUM1, R2
instructions CLR R0
LOOP ADD (R2), R0
ADD #4, R2
DEC R1
BGTZ LOOP
MOVE R0, SUM
Assembler directives RETURN
END START

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 The program begins with assembler directives

 First Assembler Directive: EQU-informs the assembler about the value of SUM

 Second Assembler Directive: ORIGIN: Tells the assembler program where in


the memory location to place the data block that follows.

 In this case, location specified has the address 204. This location is to be added
with the value 100, DATAWORD directive is used to inform the assembler about
this requirement.

 RESERVE Directive declares that a memory block of 400 bytes is to be


reserved for data, and the name NUM1 is to be associated with address 208.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Second ORIGIN directive specifies that the instruction of the object
program are to be loaded in the memory address starting at 100.It is
followed by source program instructions written with the appropriate
mnemonics.

 The last statement in the source program is the assembler directive END,
which tells the assembler that this is the end of the source program.

 END directive includes the label START, which is the address of the location
at which execution of the program is to begin.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 Assembly language is used in microprocess.

 Assembler is used to convert assembly language into machine


understandable language.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 11: Basic I/O Operations
 Consider a task that reads character from a keyboard and produces character
output on a display screen. A simple way of performing such I/O tasks is known
as program controlled I/O.
 The rate of data transfer from the keyboard to a computer is limited by the
typing speed of the user.
 The rate of output transfers from the computer to display is determined by the
rate at which characters can be transmitted over the link between computer
and display devices (typically several thousand characters per second).
 The rate of output transfers from computer to display is much higher but still
slower than the speed of processor (can execute many millions instructions per
second).
 The difference in speed between Processor and I/O Devices creates the need
for mechanism to synchronize the transfer of data between them.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Solution

 On Output side, processor sends the first character and then waits for a
signal from the display that the character has been received. It then sends
the second character and so on.

 Likewise, input is sent from keyboard, the processor waits for a signal
indicating that the character has been struck and its code is available in
some buffer register associated with the keyboard. Then the processor
proceeds to read that code.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Bus Connections for Processor,
Keyboard and Display
Bus

PROCESSOR DATAIN DATAOUT

SIN SOUT

Keyboard Display

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd….
 Striking a key stores the corresponding character in an 8 bit buffer register
associated with the keyboard.8 bit buffer register is known as DATAIN.
 To inform the processor, a valid character is in DATAIN, a status control
flag, SIN is set to 1.
 A Program monitors SIN, and when SIN is set to 1,the processor reads the
contents of DATAIN.
 When the character is transferred to the processor, SIN is automatically
cleared to zero.
 If a second character is entered at keyboard, SIN is again set to 1 and the
process repeats.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…
 A buffer register, DATAOUT and a status control flag, SOUT are used when
characters are transferred from the processor to the display.

 When SOUT equals to 1,the display is ready to receive a character.

 Under program control, the processor monitors SOUT, and when SOUT is
set to 1, the processor transfers a character code to DATAOUT.

 The transfer of a character to DATAOUT clears SOUT to 0, when the


display device is ready to receive a second character, SOUT is again set to
1.

 The buffer registers DATAIN and DATAOUT, status flags SIN and SOUT are
part of circuit known as device interface.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 Data input accepts from Input unit and it will be stored in DATAIN register.

 Output data will send it to Output unit and it will be stored in DATAOUT
register.

 Input unit and output units are having the status flags (SIN & SOUT) which
are used to know the status of the unit.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 12: Stacks and Queues
 In general, program operates on data that reside in the computer memory.
These data can be organized in variety of ways.

 Programmer use data structure to represent the data.

 Consider an important data structure known as stack.

 A Stack is a list of data elements in which elements can bd added or


removed at one end of the list only.

 This end is called top of the stack and other end is called bottom. This
structure is sometimes referred as pushdown stack.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Topic 12: Stacks and Queues Contd…

 Stack follows last in first out technique-last data element placed on the
stack is the first one removed from the stack.

 There are two operations


1) Push - Inserting a new item into the stack
2) Pop - Removing the top item from the stack

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


A stack of words in the memory

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Explanation

 Stack contains numerical values with 43 at the bottom and -28 at the top.

Stack Pointer

 A processor register keep track of the address of the element of the stack
that is at the top at any given time.

 This register is called stack pointer.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Push and Pop Operation

After push Before


from new push from
item new item

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Contd…..

 Push operation can be implemented as

 Subtract #4, SP- : Subtract instruction subtracts the source operand 4 from
the destination operand(SP) and places the result in SP.

 Move NEW ITEM, (SP)- : Move the New Item(19) to Stack Pointer.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Pop Operation

-54 -54
Stack 25 SP 25
Pointer (SP) 504
504

45 45

ITEM -28

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Explanation

 Pop operation can be implemented as


Move (SP), ITEM
Add #4, SP
 These two instructions move the top value from stack into location Item
and then increment SP by 4 so that it points to the new top element.
 If the processor has auto increment and auto decrement addressing
modes, then push and pop operation can be performed by single
instruction.
Move NEW ITEM, -(SP)
Move (SP)+, Item

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Queue

 Is a list of data elements in which elements can be added or removed at


different end.

 Data added into queue is known as REAR End and Data removed from
the queue is known as front end.

 Queue follows First in First out technique-data item stored first will be
deleted first.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Summary

 STACK use Last In First Out (LIFO) method

 QUEUE us FIRST In First Out (FIFO) method

 Data will be inserted into memory by using PUSH operation

 Data will be moved from memory by using POP operation

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


References
Text Book:
 T1. Carl Hamacher, Zvonko Vranesic and Safwat Zaky, Computer Organization,
McGraw-Hill, 5th Edition, 2002.

Reference books:
 R1. William Stallings, Computer Organization and Architecture – Designing for
Performance, Pearson Education, 6th Edition, 2003.
 R2. David A.Patterson and John L.Hennessy, Computer Organization and design:
The hardware software interface, Morgan Kaufmann, 2nd Edition, , 2002.
 R3. John P.Hayes, Computer Architecture and Organization, McGraw Hill, 3rd
Edition, 1998.

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION


Thank You!

© Kalasalingam Academy of Research and Education COMPUTER ARCHITECTURE AND ORGANIZATION

You might also like