Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Essence of Computation.

Similar presentations


Presentation on theme: "CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Essence of Computation."— Presentation transcript:

1 CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Essence of Computation

2 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Goals By the end of the unit, you should understand How to define a computerHow to define a computer The differences between analog and digital machinesThe differences between analog and digital machines Understand why we use positional numbering systemsUnderstand why we use positional numbering systems Understand how to convert from Base-10 to Base-2Understand how to convert from Base-10 to Base-2

3 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Goals (continued) Understand how to convert from Base-2 to Base-10Understand how to convert from Base-2 to Base-10 Understand how to do simply binary arithmeticUnderstand how to do simply binary arithmetic How computers encode dataHow computers encode data How computers manipulate data using the elemental commandsHow computers manipulate data using the elemental commands How the Fetch & Execute Cycle worksHow the Fetch & Execute Cycle works

4 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science What is a Computer? “A computer is a digital machine that is a universal information manipulator” Digital Machine – Has tons of accuracy but limited precision Universal – Deals with multiple different types of data Information Manipulator – Has the ability to take raw data and make it meaningful in some way

5 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science A Paradox … “A computer is a digital machine that is a universal information manipulator” Does a computer really deal with multiple types of information? Remember, a computer consists of a series of switches that represent changes in electrical voltages. High voltages are considered “ON” (1) and low voltages are considered “OFF” (0)

6 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Computers & Binary Numbering Computers are made of a series of switchesComputers are made of a series of switches Each switch has two states: ON or OFFEach switch has two states: ON or OFF Each state can be represented by a number:Each state can be represented by a number: –ON is represented by “1” –Off is represented by “0”

7 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Starting with Numbers Each switch can either have sufficient voltage (“ON”) or have insufficient voltage (“OFF”).Each switch can either have sufficient voltage (“ON”) or have insufficient voltage (“OFF”). Another way of stating voltage: 1 or 0Another way of stating voltage: 1 or 0 This is a common approach in science – to use abstract, notational systems to describe things.This is a common approach in science – to use abstract, notational systems to describe things. “1” “0”

8 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Light Switch Demo Web site: http://www.cs.iupui.edu/~aharris/binTut/tester.htmlWeb site: http://www.cs.iupui.edu/~aharris/binTut/tester.html http://www.cs.iupui.edu/~aharris/binTut/tester.html What patterns do you recognize when we add a switch?What patterns do you recognize when we add a switch? 1 switch – 2 states; 2 switches – 4 states; 3 switches – 8 states; 4 switches – 16 states …1 switch – 2 states; 2 switches – 4 states; 3 switches – 8 states; 4 switches – 16 states … There seems to be a “magic” pattern related to two …There seems to be a “magic” pattern related to two …

9 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Using Two Switches AB OFFOFF OFFON ONOFF ONONAB00 01 10 11

10 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Using Three Switches ABC OFFOFFOFF OFFOFFON OFFONOFF OFFONON ONOFFOFF ONOFFON ONONOFF ONONONABC000 001 010 011 100 101 110 111

11 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Using Four Switches Complete the table for four switches …Complete the table for four switches … How many rows did you need?How many rows did you need? What patterns do you recognize?What patterns do you recognize? ABCD 0000 0001 0010 0011

12 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science You’ve Got the Power (of Two) Each time we add a switch, we increase the number of states by a power of two (2 n )Each time we add a switch, we increase the number of states by a power of two (2 n ) And now the that “magic” pattern unlocked …And now the that “magic” pattern unlocked …

13 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The Magic Pattern n2n2n2n2Result 202020201 212121212 222222224 232323238 2424242416 2525252532 What’s Next?

14 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science It’s A Binary Thing … If our notational system is formally described, we can use mathematics.If our notational system is formally described, we can use mathematics. Which is how, from the world of the switch, we find ourselves doing binary math.Which is how, from the world of the switch, we find ourselves doing binary math. Consider this shorthand notation for a bank of switch settings: 1011Consider this shorthand notation for a bank of switch settings: 1011 What does it mean? Remember, we are trying to represent numbers using switches, so how can I interpret 1011 as a number?What does it mean? Remember, we are trying to represent numbers using switches, so how can I interpret 1011 as a number?

