1
Computer Organization &
Architecture
Module 4 - Part 2 .
General Register Organization
Central Processing Unit
● The part of the computer that performs the data-processing operations is called the central
processing unit(CPU).
● The register set stores data used during the execution of the instructions.
● ALU performs the required microoperations for executing the instructions.
● The control unit supervises the transfer of information among the registers and instructs the
ALU as to which operation to perform.
3
General Register Organization
● Registers are used to store the intermediate
values during instruction execution.
● Register organization show how registers are
selected and how data flow between register and
ALU.
● A decoder is used to select a particular register.
● The output of each register is connected to two
multiplexers to form the two buses A and B.
● The selection lines in each multiplexer select the
input data for the particular bus.
● The A and B buses form the two inputs of an ALU.
● The operation select lines decide the micro
operation to be performed by ALU.
4
General Register Organization
● The result of the micro operation is available at
the output bus.
● The output bus connected to the inputs of all
registers, thus by selecting a destination register it
is possible to store the result in it.
Example : To perform R1 ← R2 + R3,
1. MUX A selector (SELA): to place the content of R2
into bus A.
2. MUX B selector (SELB): to place the content of R3
into bus B.
3. ALU operation selector (OPR): to provide the
arithmetic addition A.
4. Decoder destination selector (SELD): to transfer
the content of the output bus into R1. 5
Control Word
● The combined value of a binary selection inputs specifies the control word.
● It consist of four fields SELA,SELB,and SELD contains three bit each and OPR field contains four
bits thus the total bits in the control word are 13-bits.
● The three bit of SELA select a source registers of the a input of the ALU.
● The three bits of SELB select a source registers of the b input of the ALU.
● The three bits of SELD select a destination register using the decoder.
● The four bits of OPR select the operation to be performed by ALU.
6
7
Example : R2=R1+R3
Stack Organization
8
Stack Organization
9
● A useful feature that is included in the CPU of most computers is a stack or last-in, first-out
(LIFO) list.
● The register that holds the address for the stack is called a stack pointer (SP) because its value
always points at the top item in the stack.
● The stack in digital computers is essentially a memory unit with an address register that can
count only after an initial value is loaded into it.
● The two operations of a stack are the insertion and deletion of items.
Register Stack
● Stack can be placed in a portion of a large memory
or it can be organized as a collection of a finite
number of memory words or registers.
● The stack pointer register SP contains a binary
number = address of the word that is currently on
top of the stack.
● In a 64-word stack, the stack pointer contains 6
bits because 26 = 64.
● Three items are placed in the stack: A, B, and C, in
that order.
● Item C is on top of the stack so that the content of
SP is now 3.
10
Register Stack
● FULL = 1 , when stack is full & EMPTY=1 if stack is
empty
● Initially SP=0, EMPTY=1 and FULL=0
To delete an item.
● Item is deleted, if the stack is not empty.
● Read the top item into DR.
● If SP reaches 0, EMPTY is set to 1.
● Decrement SP by 1.
● DR ← M [SP]
SP ← SP — 1
If (SP = 0) then (EMTY ← 1)
FULL ← 0
11
Register Stack
To Insert a new item.
● Item is pussed only if stack is not full.
● Incerement SP by 1.
● Write a word in that higher location.
● If SP reaches 0, the stack is full of items, so FULL is
set to 1.
● SP ← SP + 1
M [SP ] ← DR
If (SP=0) then (FULL ← 1)
EMTY ← 0
12
Memory Stack
● Implementated by assigning a portion of memory to a
stack operation and using a processor register as a stack
pointer.
● The program counter (PC) points at the address of the
next instruction in the program.
● PC is used during the fetch phase to read an instruction.
● The address register (AR) points at an array of data.
● AR is used during the execute phase to read an
operand.
● The stack pointer SP points at the top of the stack.
● P is used to push or pop items into or the stack.
● Advantage - CPU can refer to it without having to
specify an address (instead use SP).
13
Instruction Formats
14
Instruction Formats
15
● The bits of the instruction are divided into groups called fields.
1. Opcode field - specifies the operation to be performed.
2. Address field - specifies a memory address / processor register.
3. Mode field - specifies the way the operand or the effective address is determined.
● The number of address fields depends on the internal organization of registers.
● Three types of CPU organizations:
1. Single accumulator organization.
Eg: ADD X
2. General register organization.
Eg: ADD R1, R2, R3 - MOV R1, R2
3. Stack organization
Eg: PUSH X
● Based on these, instructions are classified into four formats.
● Computers with three-address instruction formats can use each address field to specify either a
processor register or a memory operand.
● The program in assembly language that evaluates X = (A + B) * (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* R2
● Advantage - It results in short programs when evaluating arithmetic expressions.
● Disadvantage - The binary-coded instructions require too many bits to specify three addresses.
● Eg: Commercial computer Cyber 170.
Three-Address Instruction
16
● Two-address instructions are the most common in commercial computers.
● Here again each address field can specify either a processor register or a memory word.
● The program to evaluate X = (A + B) * (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 + M[D]
MUL R1, R2 // R1 ← R1*R2
MOV X, R1 // M[X] ← R1
Two-Address Instruction
17
● Use an implied accumulator (AC) register for all data manipulation.
● Here we neglect the second register and assume that the AC contains the result of all
operations.
● The program to evaluate X = (A + B) * (C + D)
LOAD A // AC ← M[A]
ADD B // AC ← AC + M[B]
STORE T // M[T] ← ΑC
LOAD C // AC ← M[C]
ADD D // AC ← AC + M[D]
MUL T // AC ← AC * M[T]
STORE X // M[X] ← AC
● T is the address of a temporary memory location required for storing the intermediate result.
One-Address Instruction
18
● Used in stack-organized computers.
● The program to evaluate X = (A + B) * (C + D) for a stack-organized computer
PUSH A // TOS ← A
PUSH B // TOS ← B
ADD // TOS ← (A + B)
PUSH C // TOS ← C
PUSH D // TOS ← D
ADD // TOS ← (C + D)
MUL // TOS ← (C + D)*(A + B)
POP X // M[X] ← TOS
● To evaluate arithmetic expressions in a stack computer, it is necessary to convert the
expression into reverse Polish notation.
Zero-Address Instruction
19
Addressing Modes
20
Addressing Mode
● The operation field of an instruction specifies the operation to be performed.
● This operation must be executed on some data stored in computer registers or memory words.
● The way the operands are chosen during program execution is dependent on the addressing
mode of the instruction.
● The addressing mode specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually referenced.
● Computers use addressing mode techniques for the purpose of accommodating one or both of
the following provisions:
1. To give programming versatility to the user by providing such facilities as pointers to
memory, counters for loop control, indexing of data, and program relocation.
2. To reduce the number of bits in the addressing field of the instruction
21
1. Implied Mode
● The operands are specified implicitly in the definition of the instruction.
● Eg: CMA - Complement Accumulator.
● All register reference instructions that use an accumulator are implied-mode instructions.
● Zero-address instructions in a stack-organized computer are implied-mode instructions since
the operands are implied to be on top of the stack.
22
2. Immediate Mode
● The operand is specified in the instruction itself.
● I has an operand field rather than an address field.
● The operand field contains the actual operand to be used in conjunction with the operation
specified in the instruction.
● They are are useful for initializing registers to a constant value.
● Eg: ADD 7
23
3. Register Mode
● The address field specifies a processor register.
● In this mode the operands are in registers that reside within the CPU.
● The particular register is selected from a register field in the instruction.
● A k-bit field can specify any one of 2k registers.
● Eg: ADD R1
24
4. Register Indirect Mode
● The instruction specifies a register in the CPU whose contents give the address of the operand
in memory.
● The selected register contains the address of the operand rather than the operand itself.
● Before using a register indirect mode instruction, the programmer must ensure that the
memory address of the operand is placed in the processor register with a previous instruction.
● Advantage - The address field of the instruction uses fewer bits to select a register.
25
5. Autoincrement or Autodecrement Mode
● Similar to the register indirect mode except that the register is incremented or decremented
after (or before) its value is used to access memory.
● When the address stored in the register refers to a table of data in memory, it is necessary to
increment or decrement the register after every access to the table.
● This can be achieved by using the increment or decrement instruction.
26
6.Direct Address Mode
● The effective address is equal to the address part of the instruction.
● The operand resides in memory and its address is given directly by the address field of the
instruction.
● In a branch-type instruction the address field specifies the actual branch address.
27
7. Indirect Address Mode
● The address field of the instruction gives the address where the effective address is stored in
memory.
● Control fetches the instruction from memory and uses its address part to access memory again
to read the effective address.
28
8. Relative Address Mode
● Content of the program counter is added to the address part of the instruction in order to
obtain the effective address.
● The address part of the instruction is usually a signed number (positive or negative).
● This number is added to the content of the program counter, producing an effective address
whose position in memory is relative to the address of the next instruction.
● It is often used with branch-type instructions.
● Example:
Let PC contains the number 825.
The address part of the instruction contains the number 24.
The instruction at location 825 is read from memory during the fetch phase and the program
counter is then incremented by one to 826.
The effective address computation for the relative address mode is 826 + 24 = 850.
29
9. Indexed Addressing Mode
● Content of an index register is added to the address part of the instruction to obtain the
effective address.
● The index register is a special CPU register that contains an index value.
● The address field of the instruction defines the beginning address of a data array in memory.
● The distance between the beginning address and the address of the operand is the index value
stored in the index register.
● Any operand in the array can be accessed with the same instruction if the index register
contains the correct index value.
● The index register can be incremented to facilitate access to consecutive operands.
30
10. Base Register Addressing Mode
● In this mode the content of a base register is added to the address part of the instruction to
obtain the effective address.
● Similar to the indexed addressing mode except that the register is now called a base register.
● The difference between the two modes is in the way they are used rather than in the way that
they are computed.
● A base register holds a base address and the address field of the instruction gives a
displacement relative to this base address.
● This mode is used to facilitate the relocation of programs in memory.
● When programs and data are moved from one segment of memory to another, as required in
multiprogramming systems, the address values of instructions must reflect this change of
position.
● Here only the value of the base register requires updating to reflect the beginning of a new
memory segment.
31
Data Transfer and Manipulation
32
Data Transfer & Manipulation
33
● Computers provide an extensive set of instructions to give the user the flexibility to carry out
various computational tasks.
● The basic set of operations available in a typical computer can be classified into three
categories:
1. Data transfer instructions
2. Data manipulation instructions
3. Program control instructions
● Data transfer instructions cause transfer of data from one location to another without
changing the binary information content.
● Data manipulation instructions are those that perform arithmetic, logic, and shift operations.
● Program control instructions provide decision-making capabilities and change the path taken
by the program when executed in the computer.
Data Transfer Instruction
● Data transfer instructions move data from one place in the computer to another without
changing the data content.
● The most common transfers are between memory and processor registers, between processor
registers and input or output, and between the processor registers themselves.
● Typical Instructions are,
1. Load (LD) - Transfer from memory to a processor register, usually an accumulator.
2. Store (ST) - Transfer from a processor register into memory.
3. Move (MOV) - Transfer from one register to another.
4. Exchange (XCH) - Swaps information between two registers or a register and a memory
word.
5. Input (IN), Output (OUT) - Transfer data among processor registers and input or output
terminals.
6. Push (PUSH), Pop(POP) - Transfer data between processor registers and a memory stack.
34
Data Manipulation Instructions
● Perform operations on data and provide the computational capabilities for the computer.
● Divided into three basic types:
1. Arithmetic instructions.
2. Logical and bit manipulation instructions.
3. Shift instructions.
35
Arithmetic Instructions
● Increment (INC) : adds 1 to the value stored in a register or memory word.
● Decrement (DEC) : subtracts 1 from a value stored in a register or memory word.
● Add (ADD) : Addition.
● Subtract (SUB) : Subtraction.
● Multiply (MUL) : Multiplication.
● Divide (DIV) : Division.
● Add with carry (ADDC) : Performs the addition on two operands plus the value of the carry
from the previous computation.
● Subtract with borrow (SUBB) : Subtracts two words and a borrow which may have resulted
from a previous subtract operation.
● Negate (NEG) : Forms the 2’s complement of a number.
36
Logical and Bit Manipulation Instructions
● Clear (CLR)
● Complement (COM)
● AND (AND)
● OR (OR)
● Exclusive-OR (XOR)
● Clear carry (CLRC)
● Set carry (SETC)
● Complement carry (COMC)
● Enable interrupt (EI)
● Disable interrupt (DI)
37
Shift Instructions
● Shifts are operations in which the bits of a word are moved to the left or right.
● The bit shifted in at the end of the word determines the type of shift used.
● Types
1. Logical Shift.
2. Arithmetic Shift
3. Rotate Shift
38
Logical Shift
● Inserts 0 to the end bit position.
● The end position is the leftmost bit for shift right and the rightmost bit for the shift left.
39
Logical Shift Right (SHR) Logical Shift Left (SHL)
11010 to 01101 11010 to 10100
Arithmetic Shift
● Arithmetic Shift Right - Preserve sign bit in the left most position. Sign bit shifted to right along
with other numbers but sign bit remain unchanged.
40
Arithmetic Shift Right (SHRA) Arithmetic Shift Left (SHLA)
11010 to 11011 11010 to 10100
Rotate Shift
● Bits are shifted out one end are not lost but circulated back into other end.
● Rotate Left Through Carry(ROLC), Rotate right through Carry (RORC) treats carry bit as an
extension of register whose word is being rotated.
41
Rotate Right (ROR) Rotate Left (ROL)
10110 to 01011 10110 to 01101
Program Control
42
Program Control Instructions
● Program control instructions specify conditions for altering the content of the program
counter.
● Provides decision making capabilities.
● Branch (BR) : BR ADR, branch the program to Address ADR. (PC←ADR)
● Jump (JMP)
● Skip (SKP) : Skip instruction(PC←PC + 1) if some condition is met.
● Call (CALL) : Used with subroutines
● Return (RET)
● Compare (CMP) : Compare by subtraction.
● Test (by ANDing) TST : AND instruction without storing result.
43
44
www.teachics.org

More Related Content

PDF
Control Unit Design
PPTX
Micro Programmed Control Unit
PPTX
Von-Neumann machine and IAS architecture
PPT
Basic operational concepts.ppt
PPTX
Computer organization algorithms like addition and subtraction and multiplica...
PPT
Memory Reference instruction
PPTX
Instruction Formats
PPTX
Ppt of operations on one way link list
Control Unit Design
Micro Programmed Control Unit
Von-Neumann machine and IAS architecture
Basic operational concepts.ppt
Computer organization algorithms like addition and subtraction and multiplica...
Memory Reference instruction
Instruction Formats
Ppt of operations on one way link list

What's hot (20)

PPTX
6-Role of Parser, Construction of Parse Tree and Elimination of Ambiguity-06-...
PPT
Unit 3 basic processing unit
PDF
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
PPTX
Computer organization and architecture
PPTX
priority interrupt computer organization
PPT
I/O System
PDF
Chapter 4 flip flop for students
PPT
Computer organisation Module 1.ppt
PPTX
Addressing modes
PPTX
Micro programmed control
PPT
Infix to Postfix Conversion Using Stack
PDF
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
PDF
Programed I/O Modul..
PDF
CS304PC:Computer Organization and Architecture UNIT I.pdf
PPTX
Basic Processing Unit
PPT
Types of instructions
PPTX
Stacks & subroutines 1
PPT
Memory hierarchy
PDF
8085 stack & machine control instruction
PPTX
Register organization, stack
6-Role of Parser, Construction of Parse Tree and Elimination of Ambiguity-06-...
Unit 3 basic processing unit
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
Computer organization and architecture
priority interrupt computer organization
I/O System
Chapter 4 flip flop for students
Computer organisation Module 1.ppt
Addressing modes
Micro programmed control
Infix to Postfix Conversion Using Stack
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Programed I/O Modul..
CS304PC:Computer Organization and Architecture UNIT I.pdf
Basic Processing Unit
Types of instructions
Stacks & subroutines 1
Memory hierarchy
8085 stack & machine control instruction
Register organization, stack
Ad

Similar to Computer organisation and architecture jntuh 2rd year 2nd unit # central processing unit and stuff unit-2 ppt.pptx (20)

PPTX
unit-2 notesdivision akgorithmdivi.pptx
PPTX
UNIT-3.pptx
PPT
Computer Organisation and Architecture
PPTX
Central processing unit pptx for computer engineering
PPT
B.sc cs-ii-u-4 central processing unit and pipeline
PPT
central processing unit and pipeline
PPT
Mca i-u-4 central processing unit and pipeline
PPT
Bca 2nd sem-u-4 central processing unit and pipeline
PPT
central processing unit.ppt
PPT
unit-3-L1.ppt
DOCX
Computer Organization and 8085 microprocessor notes
PPTX
2024_lecture11__come321.pptx.......................
PDF
7. CPU_Unit3 (1).pdf
PPT
CAO_Unit-3.ppt
PPT
CH-3 CPU Computer architecture and organization.ppt
DOCX
Central processing unit
PPT
CO by Rakesh Roshan
PDF
UNIT-3-COrtertertertertertertertertr.pdf
PPT
Addressing modes (detailed data path)
PPTX
CO UNIT 4 pptx in computer organizations
unit-2 notesdivision akgorithmdivi.pptx
UNIT-3.pptx
Computer Organisation and Architecture
Central processing unit pptx for computer engineering
B.sc cs-ii-u-4 central processing unit and pipeline
central processing unit and pipeline
Mca i-u-4 central processing unit and pipeline
Bca 2nd sem-u-4 central processing unit and pipeline
central processing unit.ppt
unit-3-L1.ppt
Computer Organization and 8085 microprocessor notes
2024_lecture11__come321.pptx.......................
7. CPU_Unit3 (1).pdf
CAO_Unit-3.ppt
CH-3 CPU Computer architecture and organization.ppt
Central processing unit
CO by Rakesh Roshan
UNIT-3-COrtertertertertertertertertr.pdf
Addressing modes (detailed data path)
CO UNIT 4 pptx in computer organizations
Ad

Recently uploaded (20)

PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PPTX
Principal presentation for NAAC (1).pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
Software Engineering and software moduleing
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PPTX
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPTX
mechattonicsand iotwith sensor and actuator
PPTX
ai_satellite_crop_management_20250815030350.pptx
PPTX
Feature types and data preprocessing steps
PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
PPT
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
Measurement Uncertainty and Measurement System analysis
PDF
Cryptography and Network Security-Module-I.pdf
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
Module 8- Technological and Communication Skills.pptx
20250617 - IR - Global Guide for HR - 51 pages.pdf
Principal presentation for NAAC (1).pptx
distributed database system" (DDBS) is often used to refer to both the distri...
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
Computer organization and architecuture Digital Notes....pdf
Exploratory_Data_Analysis_Fundamentals.pdf
Software Engineering and software moduleing
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
MLpara ingenieira CIVIL, meca Y AMBIENTAL
mechattonicsand iotwith sensor and actuator
ai_satellite_crop_management_20250815030350.pptx
Feature types and data preprocessing steps
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Measurement Uncertainty and Measurement System analysis
Cryptography and Network Security-Module-I.pdf
August -2025_Top10 Read_Articles_ijait.pdf
Module 8- Technological and Communication Skills.pptx

Computer organisation and architecture jntuh 2rd year 2nd unit # central processing unit and stuff unit-2 ppt.pptx

  • 3. Central Processing Unit ● The part of the computer that performs the data-processing operations is called the central processing unit(CPU). ● The register set stores data used during the execution of the instructions. ● ALU performs the required microoperations for executing the instructions. ● The control unit supervises the transfer of information among the registers and instructs the ALU as to which operation to perform. 3
  • 4. General Register Organization ● Registers are used to store the intermediate values during instruction execution. ● Register organization show how registers are selected and how data flow between register and ALU. ● A decoder is used to select a particular register. ● The output of each register is connected to two multiplexers to form the two buses A and B. ● The selection lines in each multiplexer select the input data for the particular bus. ● The A and B buses form the two inputs of an ALU. ● The operation select lines decide the micro operation to be performed by ALU. 4
  • 5. General Register Organization ● The result of the micro operation is available at the output bus. ● The output bus connected to the inputs of all registers, thus by selecting a destination register it is possible to store the result in it. Example : To perform R1 ← R2 + R3, 1. MUX A selector (SELA): to place the content of R2 into bus A. 2. MUX B selector (SELB): to place the content of R3 into bus B. 3. ALU operation selector (OPR): to provide the arithmetic addition A. 4. Decoder destination selector (SELD): to transfer the content of the output bus into R1. 5
  • 6. Control Word ● The combined value of a binary selection inputs specifies the control word. ● It consist of four fields SELA,SELB,and SELD contains three bit each and OPR field contains four bits thus the total bits in the control word are 13-bits. ● The three bit of SELA select a source registers of the a input of the ALU. ● The three bits of SELB select a source registers of the b input of the ALU. ● The three bits of SELD select a destination register using the decoder. ● The four bits of OPR select the operation to be performed by ALU. 6
  • 9. Stack Organization 9 ● A useful feature that is included in the CPU of most computers is a stack or last-in, first-out (LIFO) list. ● The register that holds the address for the stack is called a stack pointer (SP) because its value always points at the top item in the stack. ● The stack in digital computers is essentially a memory unit with an address register that can count only after an initial value is loaded into it. ● The two operations of a stack are the insertion and deletion of items.
  • 10. Register Stack ● Stack can be placed in a portion of a large memory or it can be organized as a collection of a finite number of memory words or registers. ● The stack pointer register SP contains a binary number = address of the word that is currently on top of the stack. ● In a 64-word stack, the stack pointer contains 6 bits because 26 = 64. ● Three items are placed in the stack: A, B, and C, in that order. ● Item C is on top of the stack so that the content of SP is now 3. 10
  • 11. Register Stack ● FULL = 1 , when stack is full & EMPTY=1 if stack is empty ● Initially SP=0, EMPTY=1 and FULL=0 To delete an item. ● Item is deleted, if the stack is not empty. ● Read the top item into DR. ● If SP reaches 0, EMPTY is set to 1. ● Decrement SP by 1. ● DR ← M [SP] SP ← SP — 1 If (SP = 0) then (EMTY ← 1) FULL ← 0 11
  • 12. Register Stack To Insert a new item. ● Item is pussed only if stack is not full. ● Incerement SP by 1. ● Write a word in that higher location. ● If SP reaches 0, the stack is full of items, so FULL is set to 1. ● SP ← SP + 1 M [SP ] ← DR If (SP=0) then (FULL ← 1) EMTY ← 0 12
  • 13. Memory Stack ● Implementated by assigning a portion of memory to a stack operation and using a processor register as a stack pointer. ● The program counter (PC) points at the address of the next instruction in the program. ● PC is used during the fetch phase to read an instruction. ● The address register (AR) points at an array of data. ● AR is used during the execute phase to read an operand. ● The stack pointer SP points at the top of the stack. ● P is used to push or pop items into or the stack. ● Advantage - CPU can refer to it without having to specify an address (instead use SP). 13
  • 15. Instruction Formats 15 ● The bits of the instruction are divided into groups called fields. 1. Opcode field - specifies the operation to be performed. 2. Address field - specifies a memory address / processor register. 3. Mode field - specifies the way the operand or the effective address is determined. ● The number of address fields depends on the internal organization of registers. ● Three types of CPU organizations: 1. Single accumulator organization. Eg: ADD X 2. General register organization. Eg: ADD R1, R2, R3 - MOV R1, R2 3. Stack organization Eg: PUSH X ● Based on these, instructions are classified into four formats.
  • 16. ● Computers with three-address instruction formats can use each address field to specify either a processor register or a memory operand. ● The program in assembly language that evaluates X = (A + B) * (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* R2 ● Advantage - It results in short programs when evaluating arithmetic expressions. ● Disadvantage - The binary-coded instructions require too many bits to specify three addresses. ● Eg: Commercial computer Cyber 170. Three-Address Instruction 16
  • 17. ● Two-address instructions are the most common in commercial computers. ● Here again each address field can specify either a processor register or a memory word. ● The program to evaluate X = (A + B) * (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 + M[D] MUL R1, R2 // R1 ← R1*R2 MOV X, R1 // M[X] ← R1 Two-Address Instruction 17
  • 18. ● Use an implied accumulator (AC) register for all data manipulation. ● Here we neglect the second register and assume that the AC contains the result of all operations. ● The program to evaluate X = (A + B) * (C + D) LOAD A // AC ← M[A] ADD B // AC ← AC + M[B] STORE T // M[T] ← ΑC LOAD C // AC ← M[C] ADD D // AC ← AC + M[D] MUL T // AC ← AC * M[T] STORE X // M[X] ← AC ● T is the address of a temporary memory location required for storing the intermediate result. One-Address Instruction 18
  • 19. ● Used in stack-organized computers. ● The program to evaluate X = (A + B) * (C + D) for a stack-organized computer PUSH A // TOS ← A PUSH B // TOS ← B ADD // TOS ← (A + B) PUSH C // TOS ← C PUSH D // TOS ← D ADD // TOS ← (C + D) MUL // TOS ← (C + D)*(A + B) POP X // M[X] ← TOS ● To evaluate arithmetic expressions in a stack computer, it is necessary to convert the expression into reverse Polish notation. Zero-Address Instruction 19
  • 21. Addressing Mode ● The operation field of an instruction specifies the operation to be performed. ● This operation must be executed on some data stored in computer registers or memory words. ● The way the operands are chosen during program execution is dependent on the addressing mode of the instruction. ● The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. ● Computers use addressing mode techniques for the purpose of accommodating one or both of the following provisions: 1. To give programming versatility to the user by providing such facilities as pointers to memory, counters for loop control, indexing of data, and program relocation. 2. To reduce the number of bits in the addressing field of the instruction 21
  • 22. 1. Implied Mode ● The operands are specified implicitly in the definition of the instruction. ● Eg: CMA - Complement Accumulator. ● All register reference instructions that use an accumulator are implied-mode instructions. ● Zero-address instructions in a stack-organized computer are implied-mode instructions since the operands are implied to be on top of the stack. 22
  • 23. 2. Immediate Mode ● The operand is specified in the instruction itself. ● I has an operand field rather than an address field. ● The operand field contains the actual operand to be used in conjunction with the operation specified in the instruction. ● They are are useful for initializing registers to a constant value. ● Eg: ADD 7 23
  • 24. 3. Register Mode ● The address field specifies a processor register. ● In this mode the operands are in registers that reside within the CPU. ● The particular register is selected from a register field in the instruction. ● A k-bit field can specify any one of 2k registers. ● Eg: ADD R1 24
  • 25. 4. Register Indirect Mode ● The instruction specifies a register in the CPU whose contents give the address of the operand in memory. ● The selected register contains the address of the operand rather than the operand itself. ● Before using a register indirect mode instruction, the programmer must ensure that the memory address of the operand is placed in the processor register with a previous instruction. ● Advantage - The address field of the instruction uses fewer bits to select a register. 25
  • 26. 5. Autoincrement or Autodecrement Mode ● Similar to the register indirect mode except that the register is incremented or decremented after (or before) its value is used to access memory. ● When the address stored in the register refers to a table of data in memory, it is necessary to increment or decrement the register after every access to the table. ● This can be achieved by using the increment or decrement instruction. 26
  • 27. 6.Direct Address Mode ● The effective address is equal to the address part of the instruction. ● The operand resides in memory and its address is given directly by the address field of the instruction. ● In a branch-type instruction the address field specifies the actual branch address. 27
  • 28. 7. Indirect Address Mode ● The address field of the instruction gives the address where the effective address is stored in memory. ● Control fetches the instruction from memory and uses its address part to access memory again to read the effective address. 28
  • 29. 8. Relative Address Mode ● Content of the program counter is added to the address part of the instruction in order to obtain the effective address. ● The address part of the instruction is usually a signed number (positive or negative). ● This number is added to the content of the program counter, producing an effective address whose position in memory is relative to the address of the next instruction. ● It is often used with branch-type instructions. ● Example: Let PC contains the number 825. The address part of the instruction contains the number 24. The instruction at location 825 is read from memory during the fetch phase and the program counter is then incremented by one to 826. The effective address computation for the relative address mode is 826 + 24 = 850. 29
  • 30. 9. Indexed Addressing Mode ● Content of an index register is added to the address part of the instruction to obtain the effective address. ● The index register is a special CPU register that contains an index value. ● The address field of the instruction defines the beginning address of a data array in memory. ● The distance between the beginning address and the address of the operand is the index value stored in the index register. ● Any operand in the array can be accessed with the same instruction if the index register contains the correct index value. ● The index register can be incremented to facilitate access to consecutive operands. 30
  • 31. 10. Base Register Addressing Mode ● In this mode the content of a base register is added to the address part of the instruction to obtain the effective address. ● Similar to the indexed addressing mode except that the register is now called a base register. ● The difference between the two modes is in the way they are used rather than in the way that they are computed. ● A base register holds a base address and the address field of the instruction gives a displacement relative to this base address. ● This mode is used to facilitate the relocation of programs in memory. ● When programs and data are moved from one segment of memory to another, as required in multiprogramming systems, the address values of instructions must reflect this change of position. ● Here only the value of the base register requires updating to reflect the beginning of a new memory segment. 31
  • 32. Data Transfer and Manipulation 32
  • 33. Data Transfer & Manipulation 33 ● Computers provide an extensive set of instructions to give the user the flexibility to carry out various computational tasks. ● The basic set of operations available in a typical computer can be classified into three categories: 1. Data transfer instructions 2. Data manipulation instructions 3. Program control instructions ● Data transfer instructions cause transfer of data from one location to another without changing the binary information content. ● Data manipulation instructions are those that perform arithmetic, logic, and shift operations. ● Program control instructions provide decision-making capabilities and change the path taken by the program when executed in the computer.
  • 34. Data Transfer Instruction ● Data transfer instructions move data from one place in the computer to another without changing the data content. ● The most common transfers are between memory and processor registers, between processor registers and input or output, and between the processor registers themselves. ● Typical Instructions are, 1. Load (LD) - Transfer from memory to a processor register, usually an accumulator. 2. Store (ST) - Transfer from a processor register into memory. 3. Move (MOV) - Transfer from one register to another. 4. Exchange (XCH) - Swaps information between two registers or a register and a memory word. 5. Input (IN), Output (OUT) - Transfer data among processor registers and input or output terminals. 6. Push (PUSH), Pop(POP) - Transfer data between processor registers and a memory stack. 34
  • 35. Data Manipulation Instructions ● Perform operations on data and provide the computational capabilities for the computer. ● Divided into three basic types: 1. Arithmetic instructions. 2. Logical and bit manipulation instructions. 3. Shift instructions. 35
  • 36. Arithmetic Instructions ● Increment (INC) : adds 1 to the value stored in a register or memory word. ● Decrement (DEC) : subtracts 1 from a value stored in a register or memory word. ● Add (ADD) : Addition. ● Subtract (SUB) : Subtraction. ● Multiply (MUL) : Multiplication. ● Divide (DIV) : Division. ● Add with carry (ADDC) : Performs the addition on two operands plus the value of the carry from the previous computation. ● Subtract with borrow (SUBB) : Subtracts two words and a borrow which may have resulted from a previous subtract operation. ● Negate (NEG) : Forms the 2’s complement of a number. 36
  • 37. Logical and Bit Manipulation Instructions ● Clear (CLR) ● Complement (COM) ● AND (AND) ● OR (OR) ● Exclusive-OR (XOR) ● Clear carry (CLRC) ● Set carry (SETC) ● Complement carry (COMC) ● Enable interrupt (EI) ● Disable interrupt (DI) 37
  • 38. Shift Instructions ● Shifts are operations in which the bits of a word are moved to the left or right. ● The bit shifted in at the end of the word determines the type of shift used. ● Types 1. Logical Shift. 2. Arithmetic Shift 3. Rotate Shift 38
  • 39. Logical Shift ● Inserts 0 to the end bit position. ● The end position is the leftmost bit for shift right and the rightmost bit for the shift left. 39 Logical Shift Right (SHR) Logical Shift Left (SHL) 11010 to 01101 11010 to 10100
  • 40. Arithmetic Shift ● Arithmetic Shift Right - Preserve sign bit in the left most position. Sign bit shifted to right along with other numbers but sign bit remain unchanged. 40 Arithmetic Shift Right (SHRA) Arithmetic Shift Left (SHLA) 11010 to 11011 11010 to 10100
  • 41. Rotate Shift ● Bits are shifted out one end are not lost but circulated back into other end. ● Rotate Left Through Carry(ROLC), Rotate right through Carry (RORC) treats carry bit as an extension of register whose word is being rotated. 41 Rotate Right (ROR) Rotate Left (ROL) 10110 to 01011 10110 to 01101
  • 43. Program Control Instructions ● Program control instructions specify conditions for altering the content of the program counter. ● Provides decision making capabilities. ● Branch (BR) : BR ADR, branch the program to Address ADR. (PC←ADR) ● Jump (JMP) ● Skip (SKP) : Skip instruction(PC←PC + 1) if some condition is met. ● Call (CALL) : Used with subroutines ● Return (RET) ● Compare (CMP) : Compare by subtraction. ● Test (by ANDing) TST : AND instruction without storing result. 43