You are on page 1of 42

Chapter 2

Data Manipulation
Chapter 2: Data Manipulation

• 2.1 Computer Architecture


• 2.2 Machine Language
• 2.3 Program Execution
• 2.4 Arithmetic/Logic Instructions
• 2.5 Communicating with Other
Devices
• 2.6 Other Architectures

0-2
Introduction

• In this chapter we will learn how a


computer manipulates data and
communicates with peripheral devices
such as printers and keyboards.
• In doing so, we will explore the basics of
computer architecture and learn how
computers are programmed by means of
encoded instructions, called machine
language instructions.
Computer Architecture

John von Neumann

Memory

operation Peripheral
control
Memory

Operation peri
CPU controller
pher
Control
al
Computer Architecture
• Central Processing Unit (CPU) or processor
that controls the manipulation of data.
– Arithmetic/Logic unit: performs operations on
data (such as addition and subtraction)
– Control unit: coordinating the machine’s activities
– Registers unit: used for temporary storage of
information within the CPU
• General purpose
• Special purpose
• Bus: CPU and main memory are connected by a
collection of wires
• Motherboard: machine’s main circuit board
0-6
Motherboard

CPU Socket

Main
Memory
slot
Figure 2.1 CPU and main memory connected
via a bus

Main memory and the CPU form the


core of a computer.
0-8
General-purpose registers

• Serve as temporary places for data


being manipulated by the CPU.
• These registers hold the inputs to
the arithmetic/logic unit’s circuitry
and provide storage space for
results produced by that unit.
control unit
• To perform an operation on data
stored in main memory, the control unit
transfers the data from memory into
the general-purpose registers, informs
the arithmetic/logic unit which
registers hold the data, activates the
appropriate circuitry within the
arithmetic/logic unit, and tells the
arithmetic/logic unit which register
should receive the result.
Bus
• Through this bus, the CPU extracts (reads)
data from main memory by supplying the
address of the pertinent memory cell along
with an electronic signal telling the memory
circuitry that it is supposed to retrieve the
data in the indicated cell.
• In a similar manner, the CPU places (writes)
data in memory by providing the address of
the destination cell and the data to be stored
together with the appropriate electronic
signal telling main memory that it is supposed
to store the data being sent to it.
Read
1 A12 0000H
0 A11 0001H C
0
C 1 P

P 0
U
0 址 数据线 89H
U 0 译 1234H 数
89H
地 1
1 码 据
址 0 器 线
1
线 0
0 A0 1FFFH

0 读写控制电路
CS 存储器
存储器读命令

CPU 控制线

CPU 通过地址线发出地址由地址译码器对地址进行“翻译” , 选中某一存储单


; 发出存储器读命
CPU 元;
某一存储单元的内容送往 CPU 数据线。
令,
Write
1 A12 0000H
1 A11 0001H C
0
C 1 P

P 0
U
0 址 数据线 36H
U 0 译 数
地 1
1 码 据
址 0 器 1A35H 线
1 89H
36H
线 0
1 A0 1FFFH

0 读写控制电路
CS 存储器
存储器写命令

CPU 控制线
CPU 通过地址线发出地址,并把数据放到数据线上;
由地址译码电路对地址线进行“翻译” ,“ 选中”某一单元
;发出存储器写命令; 把数据线信息送入选中的存储单元。
CPU
Figure 2.2 Adding values stored in memory

0-14
Summary: System architecture
AB Bus

C I/O peripheral
Memory Memory
controller
P
U
DB BUS

CB BUS
Stored Program Concept
A program can be encoded as bit patterns and
stored in main memory, just like data.

• The idea of storing a computer’s program in its


main memory is called the stored-program
concept and has become the standard approach
used today.

• From there, the CPU can then extract (read)


the instructions and execute them. In turn, the
program to be executed can be altered easily.
0-16
Run of high-level language

compile
source
object

link upload
Executable
code

execution
Other program
library
Terminology
• Machine language: To apply the
stored-program concept, CPUs are
designed to recognize instructions
encoded as bit patterns. This
collection of instructions along with
the encoding system is Machine
language
• Machine instruction: An instruction
expressed in this language is called a
machine-level instruction