15 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Numbering Systems To figure the answer to this question, let’s step back and look at numbering systems in general.To figure the answer to this question, let’s step back and look at numbering systems in general. Originally, human being counted with tally math systems, with a mark for each sheep they were countingOriginally, human being counted with tally math systems, with a mark for each sheep they were counting –If you had 10 sheep, you made 10 marks

16 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Numbering Systems Later, there were advancements in tally math, using special symbols for special numbers.Later, there were advancements in tally math, using special symbols for special numbers. –Instead of 10 marks for 10 sheep, let’s make a special mark for 10 sheep … –Instead of 10 marks for 10 sheep, let’s make a special mark for 10 sheep … But this notational system was cumbersome… you had to learn a lot of symbols, and arithmetic was difficultBut this notational system was cumbersome… you had to learn a lot of symbols, and arithmetic was difficult = = X X

17 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Positional Numbering Systems Wonderful advancement over tally math.Wonderful advancement over tally math. Let’s keep a few, core numbers (digits).Let’s keep a few, core numbers (digits). We can use these digits to represent REALLY big numbers if we say that the value of a number is now made up of 2 parts:We can use these digits to represent REALLY big numbers if we say that the value of a number is now made up of 2 parts: –A count value –A place value

18 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… The 7 stands for 7 (it’s count value) ones (it’s positional value). Together, 7 times 1 is 7The 7 stands for 7 (it’s count value) ones (it’s positional value). Together, 7 times 1 is 7 3 7

19 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… The 3 stands for 3 (it’s count value) tens (it’s positional value). Together, 3 times 10 is thirtyThe 3 stands for 3 (it’s count value) tens (it’s positional value). Together, 3 times 10 is thirty 3 7

20 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… Total value: 7 (7 * 1, from the ones position) and thirty (3 * 10, from the 10 position) is 37!Total value: 7 (7 * 1, from the ones position) and thirty (3 * 10, from the 10 position) is 37! 3 73 7 3 73 7

21 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Place Values 3 73 7 3 73 7 “Ones” “Tens” 7 * 13 * 10

22 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Once More Consider 238:Consider 238: –8 times 1 = 8 –3 times 10 = 30 –2 times 100 = 200 Grand total = 238Grand total = 238 What do all of our expressions (8 * 1, 3 * 10, 2 * 100) have in common?What do all of our expressions (8 * 1, 3 * 10, 2 * 100) have in common?

23 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-10 (Decimal) A base refers to the number of digits (counting numbers) available in a numbering scheme.A base refers to the number of digits (counting numbers) available in a numbering scheme. The highest single digit in base is one less than the base number.The highest single digit in base is one less than the base number. In Base-10, the digits are:In Base-10, the digits are: –0, 1, 2, 3, 4, 5, 6, 7, 8, 9

24 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-10 (Decimal) What happens after 9?What happens after 9? The counter in the right column resets itself to “0” and 1 is added to the value of the next left- most column:The counter in the right column resets itself to “0” and 1 is added to the value of the next left- most column: 0 90 90 90 9 1 0

25 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-10 (Decimal) Interpreting a multiple digit number simply means to expand its notation, and write it out by each positional value:Interpreting a multiple digit number simply means to expand its notation, and write it out by each positional value: 7 4 2 “Ones” 2 * 1 “Tens” 4 * 10 “Hundreds” 7 * 100

26 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-10 (Decimal) What about using some math to describe the number:What about using some math to describe the number: 7 4 2 10 0 2 * 10 0 4 * 10 1 7 * 10 2 10 1 10 2

27 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Using Expanded Notation We can use our expanded notation to figure the value of a number:We can use our expanded notation to figure the value of a number: 7*10 2 = 7*100 = 700 4*10 1 = 4*10 = 40 2*10 0 = 2*1 = 2 = 742 10

28 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science A Note on Subscripts We’ve seen superscripts in expressions before today. In math, they are used to indicate an exponent in an expression:We’ve seen superscripts in expressions before today. In math, they are used to indicate an exponent in an expression: xyxyxyxy

29 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science A Note on Subscripts Let’s introduce one more notation – the subscript. It is used to indicate the base of a number (the number of digits available in a numbering system):Let’s introduce one more notation – the subscript. It is used to indicate the base of a number (the number of digits available in a numbering system): xyxyxyxy

