0% found this document useful (0 votes)
112 views

Unit 3 Notes Computer Fundamentals

Uploaded by

21it1233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

Unit 3 Notes Computer Fundamentals

Uploaded by

21it1233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

UNIT III COMPUTER FUNDAMENTALS

Computer A Computer is a combination of hardware and software resources which integrate together and
provide various functionality to the user .
Hardware Hardware are the physical components of a computer like the processor , memory
devices , monitor and keyboard etc .,
Software Software is the set of program or instructions that required by the hardware resources to
function properly.
Working cycle of Computer :-

 The input process output cycle are called as the functional components of computer .
 It needs certain input process that input and produces the designed output .
 Output unit produces the output
 Play memory unit holster data and instructions during the processing .

Digital computer

 A digital computer can be defined as programmable machine which reads the binary data .
 passed as instructions, process this binary data and display a calculated digital output .
 Therefore digital computers are those that works on the “ Digital Data “
Functional Units of Digital System

A General purpose computer system is the best known example of a digital system
 A computer consists of 5 main components

 Input unit
 Output unit
 Memory unit
 Arithmetic and logic unit
 Control limit

Input Unit
 The input unit consist of input devices that are attached to the computer.
 These devices take input and convert it into binary language that the computer
understands.
 Some of the common input devices are keyboard ,mouse, joystick and scanner etc .,
Central processing unit
 The CPU is called the” brain of the computer” and it’s the Control unit of the
computer.
 Once the information is entered into the computer by the input device , processor
process it.
 Data /instruction are fetched from memory or input device, the CPU executes or
performs required computations and then either stores the output or displays on the
output device.
The CPU has three main components that are responsible for different functions
 arithmetic logical Unit(ALU)
 control unit
 memory registers
Arithmetic logic unit
 Arithmetic logic unit performs mathematical calculations and takes logical decisions.
 Arithmetic calculation includes addition subtraction multiplication and division.
 Logical decisions involves comparison of two data items to see which one is larger or smaller
or equal

Control Unit
 The Control unit coordinates and controls the data flow in and out of CPU and also controls all
the operations of ALU, memory registers and also input/output units.
 It is also responsible for carrying out all the instructions stored in the program.
 It decodes the fetched instruction, interprets it and sends control signals to input/output devices
until the required operation is done properly by ALU and memory.

Memory Registers
 A register is a temporary unit of memory in the CPU.
 These are used to store the data which is directly used by the processor.
 Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each register inside the
CPU has a specific function like storing data, storing an instruction, storing address of a
location in memory etc.

Memory :

 Memory attached to the CPU is used for storage of data and instructions and is called internal
memory.
 The internal memory is divided into many storage locations, each of which can store data or
instructions
 Each memory location is of the same size and has an address.
 With the help of the address, the computer can read any memory location easily without
having to search the entire memory.
 when a program is executed, it’s data is copied to the internal memory and is stored in the
memory till the end of the execution.
 The internal memory is also called the Primary memory or Main memory. This memory is also
called as RAM, i.e. Random Access Memory.
 The time of access of data is independent of its location in memory, therefore this memory is
also called Random Access memory (RAM). Read this for different types of RAMs
Output Unit :
 The output unit consists of output devices that are attached with the computer.
 It converts the binary data coming from CPU to human understandable form.
 The common output devices are monitor, printer, plotter etc.
Von Neumann Architecture
 Von Neumann architecture was first published by John von Neumann in 1945.

 His computer architecture design consists of a Control Unit, Arithmetic and Logic Unit (ALU),
Memory Unit, Registers and Inputs/Outputs.

 Von Neumann architecture is based on the stored-program computer concept, where


instruction data and program data are stored in the same memory. This design is still used in
most computers produced today.

Central Processing Unit (CPU)


 The Central Processing Unit (CPU) is the electronic circuit responsible for executing the
instructions of a computer program.
 It is sometimes referred to as the microprocessor or processor.
 The CPU contains the ALU, CU and a variety of registers.

Registers
 Registers are high speed storage areas in the CPU. All data must be stored in a register before
it can be processed.
MAR(Memory Address Register)
 Holds the memory location of data that needs to be accessed
MDR(Memory Data Register)
 Holds data that is being transferred to or from memory
AC(Accumulator)
 Where intermediate arithmetic and logic results are stored
PC(Program Counter)
 Contains the address of the next instruction to be executed
CIR(Current Instruction Register)
 Contains the current instruction during processing
Arithmetic and Logic Unit (ALU)
 The ALU allows arithmetic (add, subtract etc) and logic (AND, OR, NOT etc) operations to be
carried out.
Control Unit (CU)
 The control unit controls the operation of the computer’s ALU, memory and input/output
