What Do I Represent?. Translators – Module Knowledge Areas Revisiting object code When we disassemble code we can view the opcodes used This is just a.

Slides:



Advertisements
Similar presentations
Assembly Language – 1.
Advertisements

GCSE Computing Lesson 5.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
The 8051 Microcontroller and Embedded Systems
Chapter 2 Machine Language.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
Lab6 – Debug Assembly Language Lab
Low-Level Programming Languages
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
ARM C Language & Assembler. Using C instead of Java (or Python, or your other favorite language)? C is the de facto standard for embedded systems because.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
Assembly & Machine Languages
UNDERSTANDING ASSEMBLY LANGUAGE.
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 2 Software Tools and Assembly Language Syntax.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CPS120: Introduction to Computer Science
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Instruction Set Architecture
Information Representation: Machine Instructions
Chapter 1: Basic Concepts
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
Programming With C.
What have mr aldred’s dirty clothes got to do with the cpu
Chapter 4 MARIE: An Introduction to a Simple Computer.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
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.
Computer Operations A computer is a programmable electronic device that can store, retrieve, and process data Data and instructions to manipulate the data.
What am I?. Translators Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and.
What on Earth? LEXEMETOKENPATTERN print p,r,i,n,t (leftpar( 4number4 *arith* 5number5 )rightpar) userAnswerID Letter followed by letters and digits “Game.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
1.4 Representation of data in computer systems Instructions.
What am I? while b != 0 if a > b a := a − b else b := b − a return a AST == Abstract Syntax Tree.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
8086/8088 Instruction Set, Machine Codes and Addressing Modes.
Getting ready. Why C? Design Features – Efficiency (C programs tend to be compact and to run quickly.) – Portability (C programs written on one system.
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Representation of Data Binary Representation of Instructions teachwithict.weebly.com.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
A Level Computing – A2 Component 2 1f, 1g, 1h, 1i, 1j.
Component 1.6.
GCSE COMPUTER SCIENCE Computers 1.5 Assembly Language.
F453 Computing Questions and Answers
Microprocessor T. Y. B. Sc..
Microprocessor and Assembly Language
The 8051 Microcontroller and Embedded Systems
William Stallings Computer Organization and Architecture 8th Edition
Teaching Computing to GCSE
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
Translators & Facilities of Languages
and Executing Programs
High Level Programming Languages
MARIE: An Introduction to a Simple Computer
MARIE: An Introduction to a Simple Computer
ICT Programming Lesson 1:
WJEC GCSE Computer Science
Presentation transcript:

What Do I Represent?

Translators – Module Knowledge Areas Revisiting object code When we disassemble code we can view the opcodes used This is just a stage – the assembled code is typically translated into a series of hex codes What can you say about the object code below (these are from 3 different scripts)?

Translators – Module Knowledge Areas Locate a Python script and copy it to a clean directory In the same directory create a new Python file The only line you need is import filename eg import tempConvert (do not put in the extension) Give the file a sensible name and run it In your directory you will now see a folder called “_pycache_” Open this. Inside you will see a file with the extension “.pyc” Open one of the files with Sublime Text Take a screengrab of this and use it to discuss the link between source code and object code. Ensure you explain what is being shown.

Translators

Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and optimisation Library routines

Translators – Module Knowledge Areas Types of translators and their use Three types of translator Compiler – source code to object code. Translates all the code before running Interpreter – source code to object code BUT translates one line at a time and then executes the line Assembler – assembly code to machine code

Translators – Module Learning Objectives describe the need for, and use of, translators to convert source code to object code understand the relationship between assembly language and machine code describe the use of an assembler in producing machine code describe the difference between interpretation and compilation describe the purpose of intermediate code in a virtual machine describe what happens during lexical analysis describe what happens during syntax analysis, explaining how errors are handled explain the code generation phase and understand the need for optimisation describe the use of library routines

Translators - Assembly Understand the relationship between assembly language and machine code A particular architecture (CPU) has no way to directly read source code Each architecture has its own machine language This prevents a straight source code to machine code translation – we need to assemble the code EG running my Python code on a 64 bit Windows machine is not the same as running the code on a 32 bit Linux machine

Translators - Assembly We have previously seen that one line of source code can generate many lines of object code: Line 4 of the source code creates 2 lines of object code Line 6 of the source code creates 8 lines of object code This is referred to as one to many relationship (one source code line can give rise to many object code lines) The whole program generates 20 lines of assembly code TASK – Explain what is meant by the term ‘Assembly Language’. Ensure you make a link between assembly and source

Translators - Assembly Assembly code has a one-to-one relationship with machine code. In the diagram to the left there is a representation of how the language becomes less ‘friendly’ as the translation process is undertaken TASK – Describe the three stages in the diagram above. In your description include the architecture based reasons and human readability reasons for working in source and assembly code

Translators – Machine Code We already know that machine code is architecture specific eg 16, 32, 64 bit If an architecture is 32 bit this means that it has a word length of 32 bits This means that the address bus is 32 bits in size and that the size of each instruction is 32 bits Complex instructions – those exceeding the word length – are split into 2 or more instructions Each instruction has two parts – an opcode and data Opcode – the instruction eg ADD to add a value to the ACC (accumulator) Data – the information being manipulated eg 4 to have the instruction ADD applied to it

Translators – Assembly to Machine We already know that assembly code has a particular structure that uses mnemonics (words that look like English) to provide simple instructions EG ADD 4 to ACC is an instruction to add a value to the accumulator (notice now that we are in the territory of registers) OpcodeData MOV Value 0 to ACC The value to move into the ACC ADD 4 to ACC ADD 5 to ACC MUL 2 to ACC Task – what is the above doing? In pairs agree and be prepared to explain to the group

Translators – Machine Code KISS: Keep It Simple Son – How 2 bytes/16 bits can be characterised Bits 1-6Bits 7-16 OpcodeData OpcodeAssembly MnemonicDescription MOVWill move a value to a register ADDWill add a value and store it in the ACC SUBWill subtract a value and store it in the ACC MULWill multiply a value and store it in the ACC

Translators – Machine Code In this example of disassembled code the offset (second column) has a particular pattern – what is it? The second column refers to the instruction for the mnemonic opcode in column 3. Each instruction is exactly 3 bytes in size and therefore 3 bytes apart Task – Disassembling assembly (go to Moodle)