Computer Software: Introduction

Similar documents
Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

INFS 214: Introduction to Computing

Principles of Programming Languages. Lecture Outline

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

The Programming Process Summer 2010 Margaret Reid-Miller

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Software Concepts. It is a translator that converts high level language to machine level language.

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

LESSON 13: LANGUAGE TRANSLATION

Programming 1 - Honors

Chapter 1. Preliminaries

An Introduction to Python (TEJ3M & TEJ4M)

CHAPTER 1 Introduction to Computers and Java

printf( Please enter another number: ); scanf( %d, &num2);

CSI32 Object-Oriented Programming

1) How many gigabytes make a terabyte? A) 10 B) 100 C) 1000 D) 1024 E) 512

Copyright 2005 Department of Computer & Information Science

Computer Components. Software{ User Programs. Operating System. Hardware

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Lecture 1: Preliminaries

Java and Software Design

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Introduction to Java Programming

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Computer Components. Software{ User Programs. Operating System. Hardware

3/13/2012. ESc101: Introduction to Computers and Programming Languages

Introduction to Computers and Java

Computer Fundamentals

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Life Cycle of Source Program - Compiler Design

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

Technical Questions. Q 1) What are the key features in C programming language?

Chapter 1 Preliminaries


Software Development. Integrated Software Environment

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Chapter 1: Introduction to Computers and Programming

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

AMCAT Automata Coding Sample Questions And Answers

CPE 101. Overview. Programming vs. Cooking. Key Definitions/Concepts B-1

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

Lectures 5-6: Introduction to C

From High Level to Machine Code. Compilation Overview. Computer Programs

Programming Languages, Summary CSC419; Odelia Schwartz

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

Högnivåspråk och översättning

An Introduc+on to Computers and Java CSC 121 Spring 2017 Howard Rosenthal

1 Little Man Computer

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

Chapter 1 INTRODUCTION

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

Chapter 11 Introduction to Programming in C

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Chapter 11 Introduction to Programming in C

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

Concepts of Programming Languages

UNIT I. Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4. 1

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

Chapter 1. Preliminaries

Chapter 1 & 2 Introduction to C Language

Chapter 11 Introduction to Programming in C

Part (04) Introduction to Programming

Assembly Language Fundamentals

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Chapter 1. Introduction to Computers and Programming. M hiwa ahmad aziz

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Introduction to C An overview of the programming language C, syntax, data types and input/output

Chapter 11 Introduction to Programming in C

COMP 202 Java in one week

Lecture 03 Bits, Bytes and Data Types

Computer Programming-I. Developed by: Strawberry

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

COMP 202 Java in one week

Motivation was to facilitate development of systems software, especially OS development.

Scientific Computing

Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists HST 952. Computing for Biomedical Scientists

COSC121: Computer Systems: Runtime Stack

Class List. Java Must Have. Class Goals. Class Goals. Schedule

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Introduction to Computer Programming Using FORTRAN 77

CPS122 Lecture: From Python to Java

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Transcription:

Software: A collection of programs Computer Software: Introduction Program: Sequence of instructions for the computer to carry out Programs written using a programming language Types of languages: Machine language Assembly language High-level languages Everything computer uses when running is stored in main memory This means that programs are stored in binary format Ultimately, the CPU can only understand binary instructions Every language characterized by 1. Syntax Rules that specify the form of valid sentences in the language Rules called a grammar 2. Semantics The meanings associated with language constructs 1

Computer Software: Machine Language Each instruction is in pure binary format Instructions of form opcode operands There is an opcode for each specific operation the CPU can perform Operands may take the form of Values (e.g., 105, c ), or Addresses (RAM - which represent variables - or registers) Instructions may have from 0 to 3 operands Each family of chips (CPUs) uses a set of instructions specific to it For example: 10100101 01100000 11010101 00000110 10000101 01100001 6502 chip 8 bit opcode, 8 bit operand Performs x = y + 6 Problems: Instructions not easy to remember Easy to make mistakes Hard to find mistakes Programmer must explicitly manage memory 2

Uses mnemonic instructions Computer Software: Assembly Language 1:1 correspondence between assembly language and machine language For example: LDA 96 ADC 6 STA 97 6502 chip Performs x = y + 6: 1. Load Accumulator from address 96 (y) 2. Add 6 to contents of accumulator 3. Store contents of accumulator to address 97 (x) CPU cannot directly execute program because not binary Assembler: Program that converts assembly language into machine language Comparison to machine language: Easier to understand than machine code Less easy to make mistakes Easier to correct mistakes Requires extra step (assembly) Every time change code, must reassemble 3

Uses English-like instructions Computer Software: High-level Language Uses symbolic references (variables) to memory For example: x = y + 6 Example languages: BASIC, FORTRAN, COBOL, C, C++, Lisp, Java These are independent of any CPU Must be converted to machine language 1. Interpreter Reads one HL instruction at a time Translates that instruction to machine code Executes the machine code Repeats until every HL instruction executed 2. Compiler Entire HL program converted into a machine language program Machine program executed 4

Comparison of interpreters v compilers Interpreters: Computer Software: High-level Language (2) Programs execute slowly (must wait for each instruction to be translated) Catch errors exactly where they occur Compilers: Programs execute fast (cause is machine code) Generated errors may occur far from the actual problem Programs must be recompiled after every change There must be a compiler/interpreter for every family of chips Comparison of high-level v low-level languages Low-level: Most efficient code Can take advantage of chip s special features High-level Faster to write ( 10X faster) Self-documenting Allows programmer to ignore low-level details Portable 5

Computer Software: Systems Software Purpose is to manage the resources of the computer The main piece is the operating system (OS) Program that controls the operation of the computer (e.g., Windows, Mac OS X, Linux) OS provides the following services: 1. Interface Provides means for user to communicate with computer When user issues a command, the OS (a) Interprets the command (b) Schedules the corresponding program (c) After program done executing, returns control to user 2. Security Handles user names and passwords Controls access to system resources based on privileges 3. Efficient allocation of resources Handling requests for devices Multiple requests for a resource placed in a queue Multitasking: Doing several things at once Some tasks much slower than others; e.g., IO When waiting for slow operations to complete, can be working on another task Time sharing: Multiple users on the same computer Must insure no one monopolizes the CPU Give each user a time slice of computing 4. Safe use of resources Prevents situations that could cause computer to crash E.g., Access of areas of memory allocated to system programs and data Concurrency issues 6

Other types of system software: Computer Software: Systems Software (2) 1. Language translators (e.g., compilers) 2. Memory managers E.g., loaders and linkers (see later) Determine where things are stored in RAM 3. Information managers E.g., file systems, database systems 4. Scheduler Responsible for determining order of task execution 5. Utilities E.g., word processors, graphics tools, web browsers 7

Every program has 3 aspects: Computer Software: Program Development 1. Input - Data to be processed is made accessible to program 2. Process - Data is processed (producing meaningful info) 3. Output - Processing results are made available to user Software Life Cycle (Program Development Cycle) General process describing steps used to develop programs: 1. Analyze Basic problem-solving - identifying what the problem is Generate program requirements/specifications: Id input and output 2. Design Identify program constructs and processing required to solve problem Involves designing an algorithm: A step-by-step sequence of unambiguous instructions for solving a problem in a finite amount of time Example: Algorithm to convert binary to decimal Given: binary integer n Let power = 2 0 Let ans = 0 Let length = number of digits in n Let d = rightmost digit of n While have not processed all length digits yet Let ans = ans + power d Let power = next power of 2 Let d = digit to left of d return ans 8

Computer Software: Program Development (2) Example: Another algorithm to convert binary to decimal Given: binary integer n Let ans = 0 Let length = number of digits in n Let d = leftmost digit of n While have not processed all length digits yet Let ans = 2 ans + d Let d = digit to right of d return ans 3. Implement Write code **Compile **Debug (Syntax errors) 4. Test Generate test cases Run/execute the program Debug (Logic and semantic errors) 5. Maintain Includes documentation and tweaking as needed 9

Computer Software: Program Structure In general, all programming languages have same set of constructs Major differences are in syntax and paradigm (imperative, object-oriented, functional, declarative) General differences include 1. Fixed v free format Fixed format languages (e.g., FORTRAN) expect instructions to be placed just so on a line, usually one instruction per line Free format languages can place instructions anywhere without restriction Lines separated by special characters called delimiters 2. Case sensitive v non-case sensitive In languages that are case-sensitive, upper v lower case makes a difference 10

Computer Software: Language Components Every language consists of a small set of conceptual components 1. An alphabet A set of symbols from which the language is constructed 2. Reserved (key) words A set of words with special meaning in the language They cannot be redefined by the programmer 3. Syntax The rules governing valid sentences in the language Rules called a grammar For example, the following programs (in C and Lisp) to convert binary to decimal demonstrate syntax differences in languages 11

Computer Software: Language Components (2) //************************************************ //* Convert binary to decimal: C version * //************************************************ #include <stdio.h> #include <string.h> void reverse (char []); int main () { char input[32]; int i; int ans; int length; int power; scanf("%s", input); reverse(input); length = strlen(input); ans = 0; power = 1; for (i = 0; i < length; i++) { if (input[i] == 1 ) ans = ans + power; power = power * 2; } printf("result is %d\n", ans); } return 0; void reverse (char s[]) { int c, i, j; } for(i = 0, j = strlen(s) - 1; i < j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } 12

Computer Software: Language Components (3) ;************************************************ ;* Convert binary to decimal: Lisp version * ;************************************************ (defun bintodec () (let ((input (read)) (ans 0)) (setq input (reverse (princ-to-string input))) (do* ((i 0 (+ i 1)) (power 1 (* power 2))) ((= i (array-total-size input))) (if (char= #\1 (char input i)) (setq ans (+ ans power))) ) ans ) ) 4. Semantics The meaning behind the constructs of the language Learning a language is learning these components 13

Computer Software: Program Constructs In general, all programming languages have same set of constructs 1. Comments Documentation used to (a) Indicate history (e.g., programmer names, creation date, date last modified) (b) Explain algorithms used (c) Explain uses of variables (d) Etc. Comments ignored by compiler 2. Identifiers Strings/words that represent program components, e.g., (a) Variables (b) Constants (c) Reserved words 3. Variables Represent values stored in memory Have specific data type allocated specific amount of storage 4. Declarations Specify data type (integer, float, string,...) of construct Needed so (a) Computer allocates proper amount of storage (b) Computer knows how to interpret the binary value stored there 5. IO statements Accept input from mouse, keyboard, etc. Write output to file, display, printer, etc. 6. Assignment statement Assigns values to variables 14

7. Control statements Computer Software: Program Constructs (2) Control order in which statements are executed Sequence (default) Statements simply executed in order that they appear in the program Loop (iteration, repetition) Causes set of statements to be repeated E.g., for, while, do Usually number of times loop repeats controlled by a loop control variable Inifinite loop is one that loops forever, usually the result of incorrect usage of LCV Conditional (if) Determines which of a set of instructions are executed based on a condition (predicate) Conditions expressed in terms of (a) Relational operators (<, >, >=,...) (b) Boolean operators (AND, OR, NOT) Subprogram call Causes control to jump to a subprogram (function, method, subroutine) Subprogram executes like a miniprogram When done, control returns to point after call Values called parameters can be passed into the subprogram for processing Values can be returned by the subprogram 15

Computer Software: Program Constructs (3) Example: //************************************************ Comments //* Convert binary to decimal: C version * //************************************************ #include <stdio.h> #include <string.h> void reverse (char []); int main () { char input[32]; int i; int ans; int length; int power; Precompiler statements Function declaration Start of program Variable declarations scanf("%s", input); reverse(input); length = strlen(input); ans = 0; power = 1; for (i = 0; i < length; i++) { if (input[i] == 1 ) ans = ans + power; power = power * 2; Input statement Function call Assignment statements Start of loop statement Conditional statement } End of loop printf("result is %d\n", ans); Output statement } return 0; void reverse (char s[]) { int c, i, j; Function definition } for(i = 0, j = strlen(s) - 1; i < j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } 16

Computer Software: Creating an Executable Program The process of compiling and executing a program involves a number of substeps 1. Precompiling Instructions to the precompiler are indicated with special symbols The precompiler searches the source code for them, and converts the code into instructions in the rogramming language 2. Compiling The modified source code is converted into assembly code It is most likely not complete It may access code that is stored in software libraries that has already been compiled Merging the component pieces of code occurs later 3. Assembling The assembly code is converted into machine code 17

4. Linking Computer Software: Creating an Executable Program (2) The linker finds the references in the object program to external code from the libraries The pieces of code are merged into a complete program 5. Loading The completed object program consists of relocatable code Variables, etc. do not have specific addresses The loader assigns program structures to memory and insures that all references are consistent The program and its variables are now in memory ready to run 6. Execution The address of the first instruction is loaded into the PC 18