Upload
doanque
View
219
Download
3
Embed Size (px)
Citation preview
Data Manipulation
Angela Chih-Wei Tang (唐唐唐唐 之之之之 瑋瑋瑋瑋)
Department of Communication Engineering
National Central University
JhongLi, Taiwan
2009 Fall
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
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
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
CPU & Main Memory
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 5
Adding Values Stored in Memory
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 6
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
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
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.)
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
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
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
Decoding The Instruction 35A7
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 13
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
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
A Machine Cycle
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 16
Special Case –
Decoding the Instruction B258
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 17
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
The Program Stored in Main Memory
Ready for Execution
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 19
Performing the Fetch Step of the
Machine Cycle (1/2)
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 20
Performing the Fetch Step of the
Machine Cycle (2/2)
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 21
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
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
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
Controllers Attached to a Machine’s
Bus
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 25
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
A Conceptual Representation of
Memory-Mapped I/O
C.E., NCU, Taiwan Angela Chih-Wei Tang, 2009 27
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
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
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)