30 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science A Note on Subscripts Remember our previous example?Remember our previous example? It had a subscript of “10”, meaning that the number we use the Base-10 (Decimal) numbering system to decode this number.It had a subscript of “10”, meaning that the number we use the Base-10 (Decimal) numbering system to decode this number. 742 10

31 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Understanding Placeholders Each numbering system has placeholdersEach numbering system has placeholders The possible values of each place holder depends on the maximum number of single- digit numbers available for that numbering systemThe possible values of each place holder depends on the maximum number of single- digit numbers available for that numbering system In the Base-10 world (aka Decimal), there are ten possible digits that each placeholder can take (0-9)In the Base-10 world (aka Decimal), there are ten possible digits that each placeholder can take (0-9) Think of placeholders like an odometer in a car …

32 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science From Base-10 to Other Bases We can apply the same rules we’ve learned for Base-10 to all other bases.We can apply the same rules we’ve learned for Base-10 to all other bases. Positional notational systems work the same, we just need to change our expressions from Base-10 to the new base number!Positional notational systems work the same, we just need to change our expressions from Base-10 to the new base number!

33 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-2 Placeholders “Ones”“Twos” “Fours” 4*12*01*1 2 2 *1 2 1 *0 2 0 *1 101Number: Placeholder Name: n 10 Value: n 10 Exponential Expression:

34 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Thinking in Binary (Base-2) Instead of having 10 digits, the binary (Base-2) numbering systems has 2 base digits (0 and 1).Instead of having 10 digits, the binary (Base-2) numbering systems has 2 base digits (0 and 1). –Counting in Base-2: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010 … In binary, after the right-most placeholder reaches one, it resets to 0 and advances the next left-most placeholder.In binary, after the right-most placeholder reaches one, it resets to 0 and advances the next left-most placeholder. Our base number in binary is 2, therefore we can use exponents of 2 for placeholder notationOur base number in binary is 2, therefore we can use exponents of 2 for placeholder notation

35 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Placeholders 1 0 1 1 “Twos” “Ones” “Fours” “Eights” Let’s deconstruct 1011 2 :Let’s deconstruct 1011 2 :

36 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Placeholders 1 0 1 1 2020 Now, let’s use exponents:Now, let’s use exponents: 21212 2323

37 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-2 to Base-10 Let’s convert 1011 2.Let’s convert 1011 2. STEP 1: Find all switches that are turned “OFF”. Cross them out and bring down the zero.STEP 1: Find all switches that are turned “OFF”. Cross them out and bring down the zero. 1 0 1 1 2020 21212 2323 0

38 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-2 to Base-10 STEP 2: For each placeholder turned “ON”, calculate its exponential expression.STEP 2: For each placeholder turned “ON”, calculate its exponential expression. 1 0 1 1 2020 21212 2323 0128

39 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-2 to Base-10 STEP 3: Add the results of the exponents. The sum is the Base-10 equivalent.STEP 3: Add the results of the exponents. The sum is the Base-10 equivalent. 1 0 1 1 2020 21212 2323 0128 +++ = 11 10

40 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Let’s Review … Switches can represent numbers! The notational system for switches is Base-2Switches can represent numbers! The notational system for switches is Base-2 In Base-2, the digits are 0 and 1; the highest single number is a 1In Base-2, the digits are 0 and 1; the highest single number is a 1 To convert from Base-2 to Base-10, just re-write the base two number in its expanded form, and then add the positional values.To convert from Base-2 to Base-10, just re-write the base two number in its expanded form, and then add the positional values.

41 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Let’s Try a Conversion 1 1 0 1 0 2020 Convert 11010 2 to it’s Base-10 equivalent.Convert 11010 2 to it’s Base-10 equivalent. 21212 2323 2424

42 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Let’s Try a Conversion 1 1 0 1 0 2020 STEP ONE:STEP ONE: 21212 2323 2424 00

43 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Let’s Try a Conversion 1 1 0 1 0 2020 STEP TWO:STEP TWO: 21212 2323 2424 002816

44 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Let’s Try a Conversion 1 1 0 1 0 2020 STEP THREE:STEP THREE: 21212 2323 2424 002816++++= 26 10

