Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How computers compute

347 views

Published on

How Computers Compute

Published in: Technology
  • Be the first to comment

  • Be the first to like this

How computers compute

  1. 1. How Computers Compute
  2. 2. (6+2*3)/22 –6/3 How we humans compute?
  3. 3. (6+2*3)/22 –6/3 How we humans compute? Operator Precedence: 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  4. 4. (6+2*3)/22 –6/3 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  5. 5. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  6. 6. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  7. 7. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  8. 8. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  9. 9. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  10. 10. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  11. 11. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  12. 12. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  13. 13. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 3–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  14. 14. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 3–2 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  15. 15. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 3–2 1 How we humans compute? 3: POW (^) 2: MUL, DIV (*, /) 1: ADD, SUB (+,-) 0: Parenthesis
  16. 16. CPU Memory Program VS
  17. 17. CPU Memory Program This is actually pretty stupid VS
  18. 18. ● Get data from program/memory ● Push data to memory CPU Memory Program What a CPU can do?
  19. 19. ● Get data from program/memory ● Push data to memory ● Perform operations with data from memory Addition Subtraction Multiplication Division CPU Memory Program What a CPU can do?
  20. 20. ● Get data from program/memory ● Push data to memory ● Perform operations with data from memory Addition Subtraction Multiplication Division CPU Memory Program What a CPU can do?
  21. 21. ● Get data from program/memory ● Push data to memory ● Perform operations with data from memory Addition Subtraction Multiplication Division CPU Memory Program What a CPU can do? “Variations” of Addition (Binary format perk)
  22. 22. ● Get data from program/memory ● Push data to memory ● Perform operations with data from memory Addition Subtraction Multiplication Division CPU Memory Program What a CPU can do? “Variations” of Addition (Binary format perk) RISC Reduced Instruction Set Computing
  23. 23. CPU Memory Program (6+2*3)/22 –6/3 This should go there... Running a program
  24. 24. CPU Memory Program (6+2*3)/22 –6/3 But the CPU won’t understand this program!!! Running a program
  25. 25. (6+2*3)/22 –6/3 (6+2*3)/4–6/3 (6+6)/4–6/3 (6+6)/4–2 12/4–2 3–2 1 Let’s flip our previous pyramid
  26. 26. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 Let’s flip our previous pyramid
  27. 27. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken
  28. 28. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken -
  29. 29. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - /
  30. 30. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - / +
  31. 31. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - / + /
  32. 32. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - / + / *
  33. 33. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - / + / * ^
  34. 34. 1 3–2 12/4–2 (6+6)/4–2 (6+6)/4–6/3 (6+2*3)/4–6/3 (6+2*3)/22 –6/3 And create a Graph with the steps taken - / + / * ^6 2 3 2 2 6 3
  35. 35. Let’s apply a Post-order Traversal - / + / * ^6 2 3 2 2 6 3 Algorithm: Resolve left subtree Resolve right subtree Resolve node
  36. 36. Let’s apply a Post-order Traversal - / + / * ^6 2 3 2 2 6 3 Algorithm: Resolve left subtree Resolve right subtree Resolve node 623*+22^/63/-
  37. 37. Let’s apply an Post-order Traversal - / + / * ^6 2 3 2 2 6 3 Algorithm: Resolve left subtree Resolve right subtree Resolve node this is what compilers do! From: (6+2*3)/22 –6/3 To: 623*+22^/63/- Abstract Syntax Tree (AST)
  38. 38. CPU-/36/^22+*32 6 Memory 623*+22^/63/- reversed Random Fact: HP48 calculators work with postfix notation only
  39. 39. CPU-/36/^22+*32 6
  40. 40. CPU-/36/^22+*3 2 6
  41. 41. CPU-/36/^22+* 3 6 2
  42. 42. CPU-/36/^22+ * 6 2 3 Take 2 items from memory, multiply them and leave the result in memory
  43. 43. CPU-/36/^22 + 6 6 Take 2 items from memory, multiply them and leave the result in memory
  44. 44. CPU-/36/^2 2 12
  45. 45. CPU-/36/^ 2 12 2
  46. 46. CPU-/36/ ^ 12 2 2
  47. 47. CPU-/36 / 12 4
  48. 48. CPU-/3 6 3
  49. 49. CPU-/ 3 3 6
  50. 50. CPU- / 3 6 3
  51. 51. CPU- 3 2
  52. 52. CPU 1
  53. 53. End! Q&A

×