Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to CS Chapt 2 Data Manipualtion 1 Data Manipulation How is data manipulated inside a computer? –How is data input? –How is it stored? –How is it.

Similar presentations


Presentation on theme: "Intro to CS Chapt 2 Data Manipualtion 1 Data Manipulation How is data manipulated inside a computer? –How is data input? –How is it stored? –How is it."— Presentation transcript:

1 Intro to CS Chapt 2 Data Manipualtion 1 Data Manipulation How is data manipulated inside a computer? –How is data input? –How is it stored? –How is it output? –How is it transmitted to other computers? –What is machine language and how does it work?

2 Intro to CS Chapt 2 Data Manipualtion 2 Computer Architecture Central Processing Unit Main Memory Peripherals Bus (and sometimes Bluetooth devices, switches) for connecting parts Bus is a collection of wires and circuitry for transferring data, addresses, control information

3 Intro to CS Chapt 2 Data Manipualtion 3 PCI bus monitor Graphics controller Processor(s) cache(s) memorycontroller USB controller for USB bus/devices SCSI controller to SCSI bus and multiple disks ISA controller IDE controller to disks Parallel printers modem ISA bus mouse keyboard Serial printers, cameras, etc.

4 Intro to CS Chapt 2 Data Manipualtion 4 USB and FireWire Serial communication standards to handle a variety of devices to communicate through the serial port (bits sent one by one rather than in parallel) –Sample USB devices include Mice Keyboards Printers Scanners Digital cameras

5 Intro to CS Chapt 2 Data Manipualtion 5 DMA Controller that allows device to place data into assigned address or retrieve data from assigned address in main memory directly (direct memory access) –Device driver (via CPU) sends controller address of source, destination, amount of data to be transferred, operation –Controller informs device driver (via interrupt register in CPU) when operation completes

6 Intro to CS Chapt 2 Data Manipualtion 6 Communication devices for local loop Ethernet (IEEE802.3 wired LAN) NICs –Connected to port with cat 5 (3,6) twisted copper wire WiFi (IEEE 802.11) wireless adaptor/NIC) Dial-up modem through existing telephone lines Modems for modulating digital input over analog waves DSL through existing telephone lines Cable modems through CATV cables FiOS – fiber and modem for the local loop Cellular phones – some WiFi enabled. Data rates in Kbps, Mbps, Gbps

7 Intro to CS Chapt 2 Data Manipualtion 7 Communicating with Devices Look at figure of PCI bus – today even memory has a controller (cache does not) Controller may be circuitry that is manufactured with device attached to it –controls and “translates” all data going between device & CPU (software in CPU is called a device driver) May be a general purpose controller that handles a number of different devices (SCSI, USB, or firewire controller)

8 Intro to CS Chapt 2 Data Manipualtion 8 Central Processing Unit Small 2” x 2” wafer with connecting pins –Connects to motherboard (main circuit board) 1) Control unit –Brains of the computer; sends signals (volts) to other units telling them what to do 2) Arithmetic/ Logic unit (ALU) performs data operations (+, and, etc.) 3) Registers, high speed memory buffers data, addresses that are being manipulated

9 Intro to CS Chapt 2 Data Manipualtion 9 Registers Some register functions –Hold input and output to/ from ALU –Hold addresses for Main Memory (MAR) –Hold data that will be written to memory; retrieved from memory (MDR) –Hold instruction being executed This register is called an Instruction Register (IR) –Hold address of next instruction to be executed. This register is called a program counter (PC).

10 Intro to CS Chapt 2 Data Manipualtion 10 Sample execution of instruction First part – fetch instruction Fetch instruction that is stored at address in PC Increment PC (even though the value may be overwritten) Second part- execute instruction –Example: C = A + B (A, B, C are memory locations) –Step 1. Get value in A from memory; store in register R1 –Step 2. Get value in B from memory; store in register R2 –Activate circuitry to output values from R1 and R2 (in turn) to ALU; add with result placed in temporary register in ALU; output this value to R3 –Store R3 into location C in memory

11 Intro to CS Chapt 2 Data Manipualtion 11 Stored program concept Initially, program was implemented with circuitry (e.g., data flow machines) Read/write memory held only data, not programs Stored program concept places program and data in memory –Originally, code was self modifying; operations could change instructions –Today there are efforts to protect code – only allow it to be executed (DEP)