45 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Base-10 Placeholders “Ones”“Tens” “Hundreds” 100*410*31*6 10 2 *4 10 1 *3 10 0 *6 436Number: Placeholder Name: Value: Exponential Expression:

46 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 There are two methods:There are two methods: –Using exponents of two - n 2 –Successive division Let’s try exponents first …Let’s try exponents first …

47 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP ONE: Find the largest exponent of two that is less than or equal to the Base-10 number: 23 10 = 24242424 16 23232323 22222222 21212121 20202020

48 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP TWO: Calculate the value of each exponent and place that value above it: 23 10 = 24242424 16 23232323 22222222 21212121 20202020 8421

49 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP THREE: Place a “1” above the left- most placeholder: 23 10 = 24242424 16 23232323 22222222 21212121 20202020 8421 1

50 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP FOUR: Add left-most value to the next place-holder. Put a “0” above is the sum is greater than the number being converted, otherwise put a “1” above: 23 10 = 24242424 16 23232323 22222222 21212121 20202020 8421 10

51 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP FIVE: Add subsequent placeholders. If the sum is greater than than the number being converted, put a “0” above and disregard it. Otherwise, put a “1” above and including it in your running total. 23 10 = 24242424 16 23232323 22222222 21212121 20202020 8421 10111

52 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP SIX: The resulting 1s and 0s in the top row form the binary equivalent of the Base-10 number with which we started: 23 10 = 10111 2

53 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 Now, let’s try successive division … Remember our problem: 23 10 = ? 2

54 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP ONE: Draw a table with three columns. Label the last two columns quotient and remainder, respectively. QR

55 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP TWO: In the first available left-most column, put the expression 23/2. Calculate the division and put the quotient and remainder in their respective columns. QR 23/2111

56 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP THREE: Take the quotient of the previous expression and divide it by two. Repeat until have 0 for a quotient. QR 23/2111 11/251 5/221 2/210 1/201

57 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 STEP FOUR: Read the REMAINDER column from the bottom to the top. The 1s and 0s in the remainder column represent the binary number. QR 23/2111 11/251 5/221 2/210 1/201

58 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Converting Base-10 to Base-2 23 10 = 10111 2 QR 23/2111 11/251 5/221 2/210 1/201

59 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Arithmetic Computer processing requires a little more capability in binary math, notably arithmetic.Computer processing requires a little more capability in binary math, notably arithmetic. Let’s consider addition and subtraction …Let’s consider addition and subtraction …

60 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Addition Just a few combinations are possible:Just a few combinations are possible: –0 2 + 0 2 = 0 2 –0 2 + 1 2 = 1 2 –1 2 + 0 2 = 1 2 What about 1 2 + 1 2 ?What about 1 2 + 1 2 ?

61 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Addition 1 2 + 1 2 = 10 2 Remember what that 10 means: it means a zero in the right column, and a one in the left columnRemember what that 10 means: it means a zero in the right column, and a one in the left column When you carry in base two, you are bringing a power of two to the left…When you carry in base two, you are bringing a power of two to the left…

62 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Addition 1110 2 +1011 2 10 1+ 0 11 2 =14 10 =11 10 =25 10

63 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Subtraction Subtraction in base two is similar to additionSubtraction in base two is similar to addition –11 2 – 11 2 = 00 2 –11 2 – 00 2 = 11 2 –10 2 – 00 2 = 10 2 What about 10 2 - 1 2 ?What about 10 2 - 1 2 ?

64 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Subtraction 10 2 - 1 2 = 1 2 Think about borrowing in decimal – you are really borrowing a power of your base …Think about borrowing in decimal – you are really borrowing a power of your base … In Base-10, we borrow 10 from the left column and give it to the next column to the right. So …In Base-10, we borrow 10 from the left column and give it to the next column to the right. So … In Base-2, we borrow 2 from the left column and give it to the next column to the right.In Base-2, we borrow 2 from the left column and give it to the next column to the right.

65 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Subtraction 00110011 2 -00010110 2 10 11 1 00 1 11000 2 =51 10 =22 10 =29 10