devices, telling them how to respond to the program instructions it has just read and interpreted
from the memory unit.
 The control unit also provides the timing and control signals required by other computer
components.
Buses
 Buses are the means by which data is transmitted from one part of a computer to another,
connecting all major internal components to the CPU and memory.
 A standard CPU system bus is comprised of a control bus, data bus and address bus.

Address Bus Carries the addresses of data (but not the data) between the processor and
memory
Data BusCarries data between the processor, the memory unit and the input/output
devices
Control BusCarries control signals/commands from the CPU (and status signals
from other devices) in order to control and coordinate all the activities
within the computer
Memory Unit
 The memory unit consists of RAM, sometimes referred to as primary or main memory. Unlike
a hard drive (secondary memory), this memory is fast and also directly accessible by the CPU.

 RAM is split into partitions. Each partition consists of an address and its contents (both in
binary form).
 The address will uniquely identify every location in the memory.
 Loading data from permanent memory (hard drive), into the faster and directly accessible
temporary memory (RAM), allows the CPU to operate much quicker.
Operands In Computer Organization

Definition
 Operands is the part of a computer instruction specifies what data is to be manipulated or
operated on while at the same time representing data itself.
1 + 2 => Here 1,2 are operands
Types of Operands
The most important and general categories of data are
 Addresses
 Numbers
 Characters
 Logical Data
Address
 The location where particular information is stored .
 A series of usual alphanumeric characters that specifies the storage location of particular
information
Address Values
OX00 01001010
OX01 10111010
OX02 0101111

Numbers
 All machine language includes numeric data types . Three types of numerical data in
computer such as
 Integer or fixed point
 Decimal numbers
 Floating point
Integer or Fixed point
 Fixed point representation is used to store integers , the positive and negative whole
numbers .
Example:- -3 ,- 2, - 101, 23
Floating point
 A floating point number usually has a decimal point
example 3.14, 6.5 ,122.4
Character
 A common form of a data is text or character string
 All of the characters that a computer can use are called character set.
Two common standards are
ASCII and Unicode
ASCII Code:-
 ASCII uses 7 bits giving a character set of 128 characters .
128 characters includes
 32 to control codes
 32 punctuation codes, symbols and space
 26 upper case letters
 26 lower case letters
 Numeric digits (0-9)

Character Denary Binary


A 65 1000001
Z 90 1011010
a 97 1100001
z 122 1111010
0 48 0110000
9 57 0111001

Logical Data
 Logical data is treated as a single unit of data.
 Logical data or Boolean data can only represent two values True or False

Operations of the Computer Hardware

 Every computer must be able to perform arithmetic operations:


add a, b, c
 It is a MIPS assembly language instructions that Instructs a computer to add two variables
b and c and put their sum into a.

Sample Program
To put the sum of 4 variables b, c, d, and e into variable a, we need the following
sequence of operations:
add a, b, c # The sum of b and c is placed in a
add a, a, d # The sum of b, c and d is now in a
add a, a, e # The sum of b, c, d and e is now in a.
➜The words to the right of each instruction are comments.
➜Each line of code can contain at most one instruction.
➜The number of operands in each instruction is exactly three.
Instruction Format

Category Instruction Exampl Meaning Comments


e
Arithmetic add add a, b, c a=b+c Always
3operands

subtract sub a, b, c a = b -c Always


3operands

Why do we insist that we always use 3 operands (why not allow 4, 5, etc. operands)?

The hardware for a variable number of operands (e.g., pentium) is more complicated than the hardware
for a fixed number of operands.

Principle #1: Simplicity is better than complexity in hardware design.

Example
 Translate the following C statement into a MIPS assembly language
instructions (this is the job of the compiler):

Answer
f = (g + h) - (i + j);

add t0, g, h # temporary variable t0 contains g+h


add t1, i, j # temporary variable t1 contains i+j
sub f, t0, t1 # f gets t0-t1, or (g+h) - (i+j)

Operands of the Computer Hardware


 Unlike programs in high-level languages, the operands of assembly language instructions cannot
be any variables they must be from a limited number of locations called registers.
 Registers are fast temporary memory locations inside the processor - they are visible to the
programmer that can be used to hold variables.
 The size of a register in a MIPS computer is 32 bits - groups of 32 bits are given the name word
in the MIPS architecture.
 The MIPS computer has 32 registers, using the notation $0, $1, ..., $31 to represent them.
 32 registers may not be enough to hold the potential large number of variables in big programs.
 However, a large number of registers complicates the design of the processor and increases its
clock cycle.
 A computer designer should strike a balance between providing a large number of registers and a
fast processor.

Principle #2:
Having a small number of registers (e.g., 16-128) leads to a faster design of the
processor.

