Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICC Module 3 Lesson 1 – Computer Architecture 1 / 26 © 2015 Ph. Janson Information, Computing & Communication Computer Architecture Clip 1 – Assembler.

Similar presentations


Presentation on theme: "ICC Module 3 Lesson 1 – Computer Architecture 1 / 26 © 2015 Ph. Janson Information, Computing & Communication Computer Architecture Clip 1 – Assembler."— Presentation transcript:

1

2 ICC Module 3 Lesson 1 – Computer Architecture 1 / 26 © 2015 Ph. Janson Information, Computing & Communication Computer Architecture Clip 1 – Assembler Language School of Computer Science & Communications P. Ienne (charts), Ph. Janson (commentary)

3 ICC Module 3 Lesson 1 – Computer Architecture 2 / 26 © 2015 Ph. Janson Outline ►Clip 0 – IntroductionClip 0 ►Clip 1 – Software technology – Assembler languageClip 1  Algorithms  Registers  Data instructions  Instruction numbering  Control instructions ►Clip 2 – Hardware architecture – Von Neumann’s stored program computer architectureClip 2  Data storage and processing  Control storage and processing ►Clip 3 – Hardware design – Instruction encodingClip 3 ►Harware implementation – Transistor technology  Clip 4 – Computing circuits Clip 4  Clip 5 – Memory circuits Clip 5 ►Hardware performance  Clip 6 – Logic parallelism Clip 6  Clip 7 – Architecture parallelism Clip 7 First clipPrevious clipNext clip

4 ICC Module 3 Lesson 1 – Computer Architecture 3 / 26 © 2015 Ph. Janson An algorithm – Step 0 ►An algorithm can be expressed in some intuitive « language » close to natural language People can understand and even execute that but computers cannot Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s

5 ICC Module 3 Lesson 1 – Computer Architecture 4 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Sum of the n first integers Input : 3 Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Execution of this algorithm

6 ICC Module 3 Lesson 1 – Computer Architecture 5 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Sum of the n first integers Input : 3 Output: m s ← 0 as long as 3 > 0 s ← 0 + 3 n ← 3 – 1 m ← s Execution of this algorithm

7 ICC Module 3 Lesson 1 – Computer Architecture 6 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Sum of the n first integers Input : 3 Output: m s ← 0 as long as 2 > 0 s ← 3 + 2 n ← 2 – 1 m ← s Execution of this algorithm

8 ICC Module 3 Lesson 1 – Computer Architecture 7 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Sum of the n first integers Input : 3 Output: m s ← 0 as long as 1 > 0 s ← 5 + 1 n ← 1 – 1 m ← s Execution of this algorithm

9 ICC Module 3 Lesson 1 – Computer Architecture 8 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Sum of the n first integers Input : 3 Output: m s ← 0 as long as 0 > 0 s ← s + n n ← n – 1 m ← 6 Execution of this algorithm

10 ICC Module 3 Lesson 1 – Computer Architecture 9 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: cont_lte r1, 0, 6 3: add r3, r3, r1 4: add r1, r1, -1 5: cont 2 6: load r2, r3 From algorithms to computers – Step 1 Hardware Software Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s

11 ICC Module 3 Lesson 1 – Computer Architecture 10 / 26 © 2015 Ph. Janson Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s To get to computers let us first rewrite the algorithm We need to manipulate values such as s for instance For this purpose we restrict ourselves to variables such as r1, r2, r3,…

12 ICC Module 3 Lesson 1 – Computer Architecture 11 / 26 © 2015 Ph. Janson ►Such variables are called « registers » ►They are represented as r1, r2, r3,… ►The names of all algorithm variables must be replaced by such register names  n  r1  m  r2  s  r3 « Registers »

13 ICC Module 3 Lesson 1 – Computer Architecture 12 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Sum of the n first integers Input : n Output: m s ← 0 as long as n > 0 s ← s + n n ← n – 1 m ← s Step 1.1

14 ICC Module 3 Lesson 1 – Computer Architecture 13 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Let us continue … We need to assign values to these registers So we write that in a very regular way, for instance, « load r3, 0 » to mean r3  0 ou « load r2, r3 » to mean r2  r3

15 ICC Module 3 Lesson 1 – Computer Architecture 14 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 load r3, 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 load r2, r3 Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Step 1.2

16 ICC Module 3 Lesson 1 – Computer Architecture 15 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Let us continue … We need to perform arithmetic operations on these registers We rewrite those also in a more regular way, for instance, « add r3, r3, r1 » to mean r3  r3 + r1

