SlideShare a Scribd company logo
BASIC STRUCTURE OF COMPUTERS
Dr. Chitradevi D
Assistant Professor
Department of Computer Science and Engineering
SRM Institute Technology and Science
Functional Units
 A computer consist of five parts namely: input, memory, arithmetic and logic, output and
control units.
 The input unit receives the coded information from the user, through various
electromechanical device such as keyboard etc.
 The information received is either stored in computer’s memory for later use or it can be
immediately utilized for operations.
 Finally the results are displayed to the user through the output unit.
 All these actions are coordinated by the control unit.
 The information handled by the computer are categorized as either instructions and data.
 Instructions or machine instructions, are explicit commands which,
 helps in the transfer of information within the computer as well as between the
computer and its I/O device.
 specify the arithmetic and logic operations to be performed.
 The list of instructions that performs the task is called a program and it is stored in the
memory.
Input Unit:
 Computer accepts the information through input unit. The most commonly used input
device is keyboard. Whenever a key is pressed, the corresponding letter or digit is
automatically translated into its corresponding binary code and transmitted over a cable to
memory or processor.
 Many other kind of input devices such as joysticks, trackballs, mouse and microphone.
Memory Unit:
 The function of memory unit is to store program and data. The memory unit is divided into two
types: primary and secondary.
 Primary memory: it is called as the computer memory that can be directly accessed by the
CPU. It holds the data and instructions that the processor is currently working on.
 Secondary memory/Storage: The contents of the secondary memory first get transferred
to the primary memory and then are accessed by the processor, this is because the processor
does not directly interact with the secondary memory.
Primary Secondary
Primary memory is temporary. Secondary memory is permanent.
Primary memory is directly accessible
by Processor/CPU.
Secondary memory is not directly
accessible by the CPU.
Nature of Parts of Primary memory
varies, RAM- volatile in nature. ROM-
Non-volatile.
It’s always Non-volatile in nature.
The memory devices used for primary
memory are semiconductor
memories.
The secondary memory devices are
magnetic and optical memories.
Arithmetic and Logic Unit:
 Computer operations are carried out by Arithmetic and Logic Unit (ALU) of the processor.
 Example: suppose two numbers located in the memory are to be added, first the numbers should
be brought into the processor and then the addition is carried out by the ALU. The results can be
stored in the memory or retained in the processor.
 When the operands are brought into the processor, they are stored in a high-speed storage element
called Registers.
Output Unit: its function is to send the processed results to the outside world.
Primary Secondary
Primary memory is also known as
Main memory or Internal memory.
Secondary memory is also known as
External memory or Auxiliary
memory.
Examples: RAM, ROM, Cache
memory,
Examples: Hard Disk, Floppy Disk,
Magnetic Tapes
Control Unit:
 The memory, arithmetic and logic and input and output units store and process
information and perform input and output operations. These operations must be
coordinated in some way, which is done by the control unit.
 The control unit sends control signals to other units and sense their states.
These control signals are called timing signals. The timing signals helps to
determine when a given action can take place.
Basic Operational Concept
 To perform a given task an appropriate program consisting of a list of
instructions is stored in the memory.
 Individual instructions are brought from the memory into the processor, which
executes the specified operations.
 Examples: - Add LOCA, R0
 This instruction adds the operand at memory location LOCA, to operand in
register R0 & places the sum into register. This instruction requires the
performance of several steps:
 First the instruction is fetched from the memory into the processor.
 The operand at LOCA is fetched and added to the contents of R0.
 Finally the resulting sum is stored in the register R0
 In some other type of computers, these two types of operations are performed
by separate instructions for performance reasons.
Load LOCA, R1
Add R1, R0
 The fig shows how memory & the processor can be connected. In addition to the
ALU & the control circuitry, the processor contains a number of registers used for
several different purposes.
 The instruction register (IR):- Holds the instructions that is currently being
executed.
 The program counter PC:- This is another specialized register that keeps track of
execution of a program. It contains the information of the next instruction to be
fetched and executed.
 Besides IR and PC, there are n-general purpose registers R0 through Rn.The other
two registers which facilitate communication with memory are: -
 1. MAR – (Memory Address Register):- It holds the address of the location to
be accessed.
 2. MDR – (Memory Data Register):- It contains the data to be written into or
read out of the address location.
 Operating steps:
