You are on page 1of 17

10-6

Software Language Levels


Machine Language (Binary)
Assembly Language
Assembler converts Assembly into machine

High Level Languages (C, Perl, Shell)


Compiled : C
Interpreted : Perl, Shell

Compilation
Convert Source to Object
SUM = A + B
Compiles to Machine language of:
LDRR1,A
LDRR2,B
ADDR1,R1,R2
STRR1,C

Some Terms
Source
The language program was written in

Object
The machine language equivalent of the
program after compilation

Compiler
A software program that translates the source
code into object code
Assembler is a special case of compiler where
the source was written in Assembly language

Programming Steps
for Compilation

Create/Edit source
Compile source
Link object modules together
Test executable
If errors, Start over
Stop

Example: Good Morning


Use text editor to create source file print.c:
#include<stdio.h>
intmain(){
printf(GoodMorning\n);
return0;
}

Compilation process:
Invoke compiler on source program to
generate machine language equivalent
Compiler translates source to object
Saves object output as disk file[s]
Large Systems may have many source
programs
Each has to be compiled

Link object modules together


Combine them together to form executable
Take multiple object modules
LINKER then takes object module(s) and
creates executables for you
Linker resolves references to other object
modules
Handles calls to external libraries
Creates an executable

Interpretation
No linking
No object code generated
Source statements executed line by line

Steps in interpretation
Read a source line
Parse line
Do what the line says
Allocate space for variables
Execute arithmetic opts etc..
Go to back to step 1

Similar to instruction cycle

Example: Good Morning


Perl script: print.pl
printGoodMorning\n;

Shell script print.sh


echoGoodMorning\n;

Compilation Advantages
Faster Execution
Single file to execute
Compiler can do better diagnosis of syntax
and semantic errors, since it has more info
than an interpreter (Interpreter only sees
one line at a time)
Compiler can optimize code

Compilation Disadvantages
Harder to debug
Takes longer to change source code,
recompile and relink

Interpreter Advantages
Easier to debug
Faster development time

Interpreter disadvantages

Slower execution times


No optimization
Need all of source code available
Source code larger than executable for large
systems

Some Interpretive Systems


Languages
BASIC, Perl, Lisp

OS Interfaces
C Shell, Bourne Shell
WINEXEC

Conclusion
Many different ways of developing systems
There is always a tradeoff between system
development time, testing, debugging and
performance, support etc.

You might also like