13-1 Programming…. 13-2 General Purpose The computer is a “general purpose” tool –General purpose means it can do more than one thing –How do we make.

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Algorithms and Program Development
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
The Analytical Engine Module 6 Program Translation.
COMP 4—Power Tools for the Mind1 PowerTools What’s in the Box? Turing 1: An Introduction to Programming You will learn elementary computer programming.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Computers: Tools for an Information Age
Assembly Language Programming. CPU The CPU contains a Control Unit, Arithmetic Logic Unit (ALU) and a small number of memory locations called Registers.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
The CPU The Central Presentation Unit Language Levels Fetch execute cycle Processor speed.
Assembly & Machine Languages
Computer Languages, Algorithms and Program Development
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Topics Introduction Hardware and Software How Computers Store Data
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
The Computer Continuum4-1 Computer Languages,. The Computer Continuum4-2 Computer Languages n In this chapter: What makes up a language and how do we.
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Input, Output, and Processing
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
Copyright © Prentice Hall Programming and Languages Chapter 14 Telling the Computer What to Do.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Introduction to Computers. High Level Structure of a Computer Major Components of a Computer –Central Processing Unit (CPU) – Controls the operation of.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
HOW A COMPUTER PROCESSES DATA. What is hardware? Hardware is the electric, electronic and mechanical equipment that makes up a computer What is software?
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Chapter 4 Software. Introduction Program: is a set of sequence instructions that tell the computer what to do. Software: is a collection of programs,
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
INTRODUCTION TO COMPUTER PROGRAMMING ITC-314. Computer Programming  Computer Programming means creating a sequence of instructions to enable a computer.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Computer Basics.
Chapter 1 Introduction 2nd Semester H
Component 1.6.
Topics Introduction Hardware and Software How Computers Store Data
CSCI-235 Micro-Computer Applications
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
What is a computer program?
Computers: Hardware and Software
CSCE Fall 2013 Prof. Jennifer L. Welch.
Topics Introduction Hardware and Software How Computers Store Data
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CMP 131 Introduction to Computer Programming
CSCE Fall 2012 Prof. Jennifer L. Welch.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Introduction to Computer Programming
Programming Logic and Design Eighth Edition
Presentation transcript:

13-1 Programming…

13-2 General Purpose The computer is a “general purpose” tool –General purpose means it can do more than one thing –How do we make it do more than one thing? make it perform a handful of small tasks that could be combined to perform more complicated tasks allow it to follow instructions to perform the above tasks –It is programmable (i.e., we can program it) A computer program: a list of instructions for the computer –What sort of instructions does the computer understand?

13-3 Tell me what to do... Make me a peanut butter and jelly sandwich: –What does this mean to you?

13-4 Really tell me what to do... 1.Go to the refrigerator 2.Open fridge 3.If ((no peanut butter) or (no jelly)) 1.Go to store and buy ingredients 4.Remove peanut butter and jelly 5.Get bread 6.Open bread 7.Do twice: 1.Take slice from bag 8.Place slices side by side 9.Get knife 10.Open peanut butter jar 11.Insert knife into jar 12.Apply peanut butter to knife 13.While surface of bread is not covered with peanut butter 1.Apply peanut butter to bread from knife 14.Close peanut butter jar 15.Open jelly jar 16.Insert knife into jar 17.Apply jelly to knife 18.While surface of bread is not covered with jelly 1.Apply jelly to bead with knife 19.Close jelly jar 20.Place both slices of bread together such that the side with peanut butter is touching the side with jelly and the uncovered sides are facing out. And we’re probably missing steps! “simple” tasks repetition logic

13-5 Language of Instructions What do we need to know about the target of our instructions before we can give them? How do we ask them to do things? What do they know how to do? What language do they speak?