Example:
LOAD LOCA, R1
ADD R1, R0
1. Execution of the program starts when the PC is set to point to the first
instruction of a program.
2. The contents of the PC are transferred to the MAR and a Read control signal is
sent to the memory.
3. After some time, addressed word is read out of the memory and loaded into the
MDR.
4. Next the contents of the MDR are transferred to the IR. At this point, the
instructions is ready to be decoded and executed.
5. If the instruction involves an operation to be performed by ALU, then its
necessary to obtain the required operand.
6. If an operand resides in the memory (it could also be in the GPR), it has to be
fetched by setting its address to MAR and initiating Read signal.
7. When the operand has been read from the memory into the MDR, it is
transferred from the MDR to ALU. After one or more operands are fetched in this
way, the ALU can perform the desired operation.
8. If the result of this operation is to be stored in the memory, then the result is sent
to MDR and the address of the result is to be stored in MAR and a write signal is
initiated.
9. The contents of the PC are incremented so that PC points to the next instruction
to be executed.
BUS Structure
 A Bus is a collection of wires that connects several devices. Buses are used to send
control signals and data between the processor and other components.
 In computer system all the peripherals are connected to microprocessor through Bus.
 Types of Bus structure:
 Address bus
 Data bus
 Control bus
 Address Bus:
 Address bus carry the memory address while reading from writing into memory.
 Address bus carry I/O port address or device address from I/O port.
 Data bus:
 Data bus carry the data. It is bidirectional.
 Data bus fetch the instructions from memory.
 Data bus used to store the result of an instruction into memory. It carry
commands to an I/O device controller .
 Control Bus:
 Memory Read: This signal, is issued by the CPU when performing a read
operation with the memory.
 Memory Write: This signal is issued by the CPU when performing a write
operation with the memory.
 I/O Read: This signal is issued by the CPU when it is reading from an input
port.
 I/O Write: This signal is issued by the CPU when writing into an output
port.
Memory Locations and Addresses
 Memory locations and addresses determine how the computer’s memory is
organized so that the user can efficiently store or retrieve information from the
computer.
 The computer’s memory is made of millions of storage cell, where each storage
cell is capable to store a bit of information which value is either 0 or 1.
 But the fact is, computer memory holds instructions and data. And a single bit is
very small to hold this information so bits are rarely used individually. As a
solution to this, the bits are grouped in fixed sizes of n bits.
 The group of n bit is termed as word where n is termed as the word length. he
word length of the computer has evolved from 8, 16, 24, 32 to 64 bits. General-
purpose computers nowadays have 32 to 64 bits. The group of 8 bit is called
a byte.
 Data are written into memory and readout of memory, based on their address.
INSTRUCTION TYPES
INSTRUCTION TYPES
Byte and Word Addressability
Byte Addressable Memory Word Addressable Memory
It is called byte addressable memory
because it uses byte wise storage
configuration.
It is called word addressable memory
because it uses word wise storage
configuration.
Byte addressable memory is best
suited for the processes that need a
single byte data at a time.
Word addressable memory is suitable for
processes that requires data comprising
single word at a time.
The byte addressable memory issues
a single address for accessing a
single byte.
The word accessible memory issues the
address of word that contains required
byte.
Byte addressable memory chip stores
data byte by byte.
Word addressable memory chip stores
data word by word.
 Byte Addressability is of two types : Big Endian and Little Endian.
 The word endian is the order or sequence of bytes of a word of digital data
in computer memory. The bytes in the computer memory are read in a certain
order.
 Big Endian: is used when lower byte addresses are used for the most
significant byte (MSB).
 Little Endian: is used when the lower byte addresses are used for the least
significant byte (LSB).
Memory Operation
 Both program instructions and data operands are stored in the memory. To
execute an instruction, the processor control circuits cause the word (words)
containing the instruction to be transferred from the memory to the processor.
 The operands and results must also moved between the memory and the
processor.
 The basic two operations involved in the memory are:
 Load (Read or Fetch)
 Store (Write)
 The load operation transfers the copy of the contents from a specific memory
location to the processor. The memory contents remains unchanged.
 To start the load operation, the processor sends the address of desired location to
the memory and requests that its contents to be read. The memory read the data
stored at that address and sends them to the processor.
 The store operation transfers an information from the processor to a specific
memory location, destroying the former contents of that location.
 The processor sends the desired location to the memory along with the data to be
written.
 An information item of either one word or one byte can be transferred between
the processor and the memory in a single operation. The processor contains small
number of registers, each capable of holding a word. These registers are either
source or destination.
Instructions
 The instructions stored in the memory performs some operations. The four types of operation