17 ICC Module 3 Lesson 1 – Computer Architecture 16 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 load r3, 0 as long as r1 > 0 add r3, r3, r1 add r1, r1, -1 load r2, r3 Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Step 1.3

18 ICC Module 3 Lesson 1 – Computer Architecture 17 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Let us continue …

19 ICC Module 3 Lesson 1 – Computer Architecture 18 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 load r3, 0 if r1 <= 0 continue add r3, r3, r1 add r1, r1, -1 continue load r2, r3 Sum of the n first integers Input : r1 Output: r2 r3 ← 0 as long as r1 > 0 r3 ← r3 + r1 r1 ← r1 – 1 r2 ← r3 Watch out: a somewhat contorted transformation!

20 ICC Module 3 Lesson 1 – Computer Architecture 19 / 26 © 2015 Ph. Janson To enable that let us introduce line numbers We need to be able to specify targets for these « continue there » Instead of arrows we use line numbers, for instance, 1:, 2:, 3: Sum of the n first integers Input : r1 Output: r2 load r3, 0 if r1 <= 0 continue add r3, r3, r1 add r1, r1, -1 continue load r2, r3

21 ICC Module 3 Lesson 1 – Computer Architecture 20 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: if r1 <= 0 continue at 6 3: add r3, r3, r1 4: add r1, r1, -1 5: continue at 2 6: load r2, r3 Sum of the n first integers Input : r1 Output: r2 load r3, 0 if r1 <= 0 continue add r3, r3, r1 add r1, r1, -1 continue load r2, r3 Step 1.4

22 ICC Module 3 Lesson 1 – Computer Architecture 21 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: if r1 <= 0 continue at 6 3: add r3, r3, r1 4: add r1, r1, -1 5: jump 2 6: load r2, r3 JUMP instructions We introduce a new type of action / instruction, for instance, « jump 2 » to mean continue at 2 So now we need to specify jumps to given line numbers

23 ICC Module 3 Lesson 1 – Computer Architecture 22 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: jump_lte r1, 0, 6 3: add r3, r3, r1 4: add r1, r1, -1 5: jump 2 6: load r2, r3 Conditional JUMP instructions We introduce new conditional actions / instructions, for instance, « jump_lte r1, 0, 6 » to mean if r1<= 0 continue at 6 We also need to be able to react to conditions

24 ICC Module 3 Lesson 1 – Computer Architecture 23 / 26 © 2015 Ph. Janson Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: jump_lte r1, 0, 6 3: add r3, r3, r1 4: add r1, r1, -1 5: jump 2 6: load r2, r3 Sum of the n first integers Input : r1 Output: r2 1: load r3, 0 2: if r1 <= 0 continue 6 3: add r3, r3, r1 4: add r1, r1, -1 5: continue 2 6: load r2, r3 Step 1.5 This is what is called a program in “Assembler” language, which is already a lot closer to what computers can understand

25 ICC Module 3 Lesson 1 – Computer Architecture 24 / 26 © 2015 Ph. Janson ►Bottom line: we have defined a limited number of instructions; for instance  Load for assigning values to registers  Add for adding values into registers …… ►All these instructions  Have one single result …  And operate on 1 or 2 operands …  Which are either registers or constants ►One writes all these instructions as operation result, operand1, operand2 « Instructions »

26 ICC Module 3 Lesson 1 – Computer Architecture 25 / 26 © 2015 Ph. Janson ►Jump instructions specify that the next instruction to execute is not becessarily at the next line but may be at a line specified by the instruction ►One defines a limited number of jump instructions, for instance  jump 2 for an unconditionnal jump to line 2  jump_eq r1, r2, 6 for a conditional jump to line 6 if r1 = r2  jump_lte r1, r2, 6 for a conditional jump to line 6 if r1 ≤ r2  jump_gte r1, 14, 6 for a conditional jump to line 6 if r1 ≥ 14  jump_neg r1, 6 … r1 < 0  jump_pos r1, 6 … r1 > 0 JUMP instructions

27 ICC Module 3 Lesson 1 – Computer Architecture 26 / 26 © 2015 Ph. Janson ►One uses « registers » such as r1, r2, r3, in stead of freely named variables ►One writes programs as sequences of « instructions »  instructions for loading registers  instructions for arithmetic operations on registers  instructions for jumping (un)conditionally to other instructions ►i.e. one uses a restricted set of predefined instructions Brief summary


Download ppt "ICC Module 3 Lesson 1 – Computer Architecture 1 / 26 © 2015 Ph. Janson Information, Computing & Communication Computer Architecture Clip 1 – Assembler."

Similar presentations


Ads by Google