Sandeep - Notes JavaDsa Handwritten Notes
Sandeep - Notes JavaDsa Handwritten Notes
Sandeep - Notes JavaDsa Handwritten Notes
21CSS201T
COMPUTER ORGANIZATION
AND ARCHITECTURE
UNIT-2
Topic : Basic Structure of a
Computer
Computer Types
Computer is a fast electronic calculating machine which accepts digital input,
processes it according to the internally stored instructions (Programs) and produces
the result on the output device. The internal operation of the computer can be as
depicted in the figure below:
Laptop Computer: A portable, compact computer that can run on power supply or
a battery unit. All components are integrated as one compact unit. It is generally
more expensive than a comparable desktop. It is also called a Notebook.
Main Frame: Large expensive computer capable of simultaneously processing data for
hundreds or thousands of users. Used to store, manage, and process large amounts of data
that need to be reliable, secure, and centralized.
Hand Held: It is also called a PDA (Personal Digital Assistant). A computer that fits into a
pocket, runs on batteries, and is used while holding the unit in your hand. Typically used as
an appointment book, address book, calculator and notepad.
Multi Core: Have Multiple Cores – parallel computing platforms. Many Cores or computing
elements in a single chip. Typical Examples: Sony Play station, Core 2 Duo, i3, i7 etc.
25-08-2023 21CSS201T - Computer Organization and Architecture 6
What is a computer?
• a computer is a sophisticated electronic calculating machine
that:
– Accepts input information,
– Processes the information according to a list of internally
stored instructions and
– Produces the resulting output information.
• Functions performed by a computer are:
– Accepting information to be processed as input.
– Storing a list of instructions to process the information.
– Processing the information according to the list of
instructions.
– Providing the results of the processing as output.
• What are the functional units of a computer? 6
25-08-2023 21CSS201T - Computer Organization and Architecture 10
Functions
• ALL computer functions are:
– Data PROCESSING
– Data STORAGE Data =
– Data MOVEMENT Information
– CONTROL Coordinates How
Information is Used
Functions of a computer
The operations performed by a computer using the functional units
can be summarized as follows:
• It accepts information (program and data) through input unit and
transfers it to the memory.
• Information stored in the memory is fetched, under program
control, into an arithmetic and logic unit for processing.
• Processed information leaves the computer through an output
unit.
• The control unit controls all activities taking place inside a
computer.
25-08-2023 21CSS201T - Computer Organization and Architecture 12
Output unit
• Computers represent information in a specific binary form. Output units:
- Interface with output devices.
- Accept processed results provided by the computer in specific binary form.
- Convert the information in binary form to a form understood by
an output device.
Control unit
• Operation of a computer can be summarized as:
– Accepts information from the input units (Input unit).
– Stores the information (Memory).
– Processes the information (ALU).
– Provides processed results through the output units (Output
unit).
• Operations of Input unit, Memory, ALU and Output unit are
coordinated by Control unit.
• Instructions control “what” operations take place (e.g. data transfer,
processing).
• Control unit generates timing signals which determines “when” a
particular operation takes place.
25-08-2023 21CSS201T - Computer Organization
16 and Architecture 16
CONTROL UNIT
R2
Example
Add R1, R2
T1 Enable R1
T2 Enable R2
Registers
Registers are fast stand-alone storage locations that hold data temporarily. Multiple registers are
needed to facilitate the operation of the CPU. Some of these registers are
Bus Structures
BUS STRUCTURE
•Group of wires which carries information form CPU to peripherals or vice –
versa
•Single bus structure: Common bus used to communicate between
peripherals and microprocessor
ADDRESS BUS 1 0 1
D7 D0 1 1 0
D0 D7
1 1 1
DATA BUS
Figure below shows address, data and control bus and their connection with
peripheral and microprocessor
MEMORY HIERARCHY
store 1 bit.
•
Data is usually accessed in n-bit •
•
groups. n is called word length. i th word
•Data is transferred to and from memory in groups of bits called words. A word can be a
group of 8 bits, 16 bits, 32 bits or 64 bits (and growing).
•If the word is 8 bits, it is referred to as a byte. The term “byte” is so common in computer
science that sometimes a 16-bit word is referred to as a 2-byte word, or a 32-bit word is
referred to as a 4-byte word.
Main memory
Address space
•To access a word in memory requires an identifier. Although programmers use a name to
identify a word (or a collection of words), at the hardware level each word is identified by
an address.
•The total number of uniquely identifiable locations in memory is called the address
space.
•For example, a memory with 64 kilobytes (16 address line required) and a word size of 1
byte has an address space that ranges from 0 to 65,535.
Example 1
A computer has 32 MB (megabytes) of memory. How many bits are needed to address any
single byte in memory?
Solution
The memory address space is 32 MB, or 225 (25 × 220). This means that we need log2 225, or 25
bits, to address each byte.
Example 2
A computer has 128 MB of memory. Each word in this computer is eight bytes. How many bits
are needed to address any single word in memory?
Solution
The memory address space is 128 MB, which means 227. However, each word is eight (23)
bytes, which means that we have 224 words. This means that we need log2 224, or 24 bits, to
address each word.
25-08-2023 21CSS201T - Computer Organization and Architecture 48
MEMORY OPERATIONS
• Today, general-purpose computers use a set of instructions called a program to
process data.
• A computer executes the program to create output data from input data
Big Endian
• Big Endian (e.g., in IBM, Motorolla, Sun, HP)
» high order byte stored at lowest address
» byte3 byte2 byte1 byte0
W ord
address Byte address Byte address
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 - 4 2 - 4 2 - 3 2 - 2 2 - 1 2 - 4 2 - 1 2 - 2 2 - 3 2 - 4
• R2 [LOCN]
• R4 [R3] +[R2]
Arithmetic Instructions
Used to perform arithmetic operations
Some instruction in 8086
INC Increment the data by 1
DEC Decreases data by 1
ADD perform sum of data
ADC Add with carry bit.
MUL perform multiplication
Shift instructions
used for shifting or rotating the contents of the register
Some instructions are:
SHR shift bits towards the right and put zero(S) in
MSBs
ROL rotate bits towards the left, i.e. MSB to LSB
and to Carry Flag [CF]
RCL rotate bits towards the left, i.e. MSB to CF and
CF to LSB.
Instruction Formats
(Types of instruction based on the address field)
• A instruction in computer comprises of groups called
fields.
• These field contains different information
• The most common fields are:
Operation field : specifies the operation to be
performed like addition.
Address field : contain the location of
operand
Mode field : specifies how to find the operand
25-08-2023 21CSS201T - Computer Organization and Architecture 65
If processor supports ALU operations one data in memory and other in register
then the instruction sequence is
• MOVE D, Ri
• ADD E, Ri
• MOVE Ri, F
If processor supports ALU operations only with registers then one has to follow
the instruction sequence given below
• LOAD D, Ri
• LOAD E, Rj
• ADD Ri, Rj
• MOVE Rj, F
Instruction Cycle
• the basic operational process of a computer.
• also known as fetch-decode-execute cycle
• This process is repeated continuously by CPU from boot up to shut
down of computer.
steps that occur during an instruction cycle:
1. Fetch the Instruction
2. Decode the Instruction
3. Read the Effective Address
4. Execute the Instruction
25-08-2023 21CSS201T - Computer Organization and Architecture 76
Example 1:
•programs and data are stored in the same
memory, i.e. von Neumann architecture.
•First instruction of a program is stored at
address i.
•PC gives address i and instruction stored at
that address i is fetched from the memory and
then decoded and then operand
•A is fetched from the memory and stored in a
temporary register and then the instruction is
executed(i.e. content of address A is copied into
processor register R0).
•the PC gets incremented by 4(i.e. it contains
the address of the next instruction) because the
instruction and memory segment is of 4 bytes.
•So the instruction at address i is executed.
•So every time, the PC is incremented by 4.
Therefore, the program is executing in a
sequential manner. And this process is called
25-08-2023 straight line sequencing. 21CSS201T - Computer Organization and Architecture 81
Condition Codes
The processor keeps track of information about the results of
various operations for use by subsequent conditional branch
instructions
Addressing Modes
Addressing Modes
Different ways in which the location of the operand is specified in an instruction is referred as addressing
modes. The purpose of using addressing mode is:
To give the programming versatility to the user.
To reduce the number of bits in addressing field of instruction.
Types of Addressing Modes
• Immediate Addressing
• Direct Addressing
• Indirect Addressing
• Register Addressing
• Register Indirect Addressing
• Relative Addressing
• Indexed Addressing
• Auto Increment
• Auto Decrement
25-08-2023 21CSS201T - Computer Organization and Architecture 86
Immediate Addressing
• Operand is given explicitly in the instruction
• e.g. ADD 5
• Add 5 to contents of accumulator
• 5 is operand
• No memory reference to fetch data
• Fast
• Limited range
• MOV AL,25H ; Immediate addressing AL=25
• MOV AX,2345H ; AX=2345 AX=> AH=23 AL=45
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
• MOV AL,DATA1 ; Direct Addressing AL=23
• MOV AX,DATA2 ; AX=1234
• MOV DATA3,AL ; DATA3=23
• MOV DATA4,AX ; DATA4=1234
25-08-2023 21CSS201T - Computer Organization and Architecture 88
Indirect Addressing
• Memory cell pointed to by address field contains the address of (pointer to) the
operand
Two references to memory are required to fetch the operand.
• Effective Address = [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 the accumulator
Indexed Addressing
Relative Addressing
Microprocessors
Microprocessor : is a CPU on a single chip.
Microcontroller: If a microprocessor, its associated support circuitry, memory and
peripheral I/O components are implemented on a single chip, it is a microcontroller.
• We use AVR microcontroller as the example in our course study
Address bus
ALU Register Section
Data bus
Control bus
Microprocessor types
Evolution of Microprocessors
• The first microprocessor was introduced in 1971 by Intel Corp.
• It was named Intel 4004 as it was a 4 bit processor.
Categories according to the generations or size
First Generation (4 - bit Microprocessors)
• could perform simple arithmetic such as addition, subtraction, and logical operations
like Boolean OR and Boolean AND.
• had a control unit capable of performing control functions like
• fetching an instruction from storage memory,
• decoding it, and then
• generating control pulses to execute it.
Typical microprocessors
• Most commonly used
• 68K
• Motorola
• x86
• Intel
• IA-64
• Intel
• MIPS
• Microprocessor without interlocked pipeline stages
• ARM
• Advanced RISC Machine
• PowerPC
• Apple-IBM-Motorola alliance
• Atmel AVR
• A brief summary will be given later
25-08-2023 21CSS201T - Computer Organization and Architecture 115
8086 Microprocessor
• designed by Intel in 1976
• 16-bit Microprocessor having
• 20 address lines
• 16 data lines
• provides up to 1MB storage
• consists of powerful instruction set, which provides operations like multiplication and
division easily.
supports two modes of operation
Maximum mode : suitable for system having multiple processors
Minimum mode : suitable for system having a single processor.
Features of 8086
• Has an instruction queue, which is capable of storing six instruction bytes
• First 16-bit processor having
• 16-bit ALU
• 16-bit registers
• internal data bus
• 16-bit external data bus
uses two stages of pipelining
1. Fetch Stage and
2. Execute Stage
which improves performance.
Fetch stage : can pre-fetch up to 6 bytes of instructions and stores them in the queue.
Execute stage : executes these instructions.
25-08-2023 21CSS201T - Computer Organization and Architecture 117
Architecture of 8086
Segments in 8086
CX – Counter register
16 bit register
divided into two 8-bit registers CH and CL
to perform 8-bit instructions also
Used in looping and rotation
DX – Data register
16 bit register
divided into two 8-bit registers DH and DL to
perform 8-bit instructions also
Used in multiplication an input/output port addressing
IP - Instruction Pointer
16 bit register
stores the address of the next instruction to be executed
also acts as an offset for CS register.
Segment Registers
CS - Code Segment Register:
user cannot modify the content of these registers
Only the microprocessor's compiler can do this
DS - Data Segment Register:
The user can modify the content of the data segment.
SS - Stack Segment Registers:
used to store the information about the memory segment.
operations of the SS are mainly Push and Pop.
ES - Extra Segment Register:
By default, the control of the compiler remains in the DS where the user can add and modify the
instructions
If there is less space in that segment, then ES is used
Also used for copying purpose.
• 16-bit register
• contains 9 flags
• remaining 7 bits are idle in this register
• These flags tell about the status of the processor after any arithmetic or logical
operation
• IF the flag value is 1, the flag is set, and if it is 0, it is said to be reset.
Microcomputer
Introduction to 8086
Assembly Language
Assembly Language Programming