performed by an instruction are:
 Data transfer between the memory and the processor registers
 Arithmetic and logical operations on data
 Program sequencing and control
 I/O transfers
 The operations and operands are represented by two types of notations:
 Register Transfer Notation (RTN)
 Assembly Language Notation (ALN)
 Register Transfer Notation (RTN):
 The information can be transferred from one location to another in the computer, the possible
location involved in this transfer may include memory locations, processor registers or registers
in I/O systems.
 In RTN, the memory will be represented in Capital letters. Example: LOCA, LOCB, A, B etc.
 The processor registers are represented as R0,R1,R2…
 I/O operations can be represented as DATAIN, DATAOUT…
 The contents are represented using square brackets [].
 Example 1: C= A+B, to represent this in RTN
 The left hand side contains the destination
 The right hand side contains the source.
C [A]+[B]
 Example 2: move A to R0
R0[A]
 Example 3 move contents from R2 to A
A[R2]
Assembly Language Notation:
 Example 1: C=A+B
Move A, R1
Add B, R1
Move R1,C
INSTRUCTION TYPES
22
1. According to operation: based on the instruction operation
instruction set can be differentiated.
• Data processing: arithmetic and logical instruction, performs both
arithmetic and logical operation.
• Data storage: memory instruction, performs the operation using
register. Instruction must be transferred from CPU register to
memory register.
• Data movement: data transfer instruction, holds the transfer of data
from CPU register and I/O devices
23
According to number of address:
• Three address instruction
• Two address instruction
• One address instruction
• Zero address instruction
24 • According to number of address:
Three address instruction
• Three Address instructions :- In these type of instructions, all
operand addresses are explicitly defined. Here the instructions
format has three different address fields specifying or
memory or processor register operand.
• Three-address instruction is a format of machine instruction. It
has one opcode and three address fields. One address field is
used for destination and two address fields for source.
Example :- ADD R1,C,B
25
Example:
X = (A + B) x (C + D)
ADD R1, A, B R1 <- M[A] + M[B]
ADD R2, C, D R2 <- M[C] + M[D]
MUL X, R1, R2 M[X] <- R1 x R2
26
• According to number of address:
Two address instruction
• Two Address instructions :- Here the instruction format has two
different address fields, each specifying either a memory or a
processor register operand.
• Two-address instruction is a format of machine instruction. It has
one opcode and two address fields. One address field is common
and can be used for either destination or source and other address
field for source.
Example :- ADD X,Y
27
X = (A + B) x (C + D)
MOV R1, A R1 <- M[A]
ADD R1, B R1 <- R1 + M[B]
MOV R2, C R2 <- M[C]
ADD R2, D R2 <- R2 + D
MUL R1, R2 R1 <- R1 x R2
MOV X, R1 M[X] <- R1
28 • According to number of address:
One address instruction
• One Address Instructions :- Such instruction format has a single
explicit address field and uses an implied accumulator (AC)
register for all data manipulation.
• One-Address instruction is also a format of machine instruction. It
has only two fields. One for opcode and other for operand.
29
X = (A + B) x (C + D)
LOAD A AC <- M[A]
ADD B AC <- AC + M[B]
STORE T M[T] <- AC
LOAD C AC <- M[C]
ADD D AC <- AC + M[D]
MUL T AC <- AC x M[T]
STORE X M[X] <- AC
Instruction Execution and Straight
Line Sequencing
 The program counter holds the instructions to be executed next. To begin the
execution, the address of the first instructions must be placed into the PC.
 Then the processor control circuits use the information in the PC to fetch and
execute the instruction one at a time in the order of increasing addresses. This is
called straight line sequencing.
 Executing an instruction is a two-phase procedure. The first phase is called
instruction fetch- instruction is fetched from the memory location using the
address in the PC.
 After fetching the instructions it is placed in the Instruction Register (IR).
 The second phase is called instruction execution. The instruction in the IR is
examined to determine which operation is to be performed. The specified operation
is then performed by the processor. This includes fetching operand from the
memory or processor registers, performing ALU operations and storing the result
in the destination.
Branching:
 Lets consider the task of adding a list of n numbers. The addresses of the memory
location containing the n numbers are represented as NUM1, NUM2,….NUMn
and a separate Add instruction is used to add each number to the contents of
register R0.
 Finally, after adding all the numbers, the result is placed in the memory location
SUM.
INSTRUCTION TYPES
 Instead of adding long list of Add instructions, it is possible to place a single Add
