Fundamentals of Computer Architecture: Unit - I
Fundamentals of Computer Architecture: Unit - I
ARCHITECTURE
Unit - I
TOPICS OF UNIT - I
01/10/2021
Organization of the von Neumann machine
Instruction formats
01/10/2021
Computer has single storage system(memory) for storing data as well as
program to be executed.
Processor needs two clock cycles to complete an instruction (Query and
Reply)
01/10/2021
A word may contain:
A numbers stored as 40 binary digits (bits) – sign bit + 39 bit value
An instruction-pair. Each instruction:
An opcode (8 bits)
An address (12 bits) – designating one of the 1000 words in memory.
5
HARVARD ARCHITECTURE
01/10/2021
Computer has two separate memories for storing data and program
Processor can complete an instruction in one cycle
Pipelining is possible
6
INSTRUCTION FORMAT
01/10/2021
An instruction set, or instruction set architecture (ISA), is the part of
the computer architecture related to programming.
7
01/10/2021
8
COMPUTER FUNCTION
01/10/2021
The basic function performed by a computer is execution
of a program, which consists of a set of instructions
stored in memory.
Instruction fetch-decode-execute
9
MBR: Memory Buffer Register
- contains the word to be stored in
memory or just received from memory.
01/10/2021
MAR: Memory Address Register
- specifies the address in memory of
the word to be stored or retrieved.
IR: Instruction Register - contains
the 8-bit opcode currently being
executed.
IBR: Instruction Buffer Register
- temporary store for RHS instruction
from word in memory.
PC: Program Counter - address of
next instruction-pair to fetch from
memory.
AC: Accumulator & MQ: Multiplier
10
quotient - holds operands and results
of ALU ops.
THE FETCH/EXECUTE CYCLE
01/10/2021
Standard process.
Also called as
fetch-and-execute cycle,
fetch-decode-execute cycle
FDX
11
QUESTIONS:
01/10/2021
MBR –
MAR –
AC –
IBR –
IR –
PC –
MQ –
IAS –
What is Computer Architecture?
What is Computer Organization?
Number of words in IAS machine?
Number of bits per word in IAS machine?
Data is represented in ____________ form in IAS machine 12
Explain Stored program concept.
REGISTERS AND REGISTER FILES
01/10/2021
Registers?
Group of Flip-flops capable of storing one bit of information.
N bits.
Provides storage internal to the CPU.
01/10/2021
The length of a register equals the number of bits it can store.
Hence, a register that can store 8 bits is normally referred to as 8-bit
register.
Most CPU sold today, have 32-bit or 64-bit registers.
The size of the registers is sometimes called the world size.
The bigger the world size, the faster the computer can process a set
of data.
With all other parameters being same, a CPU with 32-bit registers,
can process data twice as fast as one with 16-bit registers.
14
01/10/2021
15
REGISTER FILES (RF)
01/10/2021
Set of general purpose registers.
It functions as small RAM and implemented using fast RAM
technology.
RF needs several access ports for simultaneously reading from
or writing to several different registers. Hence RF is realized as
multiport RAM.
A standard RAM has just one access port with an associated
address bus and data bus.
16
A REGISTER FILE WITH THREE ACCESS PORTS -
SYMBOL
01/10/2021
Data in C
16
2
Address C Port C
Register File
RF
2 2
Address A Port A Port B Address B
16 16
Data out A Data out B
17
A REGISTER FILE WITH THREE ACCESS PORTS – LOGIC DIAGRAM
1011 Ex: R3 ← R1 + R2
Data in C Read Address A = 01
16 Read Address B = 10
Write Address C = 11
01/10/2021
2 4-way 16-bit
Write 11
S demultiplexer
address C
16 16 16 16
01/10/2021
Data transfer instructions
19
DATA TRANSFER INSTRUCTIONS
Move data from one place to another without changing the data
01/10/2021
content in the computer.
20
SET OF DATA TRANSFER INSTRUCTIONS
Load – transfer from memory to a processor register
Store – transfer from processor register into memory
01/10/2021
Move – transfer from one register to another, transfer between
register and memory or between two memory words.
Exchange – swaps information between two registers or a
register and a memory word
Input – transfer data among registers/memory and input
terminal
Output – transfer data among register/memory and output
terminal
Push – transfer data from register/memory to memory stack
01/10/2021
capabilities for the computer.
Arithmetic instructions
Increment
Decrement
Add
Subtract
Multiply
Divide
Add with carry
Subtract with borrow
Negate (2’s complement) – change the sign of the operand
Absolute – replace operand by its absolute value
Arithmetic shift left 22
Arithmetic shift right
01/10/2021
24
Arithmetic shift left
0 0 0 1 1 0 1 0
01/10/2021
Sign bit
Sign bit
0
Sign bit
0
0 0 0 1 1 0 1 0
01/10/2021
Sign bit
Sign bit
Sign bit
01/10/2021
Clear (can also be included in data transfer instruction based on the way
the operation is performed – 0’s transferred to the destination)
Complement
AND- to clear a bit
OR – set a bit
Ex-Or –to complement a bit
Clear carry
Set carry
Complement carry
Enable interrupt – flip-flop that controls the interrupt facility is enabled
Disable interrupt – flip-flop that controls the interrupt facility is disabled
27
DATA MANIPULATION INSTRUCTIONS
01/10/2021
Shift Instructions
Logical left shift
Logical right shift
Arithmetic shift left
Arithmetic shift right
Rotate right
Rotate left
Rotate right through carry
Rotate left through carry
28
Logical shift left
0 0 0 1 1 0 1 0
01/10/2021
0 0 0 1 1 0 1 0 Shift by 1 bit towards left
0
Logical shift Right
0 0 0 1 1 0 1 0
01/10/2021
0 0 0 0 1 1 0 1 0 Shift by 1 bit towards right
0 0 0 1 1 0 1 0
01/10/2021
0 0 0 1 1 0 1 0 Rotate by 1 bit towards left
Buffer
Buffer
0 0 0 1 1 0 1 0
01/10/2021
rotate by 1 bit towards right
0 0 0 1 1 0 1 0
Buffer
Buffer
0 0 0 1 1 0 1 0
01/10/2021
Rotate by 1 bit towards left
0 0 0 1 1 0 1 0 0
Buffer Carry
Buffer Carry
Buffer Carry 33
Rotate right through carry
0 0 0 1 1 0 1 0
01/10/2021
rotate by 1 bit towards right
0 0 0 0 1 1 0 1 0
Carry Buffer
01/10/2021
Branch
Jump
Skip
Call
Return
35
ADDRESSING MODES
01/10/2021
The way the operands are chosen during the
program execution is dependent on the addressing mode
of the instruction.
36
DIFFERENT TYPES
Implied Addressing Mode
01/10/2021
Immediate Addressing Mode
Direct Addressing Mode
Indirect Addressing Mode
Register Direct Addressing Mode
Register Indirect Addressing Mode
Displacement Addressing Mode (combines the direct
addressing and register addressing modes)
Relative Addressing Mode
Indexed Addressing Mode
Base Addressing Mode
Auto Increment and Auto Decrement Addressing Mode
37
IMPLIED ADDRESSING MODE
01/10/2021
No address field is required
Operand is implied / implicit
Ex:
Complementing Accumulator
Set or Clearing the flag bits (CLC, STC etc.)
0 – address instructions in a stack organized computer
are implied mode instructions.
Effective Address (EA) = AC or Stack[SP]
Ex: Tomorrow, I am on leave (implies that there is no
CAO class)
Come to my cabin (implies to come to 411-A32 SJT)
38
01/10/2021
Examples: CLA , CME , INP . It is mainly used for
Zero-address (STACK-organized) and One-
address (ACCUMULATOR-organized) instructions.
39
IMMEDIATE ADDRESSING MODE
01/10/2021
Operand is specified in the instruction itself
Useful for initializing the registers with constant
value
Operand = address field
40
DIRECT ADDRESSING MODE
01/10/2021
Effective address is the address part of the
instruction
EA (effective address) = A
Ex:
Mov CX, [4200]H
Advantage: Simple memory reference to access
data, no additional calculations to work out
effective address
Disadvantage: Limited address space
Ex: Aashiq, please bring my laptop from my
cabin (cabin is known to Aashiq)
41
INDIRECT ADDRESSING MODE
01/10/2021
The address field of the instruction gives the
address of the effective address of the operand
stored in the memory.
EA = (A)
Ex: Mov CX, [BX]
Advantage: Large address space, may be nested,
multilevel or cascaded
Disadvantage: Multiple memory accesses to find
the operand, hence slower
42
INDIRECT ADDRESSING MODE
DIAGRAM
01/10/2021
43
REGISTER DIRECT ADDRESSING
MODE
01/10/2021
Operand is in the register specified in the address
part of the instruction
EA = R
Ex: Mov AX, [BX]
Special case of direct addressing
Advantage: No memory reference, shorter
instructions, faster instruction fetch, very fast
execution
Disadvantage: Limited address space as limited
number of registers
44
REGISTER ADDRESSING DIAGRAM
01/10/2021
45
REGISTER INDIRECT ADDRESSING
MODE
01/10/2021
Address part of the instruction specifies the register
which gives the address of the operand in memory
Special case of indirect addressing
EA = (R)
46
01/10/2021
47
DISPLACEMENT ADDRESSING MODE
EA = A + (R)
Address field holds two values
01/10/2021
A = Base value
R = register that holds displacement
Or vice-versa
48
RELATIVE ADDRESSING MODE
01/10/2021
Version of the displacement addressing
R = program counter, PC
Content of PC is added to address part of the instruction
to obtain the effective address of the operand
EA = A + (PC)
It is often used in branch (conditional and unconditional)
instructions, locality of reference and cache usage
Advantage: Flexibility
Disadvantage: Complexity
49
INDEXED ADDRESSING MODE
01/10/2021
A holds base address
R holds displacement, may be explicit or implicit
(segment registers in 8086)
Content of the index register is added to the
address part of the instruction to obtain effective
address of the operand.
Used in performing iterative operations
EA = A + (SI)
Ex: Mov CX, [SI] 2400H
Advantage: Flexibility, good for accessing arrays
Disadvantage: Complexity
50
BASE REGISTER ADDRESSING MODE
01/10/2021
The content of the base register is added to the
address part of the instruction to obtain the
effective address of the operand.
Used to facilitate the relocation of programs in
memory.
EA = A + (BX)
Advantage: Flexibility
Disadvantage: Complexity
51
AUTO INCREMENT AND AUTO
DECREMENT ADDRESSING MODES
01/10/2021
This addressing mode is used 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.
Ex: Mov AX, (BX)+, Mov AX, -(BX)
52
01/10/2021
53
16 BIT ADDITION
01/10/2021
4100 C3 CLR C Clear carry
4101 74,04 MOV A, #DATA1 Move data1 to acc
4103 24,02 ADD A, #DATA2 Add data2 with acc
4105 90,41,50 MOV DPTR, #4150h Move content in 4500 to
DPTR.
01/10/2021
410C D6, 64 SUI 64 Subtract data from acc
01/10/2021
56
EXAMPLE PROBLEM
01/10/2021
The most appropriate matching for the following pairs is-
Column-1:
X: Indirect addressing
Y: Immediate addressing
Column-2:
1. Loops
2. Pointers
3. Constants
01/10/2021 59
01/10/2021
2. An instruction is stored at location 300 with its
address field at location 301. The address field has the
value 400. A processor register R1 contains the number
200. Evaluate the effective address if the addressing
mode of the instruction is (a) direct; (b) immediate (c)
relative (d) register indirect; (e) index with R1 as the
index register.
60
SUBROUTINE CALL AND
RETURN MECHANISMS
SUBROUTINE
Subroutine is a self-contained sequence of instructions
that performs a given computational task.
It may be called many times at various points in the main
program
When called, branches to 1st line of subroutine and at the
end, returned to main program.
Different names to the instruction that transfers program
control to a subroutine
Call subroutine
Jump to subroutine
Branch to subroutine
Branch and save address
CONTROL TRANSFER FROM
CALLED TO CALLER
Subroutine instruction – Opcode + starting
address of the subroutine
Execution:
PC content (return address) is stored in a temporary
location
Control is transferred to the subroutine
when return
Transfers the return address from the temporary
location to the PC.
Control is transferred back to the called routine
LOCATIONS TO STORE THE
RETURN ADDRESS
First memory location of the subroutine
Fixed location in memory
Processor registers
Return:
PC ← M[SP]// pop stack and transfer to PC
SP ← SP + 1 // increment stack pointer
RECURSIVE SUBROUTINES
Subroutine that calls itself
If only one register or memory location is used to hold
the return address, when subroutine is called recursively,
it destroys the previous return address.
So, stack is the good solution for this problem
ASSIGNMENT
1. Write an assembly language program using IAS instruction set for
performing all arithmetic operations (+, -, *, /)
2. Show the register transfer operations using IAS machine registers for
division operation.
3. Given the memory contents of the IAS computer shown below. Show the
assembly language code for the program, starting at address 08A. Explain
what this program does. Given the memory contents of the IAS computer
shown below. Show the assembly language code for the program, starting at
address 08A. Explain what this program does.
Address Contents
08A 010FA210FB
08B 010FA0F08D
08C 020FA210FB
4.Write an Assembly language programming for the following
expressions using IAS computer Instruction set and interpret to the
flow of IAS computer [Any one ]
1. A=(B-C)*D
2. A=B*(C+D)
3. A=(B-C)/D
4. A=B/(C+D)
5. A=-(B+C-D)
6. A=(B*2)/2
Make necessary assumptions.
5. On the IAS, describe in English the process that the CPU must
undertake to read a value from memory and to write a value to
memory in terms of what is put into the MAR, MBR, address bus,
data bus, and control bus.
6. Find out the difference between Multicomputer, Multiprocessor,
Distributed computer, Multicores
7. A two-word instruction is stored in memory at an address
designated by the symbol W. The address field of the
instruction (stored at W + 1) is designated by the symbol Y.
The operand used during the execution of the instruction is
stored at an address symbolized by Z. An index register
contains the value X. State how Z is calculated from the other
addresses if the addressing mode of the instruction is
Direct
Indirect
Relative
Indexed
300 600
500 700
13. Given the following memory values and a one-address machine with an
accumulator, what values do the following instructions load into the accumulator?
Word 20 contains 40
Word 30 contains 50
Word 40 contains 60
Word 50 contains 70
Load immediate 20
Load direct 20
Load indirect 20
Load immediate 30
Load direct 30
Load indirect 30
14. Let the address stored in the program counter be designated by the symbol X1.
The instruction stored in X1 has the address part (operand reference) X2. The
operand needed to execute the instruction is stored in the memory word with
address X3. An index register contains the value X4. What is the relationship
between these various quantities if the addressing mode of the instruction is (a)
direct (b) indirect (c) PC relative (d) indexed?
15. An address field in an instruction contains decimal
value 14. where is the corresponding operand located
for:
Immediate addressing?
Direct addressing?
Indirect addressing?
Register addressing?
Register indirect addressing?