Example Given the following C statement:


f = (g + h) - (i + j);

Assume the compiler associates the variables f, g, h, i, and j to the registers $s0, $s1, $s2, $s3,
and $s4, respectively
What is the compiled MIPS assembly language code?

add $t0, $s1, $s2 # Register $t0 contains g+h

add $t1, $s3, $s4 # Register $t1 contains i+j

sub $s0, $t0, $t1 # fgets$t0-$t1,or(g+h)- (i+j)

 What if we have a program that manipulates a large array of numbers - they cannot all be stored
in the registers of the MIPS processor.
 In this case, the elements of the array would be stored in the memory of the MIPS computer.
 The memory is a large storage space that can store millions of data elements.
 When we need to perform an operation on certain elements of this array, we transfer these
elements from the memory to the registers - MIPS cannot perform operations directly on data
elements stored in memory (certain computers can).
 These instructions are called data transfer instructions.

What is an Address
To access a word in memory, the data transfer instruction must supply its address (Memory[2]
= 1000 in the example below).
 The data transfer instruction that moves data from memory to a register is called load.
 The MIPS assembly language notation for this data transfer instruction is lw which stands for
load word.
The format of lw is such that:
1)It should contain the start address of the array,
2)It should contain a register that contains the index of the element of the array to be
loaded
(e.g., lw $27, Abegin($12)).
Address of array element = Abegin + content of register $12.
Register $12, in the above example, is called index register.
Example
 Assume that A is an array of 100 elements and that the compiler has associated the variables g, h
with registers
 $s1, and $s2. Let us assume also that the starting address, also called base address, is in $s3.
 Translate this C statements into MIPS assembly code:
g = h + A[8]
Answer
lw $t0, 8($s3) # Temporary reg $t0 gets A[8] add $s1, $s2, $t0 # g = h + A[i]
 We have shown how to address words (32 bits) in MIPS. However, most computers - including
MIPS - addresses individual bytes (8 bits) as well.
As a result, real memory addresses are as follows:

The MIPS assembly language instruction which is complimentary to load is called store.
The store instruction transfers data from a register to a memory location.
The MIPS assembly language notation for this data transfer instruction is sw which stands for store
word.
The format of sw is such that (similar to lw):

1)It should contain the start address of the array,


2)It should contain a register that contains the index of the element of the array to be stored
Example
Assume the variable h is associated with the register $s2. and the base address of the
array A is in $s3.
What is the MIPS assembly language code for the C state- ment below:
Answer
A[12] = h + A[8]
lw $t0, 32($s3) # Temporary reg $t0 gets A[8]
add $t0, $s2, $t0 # Temporary reg $t0 gets
h+A[8]
sw $t0, 48($s3) # Stores h+A[8] back into A[12]

Summary of MIPS Assembly language


Memory Locations and Addresses

 The memory consists of many millions of storage cells, each of which can store a bit of
information having the value 0 or 1.
 A single bit represents a very small amount of information, bits are seldom handled individually.
 The usual approach is to deal with them in groups of fixed size.
 The memory is organized so that a group of n bits can be stored or retrieved in a single, basic
operation.
 Each group of n bits is referred to as a word of information, and n is called the word length. The
memory of a computer can be schematically represented as a collection of words.
 Modern computers have word lengths that typically range from 16 to 64 bits.
 If the word length of a computer is 32 bits, a single word can store a 32-bit signed number or four
ASCII-encoded characters.
 A unit of 8 bits is called a byte.
 Machine instructions may require one or more words for their representation.
 Accessing the memory to store or retrieve a single item of information, either a word or a byte,
requires distinct names or addresses for each location.
 It is customary to use numbers from 0 to 2k 1, for some suitable value of k, as the addresses of
successive locations in the memory. Thus, the memory can have up to 2k addressable locations.
 The 2k addresses constitute the address space of the computer.
 For example, a 24-bit address generates an address space of 224 (16,777,216) locations. This
number is usually written as 16M (16 mega), where 1M is the number 220 (1,048,576). A 32-bit
address creates an address space of 232 or 4G (4 giga) locations, where 1G is 230. Other notational
conventions that are commonly used are K (kilo) for the number 210 (1,024), and T (tera) for the
number 240.
2.1.1Byte Addressability

 We now have three basic information quantities to deal with: bit, byte, and word.
 A byte is always 8 bits, but the word length typically ranges from 16 to 64 bits.
 It is impractical to assign distinct addresses to individual bit locations in the memory.
 The most practical assignment is to have successive addresses refer to successive byte
locations in the memory. This is the assignment used in most modern computers.
 The term byte-addressable memory is used for this assignment. Byte locations have
addresses 0, 1, 2,.
 Thus, if the wordlength of the machine is 32 bits, successive words are located at
addresses 0, 4, 8,. , with
 each word consisting of four bytes.

2.1.2Big-Endian and Little-Endian Assignments

 The name big-endian is used when lower byte addresses are used for the more significant
bytes (the leftmost bytes) of the word.
 The name little-endian is used for the opposite ordering, where the lower byte addresses
are used for the less significant bytes (the rightmost bytes) of the word.
 The words “more significant” and “less significant” are used in relation to the weights
(powers of 2) assigned to bits when the word represents a number.
 Both little-endian and big-endian assignments are used in commercial machines. In both
cases, byte addresses 0, 4, 8,..., are taken as the addresses of successive words in the
memory of a computer with a 32-bit word length. These are the addresses used when
accessing the memory to store or retrieve a word.
 In addition to specifying the address ordering of bytes within a word, it is also necessary to
specify the labeling of bits within a byte or a word.
 It is the most natural ordering for the encoding of numerical data. The same ordering is
also used for labeling bits within a byte, that is, b7, b6,..., b0, from left to right.

2.1.3Word Alignment
 In the case of a 32-bit word length, natural word boundaries occur at addresses 0, 4,
8,...,
 We say that the word locations have aligned addresses if they begin at a byte address
that is a multiple of the number of bytes in a word.
 For practical reasons associated with manipulating binary-coded addresses, the
number of bytes in a word is a power of 2.
 if the word length is 16 (2 bytes), aligned words begin at byte addresses 0, 2, 4,..., and
for a word length of 64 (23 bytes), aligned words begin at byte addresses 0, 8, 16,....
 There is no fundamental reason why words cannot begin at an arbitrary byte address.
 The most common case is to use aligned addresses, which makes accessing of memory
operands more efficient.
2.1.4 Accessing Numbers and Characters
 A number usually occupies one word, and can be accessed in the memory by specifying
its word address.
 Similarly, individual characters can be accessed by their byte address.
 For programming convenience it is useful to have different ways of specifying addresses
in program instructions.
2.2 Memory Operations
 Both program instructions and data operands are stored in the memory.
 To execute an instruction, the processor control circuits must cause the word (or words)
containing the instruction to be transferred from the memory to the processor.
 Operands and results must also be moved between the memory and the processor. Thus,
two basic operations involving the memory are needed, namely, Read and Write.
 The Read operation transfers a copy of the contents of a specific memory location to the
processor.
 The memory contents remain unchanged.
 To start a Read operation, the processor sends the address of the desired location to the
memory and requests that its contents be read.
 The memory reads the data stored at that address and sends them to the processor.
 The Write operation transfers an item of information from the processor to a specific
memory location, overwriting the former contents of that location. To initiate a Write
operation, the processor sends the address of the desired location to the memory,
together with the data to be written into that location. The memory then uses the
address and data to perform the write.
MIPSADDRESSINGMODE
Multipleformsofaddressingaregenericallycalledaddressingmodes.TheMIPSaddressingmodesarethefoll
owing,

IMMEDIATEADDRESSING
Theoperandisaconstantwithintheinstructionitself

add$S3,$t0,#10

REGISTERADDRESSING
Theoperandisa register

add$S3,$S4,$t0

BASEORDISPLACEMENTADDRESSING
Theoperandisatthememorylocationwhoseaddressisthesumofaregisterandaconstantintheinstruction

lw$S5,16($S2)

PC-RELATIVEADDRESSING
Thebranchaddressisthesumof the PCanda constantintheinstruction

beq$t0,$t3,Label
PSEUDODIRECTADDRESSING
Thejump addressisthe26bits oftheinstructionconcatenatedwiththe upperbitsof the PC

jExit

Assumeatwoaddressformatspecifiedassource,destination.Examinethefollowingsequenceof
instructions and explain the addressing modes used and the operation done in everyinstruction.
i. Move(R5)+,R0
ii. Add(R5)+,R0
iii. MoveR0,(R5)
iv. Move16(R5),R3
v. Add#40,R5

Move(R5)+, R0

Register-
IndirectwithincrementAddressingmode,IncrementsthecontentsofR5by1andloads
ittoR0.

Add(R5)+R0

Register-
IndirectwithincrementAddressingmode,IncrementsthecontentsofR5by1,addsther
esultto R0and storestheresultin R0

R0=((R5)+1)+R0.

Move R0,(R5)

RegisterDifferedaddressingmode,content ofR0ismovedtothememorylocationofR5.

Move16(R5),R3

DisplacementAddressingmode,M(16+R5)ismovedtotheR3register

Add#40, R5

ImmediateAddressingMode, R5=R5+40

You might also like