instruction in a program loop. The loop is a straight line sequence of instructions
executed as many times as needed.
 It starts at the location LOOP and ends at the instruction Branch>0. During each
pass through the loop, address of the next list entry is determined and it is added to
R0.
Addressing Modes
 The different ways in which the location of an operand is specified in an instruction
are referred to as addressing modes.
 Different types of addressing modes:
 Register mode
 Absolute mode
 Immediate mode
 Indirect mode
 Index mode
 Relative mode
 Auto increment mode
 Auto decrement mode
 Register mode: the operand is the contents of a processor register, the name of the
register is given in the instruction.
Move R1,R2
 Absolute (direct) mode: the operand is in the memory location, the address of this
location is given explicitly in the instruction.
Move LOCA, R2
 Immediate mode: the operand is given explicitly in the instruction.
Example 1: Move #200, R0
Example 2: A=B+6
Move B,R1
Add #6, R1
Move R1, A
 Indirect Addressing mode: this type of addressing mode does not give the operand or its
address explicitly. Instead, it provides information from which the memory address of the
operand can be determined. It is called as the effective address (EA) of the operand.
 Index Addressing mode: the effective address of the operand is generated by adding a
constant value to the contents of a register.
 The register used may be either a special register provided for this purpose or more commonly
it may be any one of a set of general- purpose registers in the processor. In either case it is
referred to as an index register.
 The index mode is symbolically indicated as
X(Ri)
 The effective address of the operand is given by
EA=X+[Ri]
INSTRUCTION TYPES
INSTRUCTION TYPES
Assembly Language
 Assembly Language is a low-level programming language. It helps in
understanding the programming language of machine code.
 It is a series of instructions that provide the necessary information to a user’s
CPU (Central Processing Unit) to carry out a particular task (add, subtract,
compare values, etc.).
 In computers, there is an assembler that helps in converting the assembly code
into machine code executable.
 Assembly language uses a series of mnemonic codes to represent machine
language instructions.
 The normal words such as move, add, increment, branch can be replaced by
acronyms called mnemonics, such MOVE, ADD, INC and BR. Similarly,
notation R3 is used to refer register 3 and LOC used to refer a memory location.
 The set of rules for using the mnemonics are called as the syntax of the
language.
 The assembly language is translated into corresponding machine instructions
using assembler.
 The user program is usually entered into a computer through a keyboard and stored either
in the memory or on a magnetic disk.
 At this point, the user program is simply a set of lines of alphanumeric characters.
 The assembler then reads the user program, analyze it and then generated the machine
language program.
 The original user program in alphanumeric characters are called a source program and the
assembled machine language program is called as a object program.
 The assembly language for a given computer may or may not be case sensitive.
 Example: MOVE R0,SUM
 The mnemonics MOVE followed by one blank space character, then the information that
specifies the operand is given.
 The source operand is register R0 followed by destination operands. Both the source and
destination separated by comma with no intervening blanks.
 Since there are several possible addressing modes for specifying operand locations, the
assembly language mush indicate which mode is being used.
MOVE R0,SUM
ADD #5,R3
ADDI 5,R3
MOVE #5,(R2)
 Assembler directives (commands): the assembly language allows the
programmer to specify other information needed to translate the program into
the object program.
SUM EQU 200

More Related Content

PPTX
0.2 evolution of microprocessor
PDF
Lecture 05 pic io port programming
PPTX
I/O Ports
PPT
EEPROM Part-21
PPTX
AVR ATmega32
PPTX
Microcontroller
PPT
Power point greciaaaaaa
PPTX
Ram rom
0.2 evolution of microprocessor
Lecture 05 pic io port programming
I/O Ports
EEPROM Part-21
AVR ATmega32
Microcontroller
Power point greciaaaaaa
Ram rom

Similar to INSTRUCTION TYPES (20)