13-6 Syntax and Grammar Syntax – the form of what you say –The grammatical structure (form) of a language –Grammar: defines the words you are allowed to use and specifies the order in which you can place them a grammar defines a syntax noun := sandwich connector := and adjective := peanut butter | jelly | adjective connector adjective verb := make simpleRequest := verb noun | verb adjective noun –a simpleRequest can be »make peanut butter and jelly sandwich »make sandwich »make jelly sandwich »make jelly and jelly sandwich »make jelly and jelly and jelly sandwich –A grammar tells you how to parse a message into simpler parts »(…or how to compose a message from parts) the sandwich grammar

13-7 Language of instructions Semantics – the meaning of what is said –Semantics explain how you interpret the results of parsing make is a verb –A verb tells me what action to take peanut butter and jelly is an adjective –An adjective tells me about a noun sandwich is a noun –The noun is the target of my action –The semantics provide the meaning for each of these things: Ex: “when you encounter a make adjective sandwich you will need to get two pieces of bread, and put the adjective between the pieces of bread.” –How does this relate to computers? Beyond the obvious fact that in the future there will be robots and they will make us sandwiches

13-8 Applied to Computers... What language does a computer “speak” ? –Computers “think” in binary. –Internally, they only understand 1’s and 0’s –We’ve learned that computers can do fancy things with 1’s and 0’s Boolean logic Mathematics Store and retrieve 1’s and 0’s We need the computer to know that a particular sequence of 1’s and 0’s uniquely identifies some task to do (semantics) We need to give the computer a series of 1’s and 0’s –Ideally: we (humans) would like a mapping between English (or something closer to English) and something that makes sense to the computer (binary)

13-9 In the beginning Early computers were primarily special purpose mathematic computers. –Computers were designed to perform a particular arithmetic task or set of mathematic tasks. Computers that were unable to change their tasks are “hardwired” –Hardwiring: Using solder to create circuit boards with connections needed to perform a specific task (in a larger sense). Computers that were able to have their tasks changed required direct “hardware modification” by skilled engineers –Change the flow of electricity to run through different logic paths –Fat-fingering: Engineer needed to position electrical relay switches manually.

13-10 The Programming Language Continuum ENIAC –Used programs to complete a number of different mathematical tasks. Programs were entered by plugging connector cables directly into sockets on a plug-in board. –Set-up could take hours. –A program would generally be used for weeks at a time.

13-11 The Programming Language Continuum In the beginning… To use a computer, you needed to know how to program it. Today… People no longer need to know how to program in order to use the computer. –In fact, programming has become easier as well –programming languages “evolve” from low-level to high-level. –Fifth Generation - Natural Languages –Fourth Generation - Non-Procedural Languages –Third Generation - People-Oriented Programming Languages –Second Generation - Assembly Language –First Generation - Machine Language (code) High level Low level

13-12 Representing (Instructions) Programs Arithmetic Instructions –Addition, subtraction, multiplication, division, and other numeric operations Data Movement Instructions –Move numbers from place to place in the computer Logical or Comparison Instructions –Decision making instructions e.g. x < 10 Control Instructions –Controls the sequences in which instructions are executed e.g. for x = 1 to 10 Input/Output Instructions –Allow the program to communicate with something outside the program (user, monitor, network, other programs)

13-13 Representation of Programs Program: A collection of instructions for the computer. –Instructions are broken down into an opcode and an operand Opcode – what to do Operand – additional info needed to do the opcode Instruction – opcode + operand –For some specific given CPU, imagine there are only eight valid opcodes (shown below) READ PRINT ADD SUB STORELOAD PJUMPSTOP

13-14 Representation of Programs –Although we could simply use the ASCII codes and store each command as a collection of characters... at some point the CPU will need to be able to “make decisions” based on opcodes – i.e., these opcodes will be binary input to the Instruction Decoding Unit To have the CPU directly understand ASCII would require many more wires/bits input into the CPU Map each opcode into a binary number READ = 000 LOAD = 001 ADD = 010 etc.. And each operand will also be in binary such that the entire instruction is binary –Ex: –What does the operand mean? –It could be a number, a symbol, a sound, a pixel of an image... –It’s the context (program/instruction) that gives meaning

