WJEC GCSE Computer Science

Slides:



Advertisements
Similar presentations
GCSE Computing Lesson 5.
Advertisements

CS 111: Introduction to Programming Midterm Exam NAME _________________ UIN __________________ 10/30/08 1.Who is our hero? 2.Why is this person our hero?
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
Programming Types of Testing.
COSC 120 Computer Programming
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Input, Output, and Processing
1 2. Program Construction in Java Programming Fundamentals.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
What on Earth? LEXEMETOKENPATTERN print p,r,i,n,t (leftpar( 4number4 *arith* 5number5 )rightpar) userAnswerID Letter followed by letters and digits “Game.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Introduction to Computer Programming using Fortran 77.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Chapter 1: Introduction to Computers and Programming
Topic 2: Hardware and Software
Component 1.6.
Compiler Design (40-414) Main Text Book:
GCSE COMPUTER SCIENCE Computers 1.5 Assembly Language.
Component 1.6.
CSC201: Computer Programming
Introduction to Programming and Visual Basic
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Introduction to programming
Lecture 1 Introduction Richard Gesick.
Topics Introduction Hardware and Software How Computers Store Data
F453 Computing Questions and Answers
Programming Mehdi Bukhari.
Chapter 1. Introduction to Computers and Programming
A451 Theory – 7 Programming 7A, B - Algorithms.
TRANSLATORS AND IDEs Key Revision Points.
Translators & Facilities of Languages
Chapter 1: Introduction to Computers and Programming
Course supervisor: Lubna Siddiqui
Introduction to the C Language
Chapter 10 Programming Fundamentals with JavaScript
CSCE Fall 2013 Prof. Jennifer L. Welch.
Topics Introduction Hardware and Software How Computers Store Data
Programming Errors Key Revision Points.
CMP 131 Introduction to Computer Programming
Problem Solving Skill Area 305.1
CSCE Fall 2012 Prof. Jennifer L. Welch.
Software Development Process
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Software Development Environment, File Storage & Compiling
Learning Intention I will learn about the different types of programming errors.
Chapter 10: Compilers and Language Translation
Chapter 6 Programming the basic computer
CHAPTER 6 Testing and Debugging.
Running & Testing Programs :: Translators
Presentation transcript:

WJEC GCSE Computer Science Unit 1 Translators and Errors

Objectives Describe and Explain the purpose of translators: Why translators, compilers, interpreters, and assemblers are needed The types of Programming Error that may occur including: Syntax Run-Time Logical Linking Rounding Truncation

Translators The code produced in most languages cannot be understood by a computer until it is translated, in some way, into machine code. Several tools are available to do this and they are collectively referred to as translators. Each translator is a piece of software with the job of making program code understandable to the computer.

Assemblers An assembler is a program which coverts the low level assembly programming language into machine code. The assembler does this by converting the one word assembly instructions into an opcode, e.g. converting AND to 0010. It also allocates memory to variables, often resulting in an operand.

Interpreters Before high level programming languages can be run, code is converted by an interpreter, one line at a time, into machine code, which is then executed by the CPU. A program translated in this way will run slower than if it is compiled, and if the program contains any errors the programmer will not find this out until the interpreter reaches the line containing the error.

Compilers A compiler is used when high level programming languages are converted into machine code, ready to be executed by the CPU. If there are any errors in the code, the program will not compile and the programmer will have to remove these errors before trying again.

Stages of Compilation For example: Message = “Hello World” print(Message) Would be turned into the following code: 2A 1A 1B Message 1B Lexical analysis Comments and unneeded spaces are removed. Keywords, constants and identifiers are replaced by 'tokens'. A symbol table is created which holds the addresses of variables, labels and subroutines. Keyword Token = 1A “ 1B ( 1C ) 1D print 1E Identifier Token Message 2A

Stages of Compilation Syntax analysis Tokens are checked to see if they match the spelling and grammar expected, using standard language definitions. If syntax errors are found, error messages are produced.

Stages of Compilation Semantic analysis Variables are checked to ensure that they have been properly declared and used. Variables are checked to ensure that they are of the correct data type, e.g. real values are not being assigned to integers. Operations are checked to ensure that they are legal for the type of variable being used, e.g. you would not try to store the result of a division operation as an integer.

Stages of Compilation For example: Message = “Hello World” print(Message) Would be turned into the following code: 2A 1A 1C 1B Message 1B 1D 1E 2A Code generation Machine code is generated. Code optimisation may be employed to make it more efficient/faster/less resource intense. Keyword Token = 1A “ 1B ( 1C ) 1D print 1E Identifier Token Message 2A

Workbook Complete section 7b Q1

Programming Errors Programmers are human, so they make mistakes. They actually make mistakes that fall into different categories. You need to be aware of the following types of error: Syntax Run-time / execution Logical Linking Rounding Truncation

Incorrect: IF A ADN B Then Syntax Error An error that occurs when a command does not follow the expected syntax of the language, e.g. when a keyword is incorrectly spelt. Example Incorrect: IF A ADN B Then Correct: IF A AND B Then

Runtime / Execution Error An error that only occurs when the program is running and is difficult to foresee before a program is compiled and run Examples Program requests more memory when none is available, so the program crashes The program might need a connection to the Internet in order to function, and the Internet is not currently available A fault with a piece of hardware, such as a particular disk drive, might prevent the program from completing its task

Logical Error An error that causes a program to output an incorrect answer (that does not necessarily crash the program) Example A program that calculates a percentage multiplies a value by 1000 instead of 100, giving the wrong answer.

Linking Error An error that occurs when a programmer calls a function within a program and the correct library has not been linked to that program Example When the square root function is used and the library that calculates the square root has not been linked to the program

Rounding Error Rounding is when a number is approximated to nearest whole number/tenth/hundredth, etc. Example 34.5 rounded to the nearest whole number is 35, an error of +0.5

Truncation Error Truncating is when a number is approximated to a whole number/tenth/hundredth, etc. nearer zero Example 34.9 truncated to whole number is 34, an error of -0.9

Workbook Complete section 7b Q2-3

Have you completed today’s work and any previous sections?

Programming Constructs Complete section 7c Q1-5