PDF
DLD1.pdf
PDF
Digital-Logic-Design-and-Computer-Organization.pdf
DOCX
COA Unit 1_notes : Basic Structure of Computer System.docx
PPTX
CPU ARCHITECTURE and COMPUTER PROGRAMS G
PDF
Computer organization and architecture|KTU
PDF
Computer organization and architecture|KTU
PPTX
BASIC STRUCTURE OF COMPUTERS.pptx
PDF
unit-i.pdf
PPTX
UNIT -1 COMPUTER ORGANIZATION (1).pptxxc
PPTX
Chapter 3 Assembly level machine organization Assembly level machine organiza...
PDF
Unit 1 - Basic Computer Engineering - www.rgpvnotes.in (1).pdf
PPTX
Unit2fit
PPT
COA-Unit-1-Basics.ppt
PDF
Bca examination 2015 csa
PDF
COMPUTER ORGNAIZATION NOTES
PPTX
Computer organization unit 2detaila with analysis
PPTX
Computer.pptx
PPT
Basic ops concept of comp
PPTX
COMPUTER ORGANIZATION for beginner and a
DLD1.pdf
Digital-Logic-Design-and-Computer-Organization.pdf
COA Unit 1_notes : Basic Structure of Computer System.docx
CPU ARCHITECTURE and COMPUTER PROGRAMS G
Computer organization and architecture|KTU
Computer organization and architecture|KTU
BASIC STRUCTURE OF COMPUTERS.pptx
unit-i.pdf
UNIT -1 COMPUTER ORGANIZATION (1).pptxxc
Chapter 3 Assembly level machine organization Assembly level machine organiza...
Unit 1 - Basic Computer Engineering - www.rgpvnotes.in (1).pdf
Unit2fit
COA-Unit-1-Basics.ppt
Bca examination 2015 csa
COMPUTER ORGNAIZATION NOTES
Computer organization unit 2detaila with analysis
Computer.pptx
Basic ops concept of comp
COMPUTER ORGANIZATION for beginner and a
Ad

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Sports Quiz easy sports quiz sports quiz
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
GDM (1) (1).pptx small presentation for students
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Anesthesia in Laparoscopic Surgery in India
Abdominal Access Techniques with Prof. Dr. R K Mishra
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Sports Quiz easy sports quiz sports quiz
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPH.pptx obstetrics and gynecology in nursing
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Complications of Minimal Access Surgery at WLH
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
TR - Agricultural Crops Production NC III.pdf
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
GDM (1) (1).pptx small presentation for students
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
Ad