66 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Binary Borrowing: A Little Trick Many students find it convenient to just mentally convert the binary number to decimal, complete the subtraction, and then convert the answer back to binary.Many students find it convenient to just mentally convert the binary number to decimal, complete the subtraction, and then convert the answer back to binary. Consider 10 2 – 1 2 = ?Consider 10 2 – 1 2 = ? –A one in binary is still a one in decimal –When you borrow for the zero, you bring over a power of two, which is equal to two –The decimal conversion for the borrowing is 2-1, which is 1 –And 1 10 = 1 2 Be sure to add your answer back up as a checkBe sure to add your answer back up as a check

67 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Computer Data Computers are very good at representing data in binary (1s and 0s)Computers are very good at representing data in binary (1s and 0s) However, computers can also deal with other data types:However, computers can also deal with other data types: –Text –Numbers –Graphics –Music –Video How?How?

68 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Storing Integer Numbers Convert the integer to binaryConvert the integer to binary Add a switch for positive/negativeAdd a switch for positive/negative -19 10 = -10101 2 -10101

69 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Storing Floats (Real Numbers) Uses two memory positions:Uses two memory positions: –Store the number, without the decimal point, in one slot –Store the number of digits to the LEFT of the decimal point in another slot 123.4567 10 12345673

70 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Storing Strings Need to convert strings to ASCII (American Standard Code for Information Interchange) code firstNeed to convert strings to ASCII (American Standard Code for Information Interchange) code first ASCII code is then converted to Base-2 equivalent:ASCII code is then converted to Base-2 equivalent: CHARDECBIN A651000001 B661000010 C671000011 D681000100

71 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Memory When a computer works on data, it processes the data while the data is housed in memoryWhen a computer works on data, it processes the data while the data is housed in memory Memory provides very fast access to dataMemory provides very fast access to data Memory is volatile (this can be both an advantage and disadvantage)Memory is volatile (this can be both an advantage and disadvantage)

72 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Memory Components MemoryMemory –Where data is stored when a computer is not processing that data –Similar to the parking lot in front of a car repair shop RegistersRegisters –Where data is stored when the computer is processing that data –Similar to a repair bay inside a car repair shop

73 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The Elemental Commands Understood by ALL digital computersUnderstood by ALL digital computers Used to manipulate dataUsed to manipulate data Commands:Commands: –LOAD –STORE –ADD –TEST (COMPARE) –JUMP –HALT

74 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The LOAD Command Take data from a MEMORY slot and put the data into a REGISTERTake data from a MEMORY slot and put the data into a REGISTER Opposite of the STORE commandOpposite of the STORE command

75 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The STORE Command Take data from a REGISTER and put the data into a MEMORY slotTake data from a REGISTER and put the data into a MEMORY slot Opposite of the LOAD commandOpposite of the LOAD command

76 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The ADD Command Add the values of two REGISTERSAdd the values of two REGISTERS All other arithmetic operations can be derived from add!All other arithmetic operations can be derived from add!

77 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The COMPARE Command Compare (test) two REGISTER valuesCompare (test) two REGISTER values Used in conjunction with the JUMP commandUsed in conjunction with the JUMP command

78 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The JUMP Command Tells the computer to move to another command in the list of instructionsTells the computer to move to another command in the list of instructions Used when the computer’s behavior should change based on certain circumstancesUsed when the computer’s behavior should change based on certain circumstances

79 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science The HALT Command Indicates the list of commands is finishedIndicates the list of commands is finished Without the HALT, the computer would process until the end of memory is reached – “Out of memory errors”Without the HALT, the computer would process until the end of memory is reached – “Out of memory errors”

80 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Fetch & Execute Cycle Together, a command list is called the Fetch & Execute CycleTogether, a command list is called the Fetch & Execute Cycle Computer gets (fetches) a command, executes it and then moves on to the next commandComputer gets (fetches) a command, executes it and then moves on to the next command

81 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science ABNIAC Computer simulatorComputer simulator Uses commands similar to the Elemental CommandsUses commands similar to the Elemental Commands Includes output optionsIncludes output options http://klingon.cs.iupui.edu/~aharris/abniac/java/

82 CSCI N201: Programming Concepts Copyright ©2004  Department of Computer & Information Science Questions?


Download ppt "CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Essence of Computation."

Similar presentations


Ads by Google