software - how to make a computer useful

17
Software - How to make a computer useful

Upload: courtney-erickson

Post on 03-Jan-2016

32 views

Category:

Documents


1 download

DESCRIPTION

Software - How to make a computer useful. What is software really?. Software is the ”magic wand”, which transforms the computer from dead metal to a useful tool The function of a computer is almost entirely determined by the software - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Software - How to make a computer useful

Software- How to make a computer useful

Page 2: Software - How to make a computer useful

SWC1

What is software really?

• Software is the ”magic wand”, which transforms the computer from dead metal to a useful tool

• The function of a computer is almost entirely determined by the software

• For a DVD player, a specific movie is the ”software” for the player; we are not as such con-cerned about the player itself

Page 3: Software - How to make a computer useful

SWC1

What is software really?

• More technical: Very accurate instructions to the computer, concerning how to react to various types of input

• The input could be:– A mouse click or movement– Pressing keys on a keyboard– Data in a file– Data from the Internet– Various other sources

Page 4: Software - How to make a computer useful

SWC1

How to create software

• Initially, we have some sort of idea about what the software is supposed to do

• This must in turn be evolved to a very detailed specification concerning the functionality of the software

• A specification will be a collection of rules defining the behavior of the software, in all possible scenarios

• Formulating such rules may be quite hard in some situations…

Page 5: Software - How to make a computer useful

SWC1

How to create software

• Example: Multiplication• Multiplying two (large) numbers

may be hard for a human being, but the rules are quite clear

• Quite easy to make a program, which can multiply two numbers

• A computer can perform multipli-cation much faster than any human being

Page 6: Software - How to make a computer useful

SWC1

How to create software

• Example: Chess• Chess is hard, even though the rules are precise!• What is hard about chess? To measure, if some

specific move makes your position better, and by how much

• If you can define a good measure for the ”quality” of a position, you just need to try a lot of them…

• The best chess programs are fairly equal to the best human chess players

Page 7: Software - How to make a computer useful

SWC1

How to create software

• Eksempel: Perception of emotions• Human beings are good – some better than

others – at perceiving other peoples emotions just by looking at them

• It is very hard to define precise rules for this – we ”just do it”

• Even the best software – used e.g. in a robot – is much poorer at perceiving emotions than a human being

Page 8: Software - How to make a computer useful

SWC1

How to create software

• If we are able to describe a set of rules for how to achieve a certain behavior, how do we then describe these rules to a computer!?

• In what language do we describe the rules?• Recall that the computer can basically only do

binary addition…• How do we bridge the gap, and find a way to

describe the rules, so both we and the computer agree on the interpretation of the rules?

Page 9: Software - How to make a computer useful

SWC1

The long road…

Humanlanguage

Programminglanguage

(Java)

CPU-language

(assembler)

Micro-code

0’s and1’s

Idea Pro-gram

Human beings(Brain)

Software(Compiler)

Computerhardware

Page 10: Software - How to make a computer useful

SWC1

Human language

• First step is to formulate the rules for the behavior in ordinary human language

• Must be as concise as possible• Example (from chess):

– If your king is in check, you must1. Move your king to a position where it is not in check, or

2. Move another piece so that the king is no longer in check

– If both 1 and 2 are impossible, you have lost

• Problem: Ordinary language is not very precise, and filled with assumptions

Page 11: Software - How to make a computer useful

SWC1

Programming language

• We must now formulate the rules in a different language, which another program can translate into a language which the computer understands

• This language bridges the gap between humans and computer

• A compromise between being logically concise, and being humanly understandable

Page 12: Software - How to make a computer useful

SWC1

Programming language

if (myPieces.King.Status == Check) then

{ // NOTE: This is not precise Java

if (board.noCheck(myPieces.King).exists == true)

then (myPieces.King.move())

else

if (myPieces.avoidCheck().exists == true)

then (myPieces.avoidCheck().move())

else

myGame.status = lost;

}

Page 13: Software - How to make a computer useful

SWC1

The language of the CPU

• The program, which translates from our programming language to the language of the CPU, is known as a compiler

• The language of the CPU is often called assembler code

• Humans can read assembler code, but it is quite hard, and requires lots of practice…

Page 14: Software - How to make a computer useful

SWC1

Assembler code

MOV AH, 08

INT 21

CMP AL, 42

JZ 0116

MOV BH, 12

INT 32

NJZ 0100

Uhm… what!?

Page 15: Software - How to make a computer useful

SWC1

Micro-code

• Assembler code is almost impos-sible to understand for humans, but the CPU understands!

• The CPU makes yet another translation, to micro code

• The part of the CPU which performs the actual calculation understands micro code

• Extremely hard to understand

Page 16: Software - How to make a computer useful

SWC1

Micro code

0A B1 23 41 88

6C 12 92 CB 9A

88 2E 11 07 AE

…or just

0010010101001001010

0101001101111011010

1001001010101111110

Page 17: Software - How to make a computer useful

SWC1

0’s and 1’s

• The CPU can process micro code instructions quite effectively

• This is the realm of the transistors!• In terms of language, we have

traveled a very long road, involving humans, other software, and the computer itself

• Still quite hard to produce software, but (fortunately) much easier than at the dawn of computers