INSTRUCTION TYPES

  • 1. BASIC STRUCTURE OF COMPUTERS Dr. Chitradevi D Assistant Professor Department of Computer Science and Engineering SRM Institute Technology and Science
  • 2. Functional Units  A computer consist of five parts namely: input, memory, arithmetic and logic, output and control units.  The input unit receives the coded information from the user, through various electromechanical device such as keyboard etc.  The information received is either stored in computer’s memory for later use or it can be immediately utilized for operations.  Finally the results are displayed to the user through the output unit.  All these actions are coordinated by the control unit.
  • 3.  The information handled by the computer are categorized as either instructions and data.  Instructions or machine instructions, are explicit commands which,  helps in the transfer of information within the computer as well as between the computer and its I/O device.  specify the arithmetic and logic operations to be performed.  The list of instructions that performs the task is called a program and it is stored in the memory. Input Unit:  Computer accepts the information through input unit. The most commonly used input device is keyboard. Whenever a key is pressed, the corresponding letter or digit is automatically translated into its corresponding binary code and transmitted over a cable to memory or processor.  Many other kind of input devices such as joysticks, trackballs, mouse and microphone.
  • 4. Memory Unit:  The function of memory unit is to store program and data. The memory unit is divided into two types: primary and secondary.  Primary memory: it is called as the computer memory that can be directly accessed by the CPU. It holds the data and instructions that the processor is currently working on.  Secondary memory/Storage: The contents of the secondary memory first get transferred to the primary memory and then are accessed by the processor, this is because the processor does not directly interact with the secondary memory. Primary Secondary Primary memory is temporary. Secondary memory is permanent. Primary memory is directly accessible by Processor/CPU. Secondary memory is not directly accessible by the CPU. Nature of Parts of Primary memory varies, RAM- volatile in nature. ROM- Non-volatile. It’s always Non-volatile in nature. The memory devices used for primary memory are semiconductor memories. The secondary memory devices are magnetic and optical memories.
  • 5. Arithmetic and Logic Unit:  Computer operations are carried out by Arithmetic and Logic Unit (ALU) of the processor.  Example: suppose two numbers located in the memory are to be added, first the numbers should be brought into the processor and then the addition is carried out by the ALU. The results can be stored in the memory or retained in the processor.  When the operands are brought into the processor, they are stored in a high-speed storage element called Registers. Output Unit: its function is to send the processed results to the outside world. Primary Secondary Primary memory is also known as Main memory or Internal memory. Secondary memory is also known as External memory or Auxiliary memory. Examples: RAM, ROM, Cache memory, Examples: Hard Disk, Floppy Disk, Magnetic Tapes
  • 6. Control Unit:  The memory, arithmetic and logic and input and output units store and process information and perform input and output operations. These operations must be coordinated in some way, which is done by the control unit.  The control unit sends control signals to other units and sense their states. These control signals are called timing signals. The timing signals helps to determine when a given action can take place.
  • 7. Basic Operational Concept  To perform a given task an appropriate program consisting of a list of instructions is stored in the memory.  Individual instructions are brought from the memory into the processor, which executes the specified operations.  Examples: - Add LOCA, R0  This instruction adds the operand at memory location LOCA, to operand in register R0 & places the sum into register. This instruction requires the performance of several steps:  First the instruction is fetched from the memory into the processor.  The operand at LOCA is fetched and added to the contents of R0.  Finally the resulting sum is stored in the register R0  In some other type of computers, these two types of operations are performed by separate instructions for performance reasons. Load LOCA, R1 Add R1, R0
  • 8.  The fig shows how memory & the processor can be connected. In addition to the ALU & the control circuitry, the processor contains a number of registers used for several different purposes.  The instruction register (IR):- Holds the instructions that is currently being executed.  The program counter PC:- This is another specialized register that keeps track of execution of a program. It contains the information of the next instruction to be fetched and executed.
  • 9.  Besides IR and PC, there are n-general purpose registers R0 through Rn.The other two registers which facilitate communication with memory are: -  1. MAR – (Memory Address Register):- It holds the address of the location to be accessed.  2. MDR – (Memory Data Register):- It contains the data to be written into or read out of the address location.  Operating steps: Example: LOAD LOCA, R1 ADD R1, R0 1. Execution of the program starts when the PC is set to point to the first instruction of a program. 2. The contents of the PC are transferred to the MAR and a Read control signal is sent to the memory. 3. After some time, addressed word is read out of the memory and loaded into the MDR. 4. Next the contents of the MDR are transferred to the IR. At this point, the instructions is ready to be decoded and executed.
  • 10. 5. If the instruction involves an operation to be performed by ALU, then its necessary to obtain the required operand. 6. If an operand resides in the memory (it could also be in the GPR), it has to be fetched by setting its address to MAR and initiating Read signal. 7. When the operand has been read from the memory into the MDR, it is transferred from the MDR to ALU. After one or more operands are fetched in this way, the ALU can perform the desired operation. 8. If the result of this operation is to be stored in the memory, then the result is sent to MDR and the address of the result is to be stored in MAR and a write signal is initiated. 9. The contents of the PC are incremented so that PC points to the next instruction to be executed.
  • 11. BUS Structure  A Bus is a collection of wires that connects several devices. Buses are used to send control signals and data between the processor and other components.  In computer system all the peripherals are connected to microprocessor through Bus.  Types of Bus structure:  Address bus  Data bus  Control bus  Address Bus:  Address bus carry the memory address while reading from writing into memory.  Address bus carry I/O port address or device address from I/O port.  Data bus:  Data bus carry the data. It is bidirectional.  Data bus fetch the instructions from memory.
  • 12.  Data bus used to store the result of an instruction into memory. It carry commands to an I/O device controller .  Control Bus:  Memory Read: This signal, is issued by the CPU when performing a read operation with the memory.  Memory Write: This signal is issued by the CPU when performing a write operation with the memory.  I/O Read: This signal is issued by the CPU when it is reading from an input port.  I/O Write: This signal is issued by the CPU when writing into an output port.
  • 13. Memory Locations and Addresses  Memory locations and addresses determine how the computer’s memory is organized so that the user can efficiently store or retrieve information from the computer.  The computer’s memory is made of millions of storage cell, where each storage cell is capable to store a bit of information which value is either 0 or 1.  But the fact is, computer memory holds instructions and data. And a single bit is very small to hold this information so bits are rarely used individually. As a solution to this, the bits are grouped in fixed sizes of n bits.  The group of n bit is termed as word where n is termed as the word length. he word length of the computer has evolved from 8, 16, 24, 32 to 64 bits. General- purpose computers nowadays have 32 to 64 bits. The group of 8 bit is called a byte.  Data are written into memory and readout of memory, based on their address.
  • 16. Byte and Word Addressability Byte Addressable Memory Word Addressable Memory It is called byte addressable memory because it uses byte wise storage configuration. It is called word addressable memory because it uses word wise storage configuration. Byte addressable memory is best suited for the processes that need a single byte data at a time. Word addressable memory is suitable for processes that requires data comprising single word at a time. The byte addressable memory issues a single address for accessing a single byte. The word accessible memory issues the address of word that contains required byte. Byte addressable memory chip stores data byte by byte. Word addressable memory chip stores data word by word.
  • 17.  Byte Addressability is of two types : Big Endian and Little Endian.  The word endian is the order or sequence of bytes of a word of digital data in computer memory. The bytes in the computer memory are read in a certain order.  Big Endian: is used when lower byte addresses are used for the most significant byte (MSB).  Little Endian: is used when the lower byte addresses are used for the least significant byte (LSB).
  • 18. Memory Operation  Both program instructions and data operands are stored in the memory. To execute an instruction, the processor control circuits cause the word (words) containing the instruction to be transferred from the memory to the processor.  The operands and results must also moved between the memory and the processor.  The basic two operations involved in the memory are:  Load (Read or Fetch)  Store (Write)  The load operation transfers the copy of the contents from a specific memory location to the processor. The memory contents remains unchanged.  To start the load operation, the processor sends the address of desired location to the memory and requests that its contents to be read. The memory read the data stored at that address and sends them to the processor.
  • 19.  The store operation transfers an information from the processor to a specific memory location, destroying the former contents of that location.  The processor sends the desired location to the memory along with the data to be written.  An information item of either one word or one byte can be transferred between the processor and the memory in a single operation. The processor contains small number of registers, each capable of holding a word. These registers are either source or destination.
  • 20. Instructions  The instructions stored in the memory performs some operations. The four types of operation performed by an instruction are:  Data transfer between the memory and the processor registers  Arithmetic and logical operations on data  Program sequencing and control  I/O transfers  The operations and operands are represented by two types of notations:  Register Transfer Notation (RTN)  Assembly Language Notation (ALN)  Register Transfer Notation (RTN):  The information can be transferred from one location to another in the computer, the possible location involved in this transfer may include memory locations, processor registers or registers in I/O systems.  In RTN, the memory will be represented in Capital letters. Example: LOCA, LOCB, A, B etc.  The processor registers are represented as R0,R1,R2…  I/O operations can be represented as DATAIN, DATAOUT…  The contents are represented using square brackets [].
  • 21.  Example 1: C= A+B, to represent this in RTN  The left hand side contains the destination  The right hand side contains the source. C [A]+[B]  Example 2: move A to R0 R0[A]  Example 3 move contents from R2 to A A[R2] Assembly Language Notation:  Example 1: C=A+B Move A, R1 Add B, R1 Move R1,C
  • 22. INSTRUCTION TYPES 22 1. According to operation: based on the instruction operation instruction set can be differentiated. • Data processing: arithmetic and logical instruction, performs both arithmetic and logical operation. • Data storage: memory instruction, performs the operation using register. Instruction must be transferred from CPU register to memory register. • Data movement: data transfer instruction, holds the transfer of data from CPU register and I/O devices
  • 23. 23 According to number of address: • Three address instruction • Two address instruction • One address instruction • Zero address instruction
  • 24. 24 • According to number of address: Three address instruction • Three Address instructions :- In these type of instructions, all operand addresses are explicitly defined. Here the instructions format has three different address fields specifying or memory or processor register operand. • Three-address instruction is a format of machine instruction. It has one opcode and three address fields. One address field is used for destination and two address fields for source. Example :- ADD R1,C,B
  • 25. 25 Example: X = (A + B) x (C + D) ADD R1, A, B R1 <- M[A] + M[B] ADD R2, C, D R2 <- M[C] + M[D] MUL X, R1, R2 M[X] <- R1 x R2
  • 26. 26 • According to number of address: Two address instruction • Two Address instructions :- Here the instruction format has two different address fields, each specifying either a memory or a processor register operand. • Two-address instruction is a format of machine instruction. It has one opcode and two address fields. One address field is common and can be used for either destination or source and other address field for source. Example :- ADD X,Y
  • 27. 27 X = (A + B) x (C + D) MOV R1, A R1 <- M[A] ADD R1, B R1 <- R1 + M[B] MOV R2, C R2 <- M[C] ADD R2, D R2 <- R2 + D MUL R1, R2 R1 <- R1 x R2 MOV X, R1 M[X] <- R1
  • 28. 28 • According to number of address: One address instruction • One Address Instructions :- Such instruction format has a single explicit address field and uses an implied accumulator (AC) register for all data manipulation. • One-Address instruction is also a format of machine instruction. It has only two fields. One for opcode and other for operand.
  • 29. 29 X = (A + B) x (C + D) LOAD A AC <- M[A] ADD B AC <- AC + M[B] STORE T M[T] <- AC LOAD C AC <- M[C] ADD D AC <- AC + M[D] MUL T AC <- AC x M[T] STORE X M[X] <- AC
  • 30. Instruction Execution and Straight Line Sequencing  The program counter holds the instructions to be executed next. To begin the execution, the address of the first instructions must be placed into the PC.  Then the processor control circuits use the information in the PC to fetch and execute the instruction one at a time in the order of increasing addresses. This is called straight line sequencing.
  • 31.  Executing an instruction is a two-phase procedure. The first phase is called instruction fetch- instruction is fetched from the memory location using the address in the PC.  After fetching the instructions it is placed in the Instruction Register (IR).  The second phase is called instruction execution. The instruction in the IR is examined to determine which operation is to be performed. The specified operation is then performed by the processor. This includes fetching operand from the memory or processor registers, performing ALU operations and storing the result in the destination. Branching:  Lets consider the task of adding a list of n numbers. The addresses of the memory location containing the n numbers are represented as NUM1, NUM2,….NUMn and a separate Add instruction is used to add each number to the contents of register R0.  Finally, after adding all the numbers, the result is placed in the memory location SUM.
  • 33.  Instead of adding long list of Add instructions, it is possible to place a single Add instruction in a program loop. The loop is a straight line sequence of instructions executed as many times as needed.  It starts at the location LOOP and ends at the instruction Branch>0. During each pass through the loop, address of the next list entry is determined and it is added to R0.
  • 34. Addressing Modes  The different ways in which the location of an operand is specified in an instruction are referred to as addressing modes.  Different types of addressing modes:  Register mode  Absolute mode  Immediate mode  Indirect mode  Index mode  Relative mode  Auto increment mode  Auto decrement mode  Register mode: the operand is the contents of a processor register, the name of the register is given in the instruction. Move R1,R2  Absolute (direct) mode: the operand is in the memory location, the address of this location is given explicitly in the instruction. Move LOCA, R2
  • 35.  Immediate mode: the operand is given explicitly in the instruction. Example 1: Move #200, R0 Example 2: A=B+6 Move B,R1 Add #6, R1 Move R1, A  Indirect Addressing mode: this type of addressing mode does not give the operand or its address explicitly. Instead, it provides information from which the memory address of the operand can be determined. It is called as the effective address (EA) of the operand.
  • 36.  Index Addressing mode: the effective address of the operand is generated by adding a constant value to the contents of a register.  The register used may be either a special register provided for this purpose or more commonly it may be any one of a set of general- purpose registers in the processor. In either case it is referred to as an index register.  The index mode is symbolically indicated as X(Ri)  The effective address of the operand is given by EA=X+[Ri]
  • 39. Assembly Language  Assembly Language is a low-level programming language. It helps in understanding the programming language of machine code.  It is a series of instructions that provide the necessary information to a user’s CPU (Central Processing Unit) to carry out a particular task (add, subtract, compare values, etc.).  In computers, there is an assembler that helps in converting the assembly code into machine code executable.  Assembly language uses a series of mnemonic codes to represent machine language instructions.  The normal words such as move, add, increment, branch can be replaced by acronyms called mnemonics, such MOVE, ADD, INC and BR. Similarly, notation R3 is used to refer register 3 and LOC used to refer a memory location.  The set of rules for using the mnemonics are called as the syntax of the language.  The assembly language is translated into corresponding machine instructions using assembler.
  • 40.  The user program is usually entered into a computer through a keyboard and stored either in the memory or on a magnetic disk.  At this point, the user program is simply a set of lines of alphanumeric characters.  The assembler then reads the user program, analyze it and then generated the machine language program.  The original user program in alphanumeric characters are called a source program and the assembled machine language program is called as a object program.  The assembly language for a given computer may or may not be case sensitive.  Example: MOVE R0,SUM  The mnemonics MOVE followed by one blank space character, then the information that specifies the operand is given.  The source operand is register R0 followed by destination operands. Both the source and destination separated by comma with no intervening blanks.  Since there are several possible addressing modes for specifying operand locations, the assembly language mush indicate which mode is being used. MOVE R0,SUM ADD #5,R3 ADDI 5,R3 MOVE #5,(R2)
  • 41.  Assembler directives (commands): the assembly language allows the programmer to specify other information needed to translate the program into the object program. SUM EQU 200