13-15 Generation I: Machine Language Machine language programs made up of instructions written in binary code. Computers operate in their “native” language Humans translate their instructions into binary Each instruction has two parts: Operation code, Operand –Operation code (Opcode): The command part of a computer instruction. –Operand: The address of a specific location in the computer’s memory. –You write programs in the “lowest-level” language directly for the CPU. Opcodes do very simple things (the computer is “dumb”) and you have it perform more complicated tasks by combining these instructions.

13-16 Generation I: Machine Language example... Store the accumulator value into memory location “15” Add the contents of memory slot “13” into the accumulator Load contents of memory slot “14” into accumulator MeaningOperandOpcodeInstruction # (slot #)

13-17 Generation I: Machine Language Machine language –Hardware dependent: Could be performed by only one type of computer with a particular CPU. –That is, each computer (although all speak binary) might have different arrangements of 1s and 0s for different instructions. »“Different words could have different meanings” »Maybe some computers can’t do the same things –111 might be add to me, but 010 might be add to you..

13-18 Generation II:Assembly Second Generation - Assembly Language –Assembly language programs are made up of instructions written in mnemonics. –Mnemonics: Uses convenient alphabetic abbreviations to represent operation codes, and abstract symbols to represent operands. –Each instruction (still) had two parts: Operation code, Operand »One-to-one mapping from written instruction to machine instruction –Still a “low-level” language –“higher level languages” »Easier on the programmer READnum1 READnum2 LOADnum1 ADDnum2 STOREsum PRINTsum STOP

13-19 The Programming Language Continuum Second Generation - Assembly Language –Assembly language programs are made up of instructions written in mnemonics. »Because programs are not written in 1s and 0s, the computer must first translate the program before it can be executed. »The translation is a direct translation »We translate into machine code READ == OPCODE 001 num1 == Memory … READnum1 READnum2 LOADnum1 ADDnum2 STOREsum PRINTsum STOP

13-20 Assembled, Compiled, or Interpreted Languages Assembled languages: –Assembler: a program used to translate Assembly language programs. –Produces one line of binary code per original program statement. The entire program is assembled before the program is sent to the computer for execution.

13-21 Generation: III Third Generation – High-level languages –Instructions in these languages are called statements. High-level languages: Use statements that resemble English phrases combined with mathematic and logical terms needed to express the problem or task being programmed. As before, programs are not written in 1s and 0s, the computer must first translate the program before it can be executed. –Instructions are more complicated – one may actually represent several simple opcodes –NOT-Hardware dependent. “portable” –So, as long as you can translate the statements from this language to another machine code, you can run it on that platform. (more on this later)

13-22 High Level Language Example Pascal Example: Read in two numbers, add them, and print them out. Program sum2(input,output); var num1,num2,sum : integer; begin writeln( ” please enter num1 ” ); read(num1); writeln( ” please enter num12 ” ); read(num2); sum:=num1+num2; writeln(sum); end.

13-23 Generation: IV Fourth Generation - Non-Procedural Languages –Object-Oriented Languages: A language that expresses a computer problem as a series of objects a system contains, the behaviors of those objects, and how the objects interact with each other. Object: Any entity contained within a system. –Examples: »A window on your screen. »A list of names you wish to organize. »An entity that is made up of individual parts. –Objects pass messages, expose interfaces, can be inherited from other objects... Some popular examples: C++, Java, Smalltalk, Eiffel.

13-24 O-O Language Example –Object-Oriented Languages: example (Simplified Java?): Object Person{ String name; String gender; Integer age; String socialSecurityNumber; } Object BUStudent extends Person{ // contains all properties of a person String BUID; Float GPA; // etc... }

13-25 Generation: V Fifth Generation - Natural Languages –Natural-Language: Languages that use ordinary conversation in one’s own language. Research and experimentation toward this goal is being done. –Intelligent compilers are now being developed to translate natural language (spoken) programs into structured machine- coded instructions that can be executed by computers. –Effortless, error-free natural language programs are still some distance into the future.