30
Data Manipulation Angela Chih-Wei Tang (唐之 之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2009 Fall

Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

  • Upload
    doanque

  • View
    219

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Data Manipulation

Angela Chih-Wei Tang (唐唐唐唐 之之之之 瑋瑋瑋瑋)

Department of Communication Engineering

National Central University

JhongLi, Taiwan

2009 Fall

Page 2: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Outline

� Computer Architecture

� Machine Language

� Program Execution

Arithmetic/Logic Instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 2

� Arithmetic/Logic Instructions

� Communicating with Other Devices

Page 3: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Computer Architecture

� Central Processing Unit (CPU) or processor� arithmetic/Logic Unit (ALU): perform data manipulation

� control Unit: coordinate the machine’s activities

� registers: temporary storage of information

� general purpose registers

� a temporary holding places for data being manipulated by the CPU

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 3

manipulated by the CPU

� Inputs to the ALU circuitry

� Results produced by ALU circuitry

� special-purpose registers

� cache Memory

� Bus

� Motherboard

Page 4: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Cache Memory

� Cache memory

� keep a copy of that portion of main

memory that is of current interest

� register ��cache memory

� CPU can execute more rapidly

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 4

� CPU can execute more rapidly

� update main memory if data change

� Main memory: data that will be needed in

the near future

� Mass storage: data that will likely not be

needed in the near future

Page 5: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

CPU & Main Memory

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 5

Page 6: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Adding Values Stored in Memory

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 6

Page 7: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Outline

� Computer Architecture

� Machine Language

� Program Execution

Arithmetic/Logic Instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 7

� Arithmetic/Logic Instructions

� Communicating with Other Devices

Page 8: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Machine Language

� Machine instruction = an instruction coded as a bit pattern directly recognizable by the CPU

� Machine language = the set of all instructions recognized by a machine

� Reduced Instruction Set Computing (RISC)� CPU executes minimal set of machine instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 8

� CPU executes minimal set of machine instructions

� few, simple, efficient, and fast instructions

� example: PowerPC from Apple/IBM/Motorola

� Complex Instruction Set Computing (CISC)� CPU executes a large number of complex instructions, even though man of them are technically redundant

� the more complex CPU is easier to program

� example: Pentium from Intel

Page 9: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Machine Instruction Types –

Data Transfer

� Copy data between CPU and main memory

� LOAD : fill a general-purpose register with the contents of a memory cell

STORE : transfer the contents of a register to a

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 9

� STORE : transfer the contents of a register to a memory cell

� I/O instructions : communicating with devices outside the CPU-main memory context (printers,

keyboards, monitors, disk drives, etc.)

Page 10: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Machine Instruction Types –

Arithmetic/Logic

� Use existing data values to compute a new

data value

� Tell the control unit to request an activity

within the arithmetic/logic unit

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 10

within the arithmetic/logic unit

� AND, OR, and XOR

� SHIFT : the bits that fall off the end of the register are discarded

� ROTATE : fill the holes left at the other end

Page 11: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Machine Instruction Types – Control

� Direct the execution

of the program rather

than the

manipulation of data

JUMP

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 11

� JUMP

� unconditional jumps

� conditional jumps

Dividing Values Stored in Memory

Page 12: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

A Machine Instruction

� Op-code: specifies which machine operation to

execute

� one per instruction

� Operand: more detailed information about this

operation

number of operands varies depending on op-code

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 12

� number of operands varies depending on op-code

Page 13: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Decoding The Instruction 35A7

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 13

Page 14: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Outline

� Computer Architecture

� Machine Language

� Program Execution

Arithmetic/Logic Instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 14

� Arithmetic/Logic Instructions

� Communicating with Other Devices

Page 15: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Program Execution

� Controlled by two special-purpose registers

within CPU

� program counter : address of next instruction

� instruction register : current instruction

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 15

instruction register : current instruction

� Machine cycle: 3 steps performed by control

unit

� fetch

� decode

� execute

Page 16: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

A Machine Cycle

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 16

Page 17: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Special Case –

Decoding the Instruction B258

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 17

Page 18: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Stored Program Concept

� A program is just a special type of data!

� a program can be encoded and stored in main

memory

� the control unit extracts the program from

memory, decode the instructions, and execute

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 18

memory, decode the instructions, and execute

them

� The machine alone don’t know what is data

and what is program

� The computer just executes according to the

program counter

Page 19: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

The Program Stored in Main Memory

Ready for Execution

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 19

Page 20: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Performing the Fetch Step of the

Machine Cycle (1/2)

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 20

Page 21: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Performing the Fetch Step of the

Machine Cycle (2/2)

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 21

Page 22: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Outline

� Computer Architecture

� Machine Language

� Program Execution

Arithmetic/Logic Instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 22

� Arithmetic/Logic Instructions

� Communicating with Other Devices

Page 23: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Arithmetic/Logic Operations

� Logic: AND, OR, XOR

� Rotate and Shift

� circular shift

� logical shift : discard the bit that falls off the edge

and always fill the hole with a 0

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 23

and always fill the hole with a 0

� arithmetic shift : leave the sign bit unchanged

� Arithmetic: add, subtract, multiply, divide

� separate instructions for different types of data

Page 24: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Outline

� Computer Architecture

� Machine Language

� Program Execution

Arithmetic/Logic Instructions

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 24

� Arithmetic/Logic Instructions

� Communicating with Other Devices

Page 25: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Controllers Attached to a Machine’s

Bus

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 25

Page 26: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Controller

� Intermediary device : it handles communication

between the computer and a device

� Physical form of a circuit board : it plugs into a slot

on the computer’s motherboard

� Format conversion : between a computer and a

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 26

� Format conversion : between a computer and a

particular type of peripheral device

� Port = set of addresses assigned to a controller

� memory-mapped I/O : computer’s I/O devices

appear to be in various memory locations

� buses contain a signal : indicates whether the

message is for a controller or memory

Page 27: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

A Conceptual Representation of

Memory-Mapped I/O

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 27

Page 28: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Communicating with Other Devices

� Direct memory access (DMA)� a controller accesses main memory over the bus

� CPU is not using the bus

� CPU continues with other tasks while the controller performs read/write

� Von Neumann bottleneck: the CPU and the controllers compete for bus access

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 28

controllers compete for bus access� von Neumann architecture: a computer design model that uses a single storage structure to hold both instructions and data

� coordination of these activities is a major design issue

� Handshaking� 2-way dialogue

� the computer and the peripheral device exchange device’s status and coordinate their activities

Page 29: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Data Communication Rates

� Measurement units� bps = bits per second

� Kbps = kilo-bps, or 1,000 bps

� Mbps = mega-bps, or 1,000,000 bps

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 29

� Gbps = giga-bps, or 1,000,000,000 bps

� Bandwidth = maximum available rate� depends on the type of communication path

and the technology used in its implementation

Page 30: Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2009CS/Data Manipulation.pdf · Data Manipulation Angela Chih-Wei Tang ... Machine Instruction Types – Data Transfer

Data Communication Path Types

� Parallel communication� several lines transfer different bits simultaneously

� rapid

� complex communication path

� example: CPU �� peripheral devices (e.g., printers)

� rates: > Mbps

C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 30

� rates: > Mbps

� Serial communication� one line transfers one bit at a time

� slower

� communication between different computers

� example : telephone line

� modem : bit patterns (source) � audible tones � bit patterns (destination) (D/A � A/D)