12 Intro to CS Chapt 2 Data Manipualtion 12 Cache High speed memory directly available to CPU –Faster, smaller than main memory Hierarchies – L1, L2, L3 –Slower, larger than registers (1, 2MB perhaps) –Used to store parts of memory that have been recently accessed Principle of locality of reference There are also caches on devices

13 Intro to CS Chapt 2 Data Manipualtion 13 Machine Language Machine language is the language that the CPU interprets All machine instructions (except HALT) contain (at least): –Operation code Transfer of data to/from CPU (LOAD, STORE) Arithmetic/ logic operations (ADD, AND, SHIFT) Control (JUMP) –Operand (location or value) Location may be register, memory, even device address

14 Intro to CS Chapt 2 Data Manipualtion 14 Program Execution Machine cycles (these are continually repeated) –Fetch (next instruction) Place into instruction register contents of memory address in program counter Increment program counter (in our machine by 2) –Decode op code Interpret operands based on specific operation –Execute instruction

15 Intro to CS Chapt 2 Data Manipualtion 15 Simple Machine CPU ---- BUS --- Main memory Registers/ALU/control unit cell addresses R0 (in hex) 00000000(00 in hex) R1 (in hex) 00000001 PC 00000010 IR 00000011 MDR 00000100 MAR 11111111 (FF in hex)

16 Intro to CS Chapt 2 Data Manipualtion 16 Machine Language Op codes for instructions (p.551) 4bit Op code 12bit operand Action 0001 R i XY R i  (XY) Copy bit string stored in memory location XY into register i 0010 R 1 XY R i  XY Copy the value XY ( XY is some bit string) into register i 0011 R i XY XY  (R i ) Copy the bit string stored in register i into the memory location XY 01000R i R k R k  (R i ) Copy the bit string in Register i into Register k 0101R i R k R m R i  (R k )+(R m ) In 2’s complement integer addition, add the values inside Register k and m and store result in register i 0110R i R k R m R i  (R k )+(R m ) Floating point addition

17 Intro to CS Chapt 2 Data Manipualtion 17 Machine Language 0111R 1 R 2 R 3 R 1  (R 2 ) OR (R 3 ) 1000R 1 R 2 R 3 R 1  (R 2 ) AND (R 3 ) 1001R 1 R 2 R 3 R 1  (R 2 ) XOR (R 3 ) logical operations between registers 1010 R 1 0X R 1  (rotate x bits in R 1 to the right) 1011 R 1 XY PC  (XY) if (R 0 ) = (R 1 ) else ignore R o XY is an unconditional jump (go to XY) 1100 - HALT Example: 0001000010100111 in hexadecimal is 10A7; place value stored in A7 into R 0

18 Intro to CS Chapt 2 Data Manipualtion 18 Question Explain the execution of each step of the following program (implementation of adding two values stored in memory). Assume program starts at address 00. 00 156C 02 166D 04 5056 06 306E 08 C000 ( 1) copy value stored at 6C into register 5 (2) copy value stored at 6D into register 6 (3) Add values in register 5 and 6; place result into register 0 (4) Store value in register 0 into 6E (5) Halt

19 Intro to CS Chapt 2 Data Manipualtion 19 Code vs Data Note that code is data to compilers and other types of programs In the early days, code could be modified as if it were data Today code and data are kept separate, but if you were allowed to write into the code you could harm the system (discuss C pointers, viruses)

20 CISC vs RISC architecture Complex instruction set computing –Many complex instructions in hardware easier, faster for programmer to write even Apple has switched desktop from PowerPC to Intel Reduced Instruction set computing –Machine language composed of a minimal set of machine instructions Op code is represented by smaller number of bits (less op codes) Less expensive to manufacture Low power consumption (ARM) –Used widely in wireless systems Intro to CS Chapt 2 Data Manipualtion 20

21 Logical operations in Python Intro to CS Chapt 2 Data Manipualtion 21


Download ppt "Intro to CS Chapt 2 Data Manipualtion 1 Data Manipulation How is data manipulated inside a computer? –How is data input? –How is it stored? –How is it."

Similar presentations


Ads by Google