Advanced Computer Architecture
Advanced Computer Architecture
Architecture
Unit-2
Contents
Instruction Set:
1. Characteristics
2. Operand Types
3. Operation Types
4. Addressing Modes
5. Instruction formats
CPU:
Computer Arithmetic operations:
6. ALU
7. Integer Representation and Arithmetic
8. Floating Point Representation and Arithmetic.
Instruction Cycle State Diagram
1. Characteristics
Elements of an Instruction
• Operation code (Op code)
– Specifies the operation to be performed (e.g. ADD)
• Source Operand reference
– The operation involves one or more source operands
• Result Operand reference
– The operation may produce a result
• Next Instruction Reference
– Tell the processor to fetch next instruction...
Simple Instruction Format
• Data types
• Instruction formats
– Length of op code field
– Number of addresses
• Registers
– Number of CPU registers available
• Addressing modes
RISC Vs CISC
2. Types of Operand
The category of data are
• Addresses
• Numbers
– Binary Integer/ Binary floating point, Decimal
• Characters
– ASCII etc.
• Logical Data
– Bits or flag
3. Types of Operation
• Data Transfer
• Arithmetic
• Logical
• Conversion
• I/O
• System Control
• Transfer of Control
Data Transfer
• Specify
– Source
– Destination
– Amount of data
Input/Output
• May be specific instructions
• May be done using data movement instructions (memory
mapped)
• May be done by a separate controller (DMA)
Shift and Rotate Operations
Systems Control
• Privileged instructions
• CPU needs to be in specific state
– Ring 0 on 80386+
– Kernel mode
• For operating systems use
Transfer of Control
• Branch
– e.g. branch to x if result is zero
• Skip
– e.g. increment and skip if zero
– ISZ Register1
– Branch xxxx
• Subroutine call
– interrupt call
Branch Instruction
Nested Procedure Calls
Use of Stack
Stack Frame Growth Using Sample
Procedures P and Q
4. Addressing Modes
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Indexed)
• Stack
Immediate Addressing
• Operand is part of instruction
• Operand = address field
• e.g. ADD 5
– Add 5 to contents of accumulator
– 5 is operand
• No memory reference to fetch data
• Fast
• Limited range
Immediate Addressing Diagram
Instruction
Opcode Operand
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
Indirect Addressing
• Memory cell pointed to by address field contains the address
of (pointer to) the operand
• EA = (A)
– Look in A, find address (A) and look there for operand
• e.g. ADD (A)
– Add contents of cell pointed to by contents of A to
accumulator
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Indirect Addressing
• Large address space
• 2n where n = word length
• May be nested, multilevel, cascaded
– e.g. EA = (((A)))
• Multiple memory accesses to find operand
• Hence slower
Register Addressing
• Operand is held in register named in address filed
• EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
– Requires good assembly programming or compiler writing
Register Addressing Diagram
Instruction
Operand
Register Indirect Addressing
• EA = (R)
• Operand is in memory cell pointed to by contents of register R
• Large address space (2n)
• One fewer memory access than indirect addressing
Register Indirect Addressing Diagram
Instruction
Registers
Registers
• Preindex
• EA = (A+(R))
Stack Addressing
• Operand is (implicitly) on top of stack
e.g.
– ADD Pop top two items from stack
and add
5. Instruction Formats
• Layout of bits in an instruction
• Includes opcode
• Includes (implicit or explicit) operand(s)
• Usually more than one instruction format in an instruction set
Instruction Length
• Affected by and affects:
– Memory size
– Memory organization
– Bus structure
– CPU complexity
– CPU speed
• Trade off between powerful instruction repertoire and saving
space
Allocation of Bits
• Number of addressing modes
• Number of operands
• Register versus memory
• Number of register sets
• Address range
• Address granularity
6. ALU Inputs and Outputs
7. Integer Representation and arithmetic
• +3 = 00000011
• +2 = 00000010
• +1 = 00000001
• +0 = 00000000
• -1 = 11111111
• -2 = 11111110
• -3 = 11111101
Range of Numbers
• 8 bit 2s compliment
– +127 = 01111111 = 27 -1
– -128 = 10000000 = -27
• 16 bit 2s compliment
– +32767 = 011111111 11111111 = 215 - 1
– -32768 = 100000000 00000000 = -215
Conversion Between Lengths
• Positive number pack with leading zeros
• +18 = 00010010
• +18 = 00000000 00010010
• Negative numbers pack with leading ones
• -18 = 10010010
• -18 = 11111111 10010010
• i.e. pack with MSB (sign bit)
Addition and Subtraction
• Normal binary addition
• Monitor sign bit for overflow