1 / 28

Programming in C

Programming in C. Introduction to Computers. Programming in C. sophir@techst02.technion.ac.il. Central Processing Unit. Basic Model of Computers. Control Processing Unit (CPU). Executes Programs. Program = A Sequence of Machine Instructions.

rusty
Download Presentation

Programming in C

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. Programming in C

  2. Introduction to Computers Programming in C sophir@techst02.technion.ac.il

  3. Central Processing Unit Basic Model of Computers • Control Processing Unit (CPU) • Executes Programs • Program = • A Sequence of Machine • Instructions

  4. Central Processing Unit Control Unit Basic Model of Computers • Control Unit (CU) • Determines which instruction • must be executed next. • Retrieves the needed data from • the memory • Coordinates the execution • of the instruction

  5. Central Processing Unit Control Unit Arithmetic Logic Unit Basic Model of Computers • Arithmetic Logic Unit (ALU) • Performs Simple operations: Add, Subtract, Multiply, ...

  6. Central Processing Unit Registers Basic Model of Computers • Registers Control Unit • Fast memory used to hold • the intermediate result of • operations Arithmetic Logic Unit

  7. Central Processing Unit Memory Basic Model of Computers • Memory (RAM) Control Unit • holds data and • instructions Arithmetic Logic Unit • Random Access Registers • volatile

  8. Central Processing Unit Memory Disk Basic Model of Computers • Disk Control Unit • holds data and • programs Arithmetic Logic Unit • nonvolatile Registers

  9. Central Processing Unit Memory Disk Display Printer Basic Model of Computers • And other peripherals Control Unit Arithmetic Logic Unit Registers . . .

  10. Central Processing Unit Memory Disk Display Printer Basic Model of Computers • Bus • Data passage way • between parts of • the computer Control Unit Arithmetic Logic Unit Registers . . .

  11. CPU • Repeatedly does the following: • Gets the next instruction from the memory • Gets the data required to execute the instruction from the memory • Performs the instruction • Stores the result in the memory

  12. Machine Instructions • Add the content of memory location 6 to the content of memory location 7 and store the result in memory location 8. Load 6 Add 7 Store 8 End

  13. Memory Machine Instructions CPU 1 Load 6 2 Add 7 3 Store 8 End 4 5 6 1 7 5 8

  14. Memory Machine Instructions CPU Load 6 1 Load 6 2 Add 7 3 Store 8 End 4 5 6 1 7 5 8

  15. Memory Machine Instructions CPU Load 6 1 Load 6 2 Add 7 1 3 Store 8 End 4 5 6 1 7 5 8

  16. Memory Machine Instructions CPU Add 7 1 Load 6 2 Add 7 1 3 Store 8 End 4 5 6 1 7 5 8

  17. Memory Machine Instructions CPU Add 7 1 Load 6 2 Add 7 1 5 3 Store 8 End 4 5 6 1 7 5 8

  18. Memory Machine Instructions CPU Add 7 1 Load 6 2 Add 7 + 1 5 3 Store 8 End 4 5 6 1 7 5 8

  19. Memory Machine Instructions CPU Add 7 1 Load 6 2 Add 7 + 1 5 3 Store 8 End 4 5 6 1 7 5 6 8

  20. Memory Machine Instructions CPU Store 8 1 Load 6 2 Add 7 + 1 5 3 Store 8 End 4 5 6 1 7 5 6 8

  21. Memory Machine Instructions CPU Store 8 1 Load 6 2 Add 7 + 1 5 3 Store 8 End 4 5 6 1 7 5 6 6 8

  22. Memory Memory • A Sequence of Memory Cells (Words) Word

  23. Word Word • A Sequence of 4 Bytes Byte 0 Byte 1 Byte 2 Byte 3

  24. Byte • A Sequence of 8 Bits Word Byte 0 Byte 1 Byte 2 Byte 3

  25. 1 0 0 1 0 1 1 0 . . . 0 1 1 1 Bit • A switch capable of being in one of two states: • On state: Represents 1 • Off state: Represents 0 Word 0 1 2 3 4 5 6 7 28 29 30 31

  26. Decimal Numbers • Each digit is: • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • 453 => 3x100 + 5x101 + 4x102

  27. Binary Numbers • Each digit is: • 0, 1 • 101 => 1x20 + 0x21 + 1x22 => 5

  28. Ex - Decimal Numbers • Each digit is: • 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,A ,B ,C ,D ,E ,F • 1E3 => 3x160 + 14x161 + 1x162 => 343

More Related