Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is a computer program?

Similar presentations


Presentation on theme: "What is a computer program?"— Presentation transcript:

1 What is a computer program?

2 What is a Computer Program?
A solution to a problem? A confusing mess? A sequence of instructions?

3 What is a Computer Program?
A computer program is a sequence of statements written in a formal language and executed in sequential order There are some statements that can jump to another position in the sequence

4 Languages Languages have Natural language Formal language
syntax (the way in which words can be combined) and semantics (roughly, the meaning; the relation between the language and the world) Natural language Languages we speak: English, Spanish, Chinese, Finnish, etc Can grow (infinitely?) Can be redundant and ambiguous Pronouns Formal language A language we invent for some particular reason (like a programming language) Some might be meant to be machine interpretable Can grow but slowly and not infinitely Can not be redundant or ambiguous Programming languages are formal languages

5 Software Languages High level language Mid/Low level language
Highest level of abstraction C#, Java, Python, C++ Mid/Low level language Less abstraction – closer to the hardware C Assembly language No abstraction Mnemonics for instructions, memory location names Machine code (hardware) These are the binary op codes (instructions) that execute on the hardware

6 Software Languages "Vaporators? Sir, my first job was programming binary loadlifters—very similar to your vaporators in most respects."

7 CPU Instruction Set The instructions that the computer understands are its native Machine Language instructions (assembly language programs are written using these instructions directly). 8008 Instruction Set

8 Assembly Language A very small assembly language program to add two numbers from memory and place the result back in memory would look like this: LAM    5E00     ; Load data from address 5E0016 into A LBM    5E01     ; Load data from address 5E0116 into B ADB             ; Add A and B and put result in A  LMA    5E02     ; Move data from A to address 5E0216 HLT

9 What is a CPU Good At? Remembering things Simple math operations
Moving values to/from memory Computer moves things from CPU bus to display or network Simple math operations Add, subtract Multiply, divide are sometimes provided in separate floating-point processor Repetition Over, and over, ….. and over again Low level decision making Compare two values, jump on condition The job of the programmer is to implement an algorithm using these simple instructions to do the job that needs to be done Think about long division – step by step process (algorithm) to divide two numbers

10 Exercises in Describing an Algorithm
What are the steps to? Make a peanut butter and jelly sandwich Sort playing cards Sort cards by suit (spades, hearts, diamonds, clubs) and Rank (A, K, Q, J, 10 – 2) Count Legos by color Counts of each color of Legos Long division These processes must described in simple steps and must be complete so that someone else (even a computer) could follow them Think about how you would tell another person (or a computer) to do this Write down the steps Computer programming is a written form of art


Download ppt "What is a computer program?"

Similar presentations


Ads by Google