0-18
Machine Language Philosophies

• Reduced Instruction Set Computing (RISC):


CPU should be designed to execute a minimal set of
machine instructions
– Few, simple, efficient, and fast instructions
– Examples: PowerPC from Apple/IBM/Motorola
and ARM
• Complex Instruction Set Computing (CISC):
CPUs with the ability to execute a large number of
complex instructions
– Many, convenient, and powerful instructions
– Example: Intel
0-19
Machine Instruction Types

• Data Transfer: copy data from one


location to another, LOAD, STORE
• Arithmetic/Logic: use existing bit
patterns to compute a new bit
patterns, ADD
• Control: direct the execution of the
program rather than the manipulation
of data, JUMP

0-20
Figure 2.2 Adding values stored in memory

0-21
Figure 2.3 Dividing values stored in memory

0-22
Figure 2.4 The architecture of the machine
described in Appendix C

Program counter: address of next instruction


Instruction register: current instruction 0-23
Parts of a Machine Instruction

• Op-code: Specifies which operation


to execute
• Operand: Gives more detailed
information about the operation
– Interpretation of operand varies
depending on op-code

0-24
Figure 2.5 The composition of an
instruction for the machine in Appendix C

0-25
Figure 2.6 Decoding the instruction 35A7

STORE the bit pattern found in register 5 in the memory cell whose
address is A7 0-26
Program execution
• A computer follows a program stored in its
memory by copying the instructions from
memory into the CPU as needed. Once in
the CPU, each instruction is decoded and
obeyed.
• The order in which the instructions are
fetched from memory corresponds to the
order in which the instructions are stored
in memory unless otherwise altered by a
JUMP instruction.
Program Execution
• Controlled by two special-purpose registers
– Program counter: address of next instruction
– Instruction register: current instruction

0-28
Figure 2.8 The machine cycle

Machine Cycle:
three steps
Fetch
Decode
Execute
0-29
Figure 2.10 The program from Figure 2.2 stored
in main memory ready for execution

0-30
Figure 2.11 Performing the fetch step of
the machine cycle

0-31
Figure 2.11 Performing the fetch step of
the machine cycle (cont’d)

0-32
Figure 2.7 An encoded version of the
instructions in Figure 2.2

0-33
Arithmetic/Logic Operations

• Logic: AND, OR, XOR


– Masking determines which part of the other
operand will affect the result. In the case of the
AND operation, masking produces a result that is
a partial replica of one of the operands, with 0s
occupying the nonduplicated positions.
• Rotate and Shift: circular shift, logical
shift, arithmetic shift
• Arithmetic: add, subtract, multiply,
divide
0-34
Figure 2.12 Rotating the bit pattern 65
(hexadecimal) one bit to the left

0-35
Communicating with Other Devices

AB Bus

C I/O Peripheral
Memory Memory Device
controller
P
U
DB BUS

CB BUS
Communicating with Other Devices
• Controller: An intermediary apparatus that
handles communication between the computer
and a peripheral device
– Specialized controllers for each type of
device ( purchasing a new peripheral device often
required the purchase of a new controller as well. )
– General purpose controllers (USB and
FireWire): by which a single controller is able to
handle a variety of devices
• Port: The point at which a device connects to a
computer
0-37
Figure 2.13 Controllers attached to a
machine’s bus

With this
arrangement, the
CPU is able to
communicate with
the controllers
attached to the bus
in the same manner
that it communicates
with main memory.

0-38
Communicating with Other Devices
(continued)
• Communication between
computing devices is handled over
two types of paths:
• Parallel Communication:
Several communication paths
transfer bits simultaneously.
• Serial Communication: Bits
are transferred one after the
other over a single
communication path.

0-39
Other architecture
• The Multi-Core CPU
• Today’s state of the art allows for more than one
entire CPU to be placed on a single chip. This is the
underlying architecture of devices known as multi-
core CPUs,
• Multi-core CPUs containing two processing units
are typically called dual-core CPUs.
Conclusion

• Introduce the computer architecture


• Program execution
AB Bus

C I/O Peripheral
Memory Memory Device
controller
P
U
DB BUS

CB BUS
Thank you !

You might also like