Chapter 1.4 Programming Languages and Programming.

Slides:



Advertisements
Similar presentations
Chapter 10 Linking and Loading. Separate assembly creates “.mob” files.
Advertisements

Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
The Assembly Language Level
Linking & Loading CS-502 Operating Systems
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Systems Software.
System Programming Mr. M. V. Nikum (B.E.I.T). Introduction What is System? System is the collection of various components Ex:- College is a system What.
Programming Types of Testing.
1 Machine-Independent Features Automatic Library Search automatically incorporate routines from a subprogram library Loading Options.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
Loader- Machine Independent Loader Features
COE Computer Organization & Assembly Language Introduction HLL vs. Assembly Programming Languages.
The Analytical Engine Module 6 Program Translation.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Program Flow Charting How to tackle the beginning stage a program design.
The Assembly Language Level
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Assembly Language Level.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
Introduction to Programming End Show. Resource Team R.P Ranjan-Lecturer, SPICTEC, Galle. W.M.A.S. Wijesekara-Centre manager,CRC Hali-Ela H.P.U.S Indra.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter 2.3 Modula 2 An Introduction. Summary First example Terminal symbols Comments Data –Constants –Variables Actions –Assignment statement –Control.
©J.Tiberghien - ULB-VUB Version 2007 Première partie, chap. 4, page 1 Chapitre 1.4 Langages et outils de programmation.
©J.Tiberghien - ULB-VUB Version Troisième Partie Chapitre 1 Les supports à la programmation.
Linking and Loading Linker collects procedures and links them together object modules into one executable program. Why isn't everything written as just.
Introduction to C++ Programming Language
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
PROGRAMMING LANGUAGES
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
L ECTURE -9 Topics : Compiler Interpreter Loader Linker. Types of Software..
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Computer Programming Languages HOW COMPUTERS WORK èCIRCUITS èBINARY DIGIT èBIT (0 OR 1) èBYTE - 8 BITS èASCII.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including.
LINKERS Execution of a program written in a language L involves the following steps: 1.Translation of the program: Performed by the translator for language.
The Functions and Purposes of Translators Translators, Interpreters and Compilers - High Level Languages.
Compilers and Interpreters
The Functions and Purposes of Translators Translators, Interpreters and Compilers - High Level Languages.
Hello world !!! ASCII representation of hello.c.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 The user’s view  A user is a person employing the computer to do useful work  Examples of useful work include spreadsheets word processing developing.
1 CE 454 Computer Architecture Lecture 11 Ahmed Ezzat The Assembly Language Level, Ch-(7.1 – 7.4)
Computer Language
Why don’t programmers have to program in machine code?
Computer Science 210 Computer Organization
Language Translation Compilation vs. interpretation.
Programming Language Hierarchy, Phases of a Java Program
Linking & Loading.
CS-3013 Operating Systems C-term 2008
Assembler Design Options
Computer Science 210 Computer Organization
The Assembly Language Level
Chapter 7 LC-2 Assembly Language.
Computer Organization and Design Assembly & Compilation
CMP 131 Introduction to Computer Programming
The Assembly Language Level
Linking & Loading CS-502 Operating Systems
Processor Fundamentals
Chapter 6 Programming the basic computer
Linking & Loading CS-502 Operating Systems
1.3.7 High- and low-level languages and their translators
Lecture 7 Separate compilation
Presentation transcript:

Chapter 1.4 Programming Languages and Programming

Machine Language Assembler P1:1001COPY#0ND P2:1002COPY#0SC P3:401103EQ?KFL#0P3 P4:242102MULSC#10SC P5:212122ADDSCKDASC P6:10011COPY#0KFL P7:20111ADDND#1ND P8:42133NE?ND#3P3 P9: NE?SC#321P1 P10:10113COPY#1DDA P11:471JMPP1 Machine Language vs. Assembler

ND:DAT2Number of digits,2 bytes SC:DAT2Secret code,2 bytes KFL:EQU10Keyboard Flag KDA:EQU11Keyboard Data DDA: EQU13Door Data BGN:COPY#0NDInit. number of digits COPY#0SCInit. secret code TFL:EQ?KFL#0TFLTest for key stroke MULSC#10SCShift SC one digit left ADDSCKDASCAdd new digit to SC COPY#0KFLReset keyflag ADDND#1NDIncrease entered digits NE?ND#3TFLMore digits needed ? NE?SC#321BGNCorrect secret code ? COPY#1DDAOpen the door JMPBGNRestart everything END Assembler Example

