Presentation is loading. Please wait.

Presentation is loading. Please wait.

Accomplishing Executables

Similar presentations


Presentation on theme: "Accomplishing Executables"— Presentation transcript:

1 Accomplishing Executables
Briefly how this is done Copyright © Curt Hill

2 Introduction An executable program is a series of bits that is perfectly understandable to a machine Most programs need to be coded in a textual or graphical fashion to be done by people This presentation considers how this transformation occurs Copyright © Curt Hill

3 Types of Transformers There are two basic classes of program that accomplish this transformation: Interpreters Compilers There are many combinations of these two We shall look at several examples Copyright © Curt Hill

4 Definitions Machine language is the only language a CPU may execute
Completely different for different types of CPUs An interpreter takes in a source language program It executes it as if it were machine language program A compiler translates the source language from one form to another Most often the result is machine language Translating from a new or rare language to a common one has been done Copyright © Curt Hill

5 Interpreters An interpreter takes a command and executes it directly
The early BASICs were of this form JavaScript does this as well The interpreter is part of the web browser This is an excellent debugging environment Not as fast, because the parsing of the source code takes time Copyright © Curt Hill

6 Simple Interpreter BASIC Interpreter BASIC Source Statements
Copyright © Curt Hill

7 Compilation Interpretation is like the butler
You tell them to do something he does it Compilation is like a translator Convert a program in one language to that of another Usually the result is machine language Copyright © Curt Hill

8 Several Steps Take the source language and convert into object code
Take several object codes and libraries and link together into an executable Load the executable and run Copyright © Curt Hill

9 Compilation Editor Compiler Linker Loader Source Library Object
Executable Copyright © Curt Hill

10 Compile Cycle The compiler translates the source into object
Object is machine language Not yet executable Linker takes one or more objects and libraries and creates the executable Loader executes Copyright © Curt Hill

11 project.cpp #include <iostream.h> … int main(void){
cout << “Enter a value”; int a, b; cin >> a >> b; } Copyright © Curt Hill

12 Source and Object Inside that code were several types of routines
The main function was a function that must be externally declared The cin and cout types are well known externals Brought in through an include Copyright © Curt Hill

13 Object file When the C++ compiler executes it compiles project.cpp and produces and object file .OBJ on windows and .o on UNIX This object file is mostly machine language It also contains a relocation dictionary and an external symbol dictionary These are structures we will not worry about Copyright © Curt Hill

14 Linker Takes the object files and creates an executable
Reads in the object from project.cpp places in a file Finds from a library all of the routines that it needs for this program and places them in the file The cin >> function and cout Copyright © Curt Hill

15 Loader Usually invisible to most of us Takes an executable:
Part of the OS Takes an executable: Relocates it, if needed Allocates memory for it Creates a process to start it Starts it Cleans up when complete Copyright © Curt Hill

16 Some More Thoughts The preprocessor is one additional step in the process Dev is an IDE Interactive Development Environment It manages all the pieces Includes an editor Executes the compiler, linker, etc. Keeps us from having to fuss with a lot of details Copyright © Curt Hill

17 Finally There have been many variations on the themes given here
Any interactive program can be considered an interpreter of sorts The need for speed has greatly reduced One of the reasons for scripting languages popularity as well as Java Copyright © Curt Hill


Download ppt "Accomplishing Executables"

Similar presentations


Ads by Google