NMCNTT 4 Data Manipulation AAA (1) (3)
NMCNTT 4 Data Manipulation AAA (1) (3)
Computer Science: An Overview by J. Glenn Brookshear and Dennis Brylow publisher Pearson
Data Manipulation
Computer Architecture
Machine Language
Program Execution
Arithmetic/Logic Instructions
2
COMPUTER ARCHITECTURE
Computer Architecture
Central Processing Unit (CPU) or processor
Arithmetic/Logic unit versus Control unit
Registers
General purpose
Special purpose
Bus
Motherboard
4
CPU and main memory connected via
a bus
5
Motherboards
The motherboard
is the main printed circuit board.
contains the buses, or electrical
pathways found in a computer.
Buses allow data to travel
among the various components.
accommodates CPU, RAM,
expansion slots, heat sink/fan
assembly, BIOS chip, chip set,
sockets, internal and external
connectors, various ports, and
the embedded wires that
interconnect the motherboard
components.
6
Central Processing Unit
The Central Processing Unit (CPU) is known as the brain
of the computer. It is also referred to as the processor.
The CPU executes a program, which is a sequence of
stored instructions.
7
Central Processing Unit
Some CPUs incorporate hyperthreading or
hypertransport to enhance the performance of the CPU.
The amount of data that a CPU can process at one time
depends on the size of the processor data bus.
Speed of the CPU is measured in cycles per second -
megahertz (MHz) or gigahertz (GHz).
Overclocking is a technique used to make a processor
work at a faster speed than its original specification.
8
Central Processing Unit
The latest processor technology has resulted in CPU
manufacturers finding ways to incorporate more than one
CPU core onto a single chip.
Dual Core CPU - Two cores inside a single CPU
Triple Core CPU - Three cores inside a single CPU
Quad Core CPU - Four cores inside a single CPU
Hexa-Core CPU - Six cores inside a single CPU
Octa-Core CPU - Eight cores inside a single CPU
9
The Arithmetic/Logic Unit
Subsystem that performs addition, subtraction, and
comparison for equality
Components
Registers, interconnections between components, and the
ALU circuitry
Register
Storage cell that holds the operands of an arithmetic
operation and holds its result
Bus
Path for electrical signals
10
The Arithmetic/Logic Unit
Registers are similar to RAM with following minor
differences
They do not have a numeric memory address but are
accessed by a special register designator such as A, X or R0
They can be accessed much more quickly than regular
memory cells
They are not used for general purpose storage but for
specific purposes such as holding the operands for an
upcoming arithmetic computations.
A typical ALU has 16, 32 or 64 registers.
11
The Control Unit
Control unit
Tasks: fetch, decode, and execute
12
MACHINE LANGUAGE
Stored Program Concept
A program can be encoded as bit patterns and stored in
main memory.
From there, the CPU can then extract the instructions and
execute them.
In turn, the program to be executed can be altered easily.
14
Terminology
Machine instruction: An instruction (or command)
encoded as a bit pattern recognizable by the CPU
15
Machine Language Philosophies
Reduced Instruction Set Computing (RISC)
Few, simple, efficient, and fast instructions
Examples: PowerPC from Apple/IBM/Motorola and ARM
16
Machine Instruction Types
Data Transfer: copy data from one location to another
Arithmetic/Logic: use existing bit patterns to compute a
new bit patterns
Control: direct the execution of the program
17
Adding values stored in memory
18
Dividing values stored in memory
19
An architecture of the machine
20
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
21
The composition of an instruction
22
Decoding the instruction 35A7
23
A Simple Machine Language
24
A Simple Machine Language
25
A Simple Machine Language
14A3: Load
The contents of the memory cell located at address A3 to
be placed in register 4.
20A3: Load
The value A3 to be placed in register 0.
35B1: Store
The contents of register 5 to be placed in the memory cell
whose address is B1.
40A4: Move
The contents of register A to be copied into register 4.
26
A Simple Machine Language
5726: Add
The binary values in registers 2 and 6 to be added and the
sum placed in register 7.
634E: Add
The values in registers 4 and E to be added as floating-
point values and the result to be placed in register 3.
27
A Simple Machine Language
7CB4: Or
The result of ORing the contents of registers B and 4 to be
placed in register C.
8045: And
The result of ANDing the contents of registers 4 and 5 to be
placed in register 0.
95F3: Xor
The result of XORing the contents of registers F and 3 to be
placed in register 5.
A403: Rotate
The contents of registers 4 to be rotated 3 bits to the right in
a circular fashion.
28
A Simple Machine Language
B43C:
Compare the contents of register 4 with the contents of
register 0.
If equal, the pattern 3C would be placed in the program
counter so that the next execution executed would be the
one located at that memory address.
Otherwise, nothing would be done.
C000:
Stop program execution.
29
An encoded version of the instructions
QUIZ
30
PROGRAM EXECUTION
Program Execution
Controlled by two special-purpose registers
Program counter: address of next instruction
Instruction register: current instruction
Machine Cycle
Fetch
Decode
Execute
32
The machine cycle
33
Decoding the instruction B258
34
A program stored in main memory
35
The fetch step of the machine
cycle
36
The fetch step of the machine cycle
37
ARITHMETIC/LOGIC
INSTRUCTIONS
Arithmetic/Logic Operations
Logic: AND, OR, XOR
Masking
Rotate and Shift:
circular shift (rotation)
logical shift
arithmetic shift
Arithmetic: add, subtract, multiply, divide
Precise action depends on how the values are encoded
(two’s complement versus floating-point).
39
Masking
40
Circular shift
41
Logical shift
QUIZ 42