Source Code (LLL) ASSEMBLER Object Code HARDWARE The ASSEMBLER

Assembling and Executing 1. Loading the Assembler Assembler (in machine language) ABL

Assembling and Executing 2. Assembling the program Assembler Source Code Object Code

Assembling and Executing 3. Loading the user’s program ABL User’s Program (in machine language)

Assembling and Executing 4. Executing the user’s program User’s Program User’s Data User’s results

ND:DAT2Number of digits,2 bytes SC:DAT2Secret code,2 bytes KFL:EQU10Keyboard Flag KDA:EQU11Keyboard Data DDA: EQU13Door Data BGN:COPY#0NDInit. number of digits COPY#0SCInit. secret code TFL:EQ?KFL#0TFLTest for key stroke MULSC#10SCShift SC one digit left ADDSCKDASCAdd new digit to SC COPY#0KFLReset keyflag ADDND#1NDIncrease entered digits NE?ND#3TFLMore digits needed ? NE?SC#321BGNCorrect secret code ? COPY#1DDAOpen the door JMPBGNRestart everything END Assembler Example

VAR ND,SC : CARDINAL; KFL[10] : (idle,ready); KDA[11] : [0..9]; DDA[13] : (closed,open); BEGIN LOOP SC := 0; FOR ND := 1 TO 3 DO REPEAT UNTIL KFL = ready; SC := SC * 10 + KDA; KFL := idle; END (* FOR *); IF SC = 321 THEN DDA := open END (* IF *) END (* LOOP *) END High-level Language Example

High- vs. Low-Level Languages Final := (Written + Oral) DIV 2 STO ADD SHR STO Written A A Oral A A 1 A Final

Programming Languages Low Level Languages (Assembler) –One statement corresponds to one instruction –Machine specific –Error prone, low programmers productivity High Level Languages –One statement corresponds to many instructions –Machine independent –User friendly, high programmers productivity.

HARDWARE INTERPRETER Source Code (HLL) COMPILER Object Code

Compilers vs. Interpreters Compilers –Translate the entire program at once –Program execution very fast –Poor run-time error messages Interpreters –Translate and execute statement after statement –Very slow execution –Good run-time error messages

Compiling and Executing 1. Loading the Compiler Compiler (in machine language) ABL

Compiling and Executing 2. Compiling the program Compiler Source Code Object Code

Compiling and Executing 3. Loading the user’s program ABL User’s Program (in machine language)

Compiling and Executing 4. Executing the user’s program User’s Program User’s Data User’s results

Interpretation 1. Loading the Interpreter Interpreter (in machine language) ABL

Interpretation 2. Interpreting the user’s program Interpreter User’s results Source Code + User’s Data

HARDWARE INTERPRETER Source Code (HLL) COMPILER Object Code ASSEMBLER Assembler Source

HARDWARE 1 INTERPRETER 1 Source Code (HLL) COMPILER Common Assembler Source HARDWARE 2 INTERPRETER 2

Source BSource CSource DSource A Reloc. DReloc. AReloc. BReloc. C Compiler XCompiler YAssembler LINKER Object Code A+B+C+D Role of a Linker

Relocatable Code Relocatable object code = three tables: –CODE Program to be loaded from address 0 List of all location dependant addresses –EXTERNALS Symbolic names to be imported Addresses where these externals are referenced –ENTRY POINTS Symbolic names that can be referenced elsewhere Address corresponding to the symbolic name

HARDWARE INTERPRETER Source Code (HLL) COMPILER Object Code LINKER Reloc.Code

Dynamic Linking Fact : –Many procedures are not activated at each program execution Solution : –Link at run-time ! Initial procedure calls replaced by call to linker Procedure name passed as parameter to linker –Example :.dll files under MS/Windows

Imperative vs. Non-imperative Imperative –Program states how things should be done –Traditional programming style –Efficient execution, often compiled. Non imperative (Declarative or Functional) –Program states what should be done –Innovative programming style for specific fields –Often interpreted.

Imperative vs. Non-imperative READ (Oral); READ (Written); Final := (Oral+Written)/2; WRITE (Final) Declarations: Oral can be read Written can be read Final = (Oral+Written)/2 Commands: Write(Final)

Spreadsheet example