High level code and machine code

Similar documents
3 SOFTWARE AND PROGRAMMING LANGUAGES

The use of binary codes to represent characters

MACHINE ARCHITECTURE & LANGUAGE

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Memory booklet. RDaSH. Occupational therapy. Doncaster Community Integrated Services

Levels of Programming Languages. Gerald Penn CSC 324

Notes on Assembly Language

Lab Experience 17. Programming Language Translation

The Little Man Computer

Chapter 5 Instructor's Manual

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Chapter 12 Programming Concepts and Languages

1 Classical Universal Computer 3

CPU Organization and Assembly Language

1/20/2016 INTRODUCTION

Chapter 6: Programming Languages

Chapter 13: Program Development and Programming Languages

Ch. 10 Software Development. (Computer Programming)

MICROPROCESSOR AND MICROCOMPUTER BASICS

(Refer Slide Time: 00:01:16 min)

Java CPD (I) Frans Coenen Department of Computer Science

Candidates should be able to: (i) describe the purpose of RAM in a computer system

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

PART B QUESTIONS AND ANSWERS UNIT I

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15

Chapter 14. Programming and Languages. McGraw-Hill/Irwin. Copyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.

8085 INSTRUCTION SET

BASIC COMPUTER ORGANIZATION AND DESIGN

================================================================

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

PROBLEMS #20,R0,R1 #$3A,R2,R4

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

CSE 141L Computer Architecture Lab Fall Lecture 2

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Central Processing Unit (CPU)

Report on the Examination

LC-3 Assembly Language

An Introduction to MPLAB Integrated Development Environment

Instructor Özgür ZEYDAN BEU Dept. of Enve. Eng. CIV 112 Computer Programming Lecture Notes (1)

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Instruction Set Architecture (ISA)

Python Programming: An Introduction to Computer Science

The 104 Duke_ACC Machine

Exemplar Work for SAMs. Units A452 and A453

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

OAMulator. Online One Address Machine emulator and OAMPL compiler.

HOMEWORK # 2 SOLUTIO

Jonathan Worthington Scarborough Linux User Group

Chapter 13: Program Development and Programming Languages

Administrative Issues

Assembly Language Programming

LSN 2 Computer Processors

The WIMP51: A Simple Processor and Visualization Tool to Introduce Undergraduates to Computer Organization

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Programming Languages & Tools

Cambridge International AS and A Level Computer Science

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

CPU Organisation and Operation

Building Applications Using Micro Focus COBOL

McGraw-Hill The McGraw-Hill Companies, Inc.,

İSTANBUL AYDIN UNIVERSITY

Use of Simulator in Teaching Introductory Computer Engineering*

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Chapter 7 Assembly Language

What Brain Changes Are Normal for Older Adults?

Programming Logic controllers

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

CSCI 3136 Principles of Programming Languages

Chapter 2 Logic Gates and Introduction to Computer Architecture

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class

Coping with Memory Problems after Brain Injury Practical Strategies

Chapter 01: Introduction. Lesson 02 Evolution of Computers Part 2 First generation Computers

Summary of the MARIE Assembly Language

Python Programming: An Introduction to Computer Science

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

Basics of Computer 1.1 INTRODUCTION 1.2 OBJECTIVES

CS 40 Computing for the Web

Programming Languages The McGraw-Hill Companies, Inc. All rights reserved.

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Introduction to C++ Programming I. Ian Aitchison and Peter King

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Programming Languages

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Software Tracing of Embedded Linux Systems using LTTng and Tracealyzer. Dr. Johan Kraft, Percepio AB

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Fast Arithmetic Coding (FastAC) Implementations

Software: Systems and Application Software

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Computer Programming

MATHEMATICS: REPEATING AND GROWING PATTERNS First Grade. Kelsey McMahan. Winter 2012 Creative Learning Experiences

CHAPTER 7: The CPU and Memory

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

Transcription:

High level code and machine code Teacher s Notes Lesson Plan x Length 60 mins Specification Link 2.1.7/cde Programming languages Learning objective Students should be able to (a) explain the difference between high level code and machine code (b) explain the need for translators to convert high level code to machine code (c) describe the characteristics of an assembler, a compiler and an interpreter Time (min) Activity Further Notes 5 Ask the students to quickly write down the names of any computer programming languages that they know. Ask selected students for their ideas and ask if they know the difference between the terms low level language and high level language. Show students the link to the specification. Explain the purpose and objectives of the lesson. Other examples are available on YouTube. 15 Watch the set of videos. Stress that the methods shown used sound, light and the fixed positions of flags to encode letters which are then decoded by the recipient. Computers use binary digits to do the same thing. Show students the link to the specification. Explain the purpose and objectives of the lesson. 5 Ask some questions about the video to assess learning. e.g. What is the only language that a computer understands? Why don t programmers usually write programs using machine code? Name the types of translators that are used to convert other languages to machine code. 20 Worksheet 1 Students to complete Worksheet 1 either on paper or on computer using knowledge gained from video and internet research. Ask individual students for their answers and discuss with the class so that all students will have the correct answers entered on their worksheets. Machine code. Difficult to visualize a program that is just a stream of 1s and 0s. Assemblers, compilers, interpreters. Answers provided.

Time (min) Activity Further Notes 10 Activity Explain to the students that they are now going to use Assembly language in an on-screen simulator. (http://www.cambridgegcsecomputing.org/weblink19) Explain that they will be using mnemonics to input two numbers which will then be added together. Explain that they will use the mnemonics: INP input STA store a number in a memory address ADD add numbers in accumulator OUT output the results HLT halt the program The students should now use the demonstration run-through to carry out this activity. Ask the students to carry out research to find the mnemonics for further actions and carry out other examples on the website. Extension Challenge/Homework The students should complete and submit Worksheet 2. 5 Plenary Remind students of the learning points to take away, based on those discussed earlier e.g. What is the only language that a computer understands? Why don t programmers usually write programs using machine code? Name the types of translators that are used to convert other languages to machine code and the differences between them. Machine code. Difficult to visualize a program that is just a stream of 1s and 0s. Assemblers, compilers, interpreters.

WORKSHEET 1 ANSWERS 1 Explain what is meant by machine code. Machine code, also called machine language, is a computer language that is directly understandable by a computer s CPU (central processing unit). It is the only language that a computer can understand. The instructions opcodes and operands - are represented by strings of bits 1s and 0s. 2 Explain why other languages were developed to allow humans to program computers. Writing and reading a program as a string of 1s and 0s is very difficult for a human. It is difficult to memorise all of the instructions as 1s and 0s. The speed of writing, testing and debugging a program is very slow in machine language. 3 (a) Why is assembly language referred to as a low level language? The instructions are very similar to those in machine language there is usually a one-to-one relationship between the assembly and machine code instructions. (b) What are mnemonics and how are they used in assembly language? Mnemonics are tools that are designed to help a person s memory. They can be rhymes or phrases e.g. Richard of York gave battle in vain used to help remember the order of the colours of the spectrum red, orange, yellow, green, blue, indigo and violet. In assembly language the mnemonics are English-like words used to represent the binary opcodes of machine language e.g. the mnemonic ADD is used in assembly language for the opcode 110001011. SUB, MUL, DIV, RLC and RAL are other mnemonics used in assembly language. (c) What is an assembler used for? An assembler translates the symbolic codes (mnemonics) of programs of an assembly language into machine language instructions. It is translated to the machine code version in the ratio of one symbolic instruction to one machine code instruction.

WORKSHEET 1 ANSWERS 4 (a) What are high level languages? High level languages are called high-level because they are closer to human languages and are further removed from machine languages than assembly language. There is no one-to-one relationship between the instructions in a high level language and machine language as there is with assembly language. (b) List three examples of a high level language. Basic, C, Fortran, Python, Ada etc. (c) List three advantages of assembly language over a high level language. It requires less memory and execution time. It allows hardware-specific complex jobs in an easier way. It is suitable for time-critical jobs. It is most suitable for writing interrupt service routines and other memory resident programs. (d) List three advantages of using a high level language over assembly language. Faster program development it is less time consuming to write and then test the program. It is not necessary to remember the registers of the CPU and mnemonic instructions. Portability of a program from one machine to other. Each assembly language is specific to a particular type of CPU, but most high-level programming languages are generally portable across multiple architectures.

WORKSHEET 1 ANSWERS 5 Compilers and interpreters are needed to translate the high level code into machine code. What is the difference between a compiler and an interpreter? Give an advantage and disadvantage of each. A compiler reads the whole high level code and translates it into a complete machine code program which is output as a new file and can be saved. The biggest advantage of this is that the translation is done once only and as a separate process. The program that is run is already translated into machine code so is much faster in execution. The disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling. An interpreter reads the source code one instruction or line at a time, converts this line into machine code and executes it. The machine code is then discarded and the next line is read. The advantage of this is it s simple and you can interrupt it while it is running, change the program and either continue or start again. The disadvantage is that every line has to be translated every time it is executed, even if it is executed many times as the program runs. And because of this interpreters tend to be slow. 6 Complete the following diagrams by labelling the boxes. You may use the following words: source code, interpreter, assembler, object code, compiler source code translator object code translator assembler complier interpreter

WORKSHEET 2 ANSWERS 1 A consultant is developing a program for one of her customers. The program is written in high level code and then translated to machine code. (a) Describe two differences between high level code and machine code. (4) In high level code instructions use words. In machine code instructions are in binary code. High-level code is designed to be read by human programmers. Machine code is to be read/executed by the computer High level code can be portable/translated for different machines Machine code is specific to a particular machine. (b) One type of translator which can be used is an interpreter. Describe how an interpreter translates the high-level code to machine code. (2) Translates one line of HL code at a time and executes it stops when it finds an error can be resumed (c) State the name of a different type of translator which can be used to translate highlevel code to machine code. (1) Compiler