1 / 21

Data Manipulation

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?. Computer Architecture. Central Processing Unit Main Memory Peripherals

Télécharger la présentation

Data Manipulation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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? 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 Intro to CS Chapt 2 Data Manipualtion

  3. PCI bus monitor Processor(s) SCSI controller to SCSI bus and multiple disks cache(s) Graphics controller controller memory USB controller for USB bus/devices ISA controller mouse ISA bus keyboard Serial printers, cameras, etc. IDE controller to disks Parallel printers modem 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 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 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 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) 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 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). 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 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) 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 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 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 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) Intro to CS Chapt 2 Data Manipualtion

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

  17. Machine Language 0111 R1R2R3 R1  (R2) OR (R3) 1000 R1R2R3 R1  (R2) AND (R3) 1001 R1R2R3 R1  (R2) XOR (R3) logical operations between registers 1010 R10X R1 (rotate x bits in R1 to the right) • R1XY PC (XY) if (R0) = (R1) else ignore RoXY is an unconditional jump (go to XY) 1100 - HALT Example: 0001000010100111 in hexadecimal is 10A7; place value stored in A7 into R0 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 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) Intro to CS Chapt 2 Data Manipualtion

  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

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

More Related