Chapter 0
Chapter 0
Introduction to computer
organization
• A bus is collection of signal wires which connect between the components of the
computer systems—Figure 0.2 shows that the CPU is connected to the memory as well
as I/O through the system bus, but only one at a time—if the memory and I/O wants to
use the bus at the same time, there is a conflict, as there is only one system bus.
• The system bus comprises of the address bus, data bus and the control bus.
System Bus
Data Bus:
• The set of lines used to transfer data is called the data bus.
• It is a bidirectional bus, as data has to be sent from the CPU to
memory and I/O, and has to be received as well by the CPU.
• The width of the data bus determines the data transfer rate, size
of the internal registers of the CPU and the processing capability
of the CPU.
• In short, it is a reflection of the complexity of the processor.
• As we see, the 8086 has a data bus width of 16-bits, while the
80486 has a 32-bits bus width.
• Thus the 80486 can process data of 32 bits at a time while the
8086 can only handle 16 bits.
System Bus
Address Bus:
• The address bus width determines the maximum size of the
physical memory that the CPU can access.
• With an address bus width of 20 bits, the 8086 can address 220
different locations.
• It can use a memory size of 220 bytes or 1 MB.
• For Pentium with an address bus width of 32 bits, the
corresponding numbers are 232 bytes i.e., 4 GB.
• When a particular memory location is to be accessed, the
corresponding address is placed on the address bus by the CPU.
• I/O devices also have addresses.
• In both cases, it is the CPU which supplies the address, and as such,
the address bus is unidirectional.
System Bus
Control Bus:
• The control bus is a set of control signals which needs to be activated for
activities like writing/reading to/from memory/I/O, or special activities
of the CPU like interrupts and DMA.
• Thus, we see signals like Memory Read, I/O Read, Memory Write and
Interrupt Acknowledge as part of the control bus.
• These control signals dictate the actions taking place on the system bus
that involve communications with devices like memory or I/O.
• For example,
• Memory Read signal will be asserted for reading from memory. It is
sent to memory from the processor.
• A signal such as ‘Interrupt’ is received by the processor from an I/O
device.
• Hence in the control bus, we have signals traveling in either direction.
• Some control lines may be bidirectional too.
Processor
• The processor or the microprocessor as we might call it, is the
component responsible for controlling all the activity in the system.
• It performs the following three actions continuously:
i) Fetch an instruction from memory.
ii) Decode the instruction.
iii) Execute the instruction.
Processor
• When we write a program, it is stored in memory.
• Our code has to be brought to the processor for the required
action to be performed.
– The first step obviously, is to ‘fetch’ it from memory.
– The next step i.e., decoding, involves the interpretation of the code
as to what action is to be performed.
– After decoding, the action required is performed.
• This is termed ‘instruction execution’ i.e. execute.
• The sequence of these three actions is called the ‘execution
cycle.’
• Processor has two parts:
– ALU
– Control circuitry
System Clock
• The memory associated with a computer system includes the primary memory
(RAM) as well as secondary memory.
• Memory is organized as bytes, and the capacity of a memory chip is stated in terms
of the number of bytes it can store.
• Thus, we can have chips of size 256 bytes, 1KB, 1MB and so on.
• If a computer has a total memory space of 20 MB, it can use RAM chips of the
available capacity to get that much of memory.
• There are two basic operations associated with memory— read and write.
Memory Read Cycle
Memory Write Cycle
• At this stage, we should remember that these operations are synchronized with
the system clock.
For a computer to communicate with the outside world there is the need for what
are called peripherals.
Examples: keyboard, mouse, printer, and video monitor, some modem transfer
data in both directions etc.
High Level Language
• The high-level languages are much closer to human language.
• A programming language such as C, FORTRAN or Pascal that en-
ables to write programs which is understandable to programmer
(Human) and can perform any sort of task.
• High level language must use interpreter, compiler or translator to
convert human understandable program to computer readable code
(machine code).
Examples:
COBOL Business applications
FORTRAN Engg & Scientific Applications
PASCAL General use and as a teaching tool
C & C++ General Purpose – currently most popular.
PROLOG Artificial Intelligence
JAVA General all purpose programming
.NET General or web applications.
Advantages of High over Low level language
• The main advantage of high-level languages over low-level lan-
guages is that they are easier to read, write and maintain.
• High-level languages make complex programming simpler.
• High level programming techniques are applicable everywhere even
where computational resources are limited.
• Error ratio is less in high level language and debugging (locate and
correct errors in program code ) is easier.
• Length of the program is also small compared with low level.
• Many real time problems can be easily solved with high level lan-
guage.
Assembly Language
• A computer low level language that deals with hardware registers by
name known as assembly language.
• Assembly language is the best example of low-level language, this
is in between machine language and high-level language.
• A low-level language does not need a compiler or interpreter to run
the program, the processor run low-level code directly.
Assembly Language
• Assembly languages enable a programmer to use names instead of
numbers.
• Programmers still use assembly language when speed is essential or
when they need to perform an operation that isn't possible in a high-
level language.
• It uses mnemonic codes (short forms) for instructions and allows the
programmer to introduce names for blocks of memory that hold data.
Example:
mov edx, [esp+8]
cmp edx,
Machine language
COMPILER:
Compiler is a program that compile source code into executable instructions that
a computer can understand, it check the entire program for Syntex and se-
mantic errors.
ASSEMBLER:
Assembler normally converts assembly language’s source code into machine lan-
guage.
TRANSLATOR:
Translator is a computer program that translates one programming language in-
struction(s) into another programming language instruction(s)
RISC and CISC
RISC and CISC
• when it comes to understanding and designing
microprocessor architectures, three concepts
are in center:
– Instruction Set, RISC (Reduced Instruction Set
Computer) and CISC (Complex Instruction Set
Computer).
Instruction set
• There are certain instructions that the CPU knows and when we
give them those instructions, different transistors inside it switch
ON and OFF to perform those instruction.
• The instructions that we input are in the form of 1’s and 0’s, or
opcode.
• we generally use shorthand’s for those instructions, called
assembly language, and a assembler converts it into opcode.
• The number of instructions that a particular CPU can have is
limited and the collection of all those instructions is called the
Instruction Set.
• The Instruction Set is very important. A proper design of
hardware and instruction set can determine how fast the CPU is.
CPU Performance
• The performance of a CPU is the number of programs
it can run in a given time. The more the number of
programs it can run in that time, the faster the CPU is.
Decimal Octal
Binary Hexadecimal
Quick Example
Base
Decimal to Decimal (just for fun)
Decimal Octal
Binary Hexadecimal
Weight
Base
Binary to Decimal
Decimal Octal
Binary Hexadecimal
Binary to Decimal
• Technique
– Multiply each bit by 2n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 =
2
0 x 22 =
0
1 x 23 =
8
0 x 24 =
0
1 x 25 =
32
Octal to Decimal
Decimal Octal
Binary Hexadecimal
Octal to Decimal
• Technique
– Multiply each bit by 8n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
• Technique
– Multiply each bit by 16n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
Decimal Octal
Binary Hexadecimal
Decimal to Binary
• Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant bit)
– Second remainder is bit 1
– Etc.
Example
12510 = ?2 2 125
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Decimal to Octal
• Technique
– Divide by 8
– Keep track of the remainder
Example
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal
• Technique
– Divide by 16
– Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Binary to Octal
• Technique
– Group bits in threes, starting on right
– Convert to octal digits
Example
10110101112 = ?8
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
• Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
• Technique
– Use binary as an intermediary
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF
Hexa-
Decimal Binary Octal decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF
Common Powers (1 of 2)
• Base 10 Power Preface Symbol Value
10-12 pico p .000000000001
10-9 nano n .000000001
10-6 micro .000001
10-3 milli m .001
103 kilo k 1000
106 mega M 1000000
109 giga G 1000000000
1012 tera T 1000000000000
Common Powers (2 of 2)
• Base 2 Power Preface Symbol Value
210 kilo k 1024
/ 230 =
Exercise – Free Space
• Determine the “free space” on all drives on a
machine in the lab
Free space
Drive Bytes GB
A:
C:
D:
E:
etc.
Review – multiplying powers
• For common bases, add powers
ab ac = ab+c
or…
26 210 = 64 210 = 64k
Fractions
• Decimal to decimal (just for fun)
Hexa-
Decimal Binary Octal decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82
BCD, ASCII, Negative Binary
Numbers, Addition, Subtraction
Unsigned Numbers
• Unsigned number implies that the sign of the
number is irrelevant
• We consider the numbers as having no sign bit
• All the bits allotted for the data are used for
magnitude alone
• Refers to positive numbers
• With 8 bits, numbers from 0 to 255 can be
used
Representation of Negative Numbers
• Computers use 2’s complement for
representation for negative numbers.
• 2’s complement= complement each bit of
number and add ‘1’ to this.
• Eg 4-bit representation of -6 is
i) Write 4 bit binary value of 6: 0110
ii) Complement each bit: 1001
iii) Add ‘1’ to this: 1010
• So, -6 is ‘1010’, for computers
Negative binary
numbers: 2’s
complement
Hex 7EH
Hex F5H
A B A+B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
Addition of Unsigned Numbers Case1:
110011+001100=
Binary addition
10101010 + 11001100 = 0101110110
110011+001100= 0111111
Hexadecimal addition
59H 8ABH 999H
69H B78H ABCDH
----- --------- ---------
C2H 1423H B566H
Hexadecimal addition
79H 898 FFF
79H ABA EEE
----- --------- ---------
Hexadecimal addition
79H 898H FFFH
79H ABAH EEEH
----- --------- ---------
F2H 1352H 1EEDH
Addition of Negative Numbers
• Negative numbers are represented in 2’s
complement notation
Q) Add -43 and -56
A) Calculate 2’s complement of 43 and 56
- 43
1101 0101
- 56 + 1100 1000
-99 1 1001 1101
A B A– B
0 0 0
0 1 1 (borrow 1)
1 0 1
1 1 0
Subtraction
Subtraction
Second Step
Third Step
BCD subtraction in 9’s compliment method.