Sunteți pe pagina 1din 6

System Software Concepts Handout Notes

The following system software concepts are discussed: Compiler Interpreter Assembler Loader & Linker Programming Languages Properties Need to be precise Need to be concise Need to be expressive Need to be at a high-level (lot of abstractions) How to Instruct the Computer Write a program using a programming language(High-level Abstract Description) Microprocessors talk in assembly language(Low-level Implementation Details) System Software System programs which provide a more convenient environment for program development and execution Example Compilers Assemblers Loaders Linkers Operating syetem

Translators A program which converts a users program written in some language to another language. The language in which the users program is written is called the source language The language to which the source language is converted is called the target language Examples:

Figure 1: Translator

COMPILER

Why Study Compilers? Compilers enable programming at a high level language instead of machine instructions. system programs that translates an input program in a high level language into its machine language equivalent Checks for errors Optimizes the code Prepares the code for execution

Conceptual Structure of a Compiler Compiler phases

Figure 2: Compiler Structure 1. Lexical analysis (Scanner): Recognition of symbols, delimiters, and comments By regular expressions and nite automata Formation of tokens(Keywords,Identier, Constant, Operator, Symbol) 2. Syntactic analysis (Parser): Determination of hierarchical program structure(Parse Tree) By contextfree grammars and pushdown automata 3. Semantic analysis: Checking context dependencies, data types, By attribute grammars 4. Intermediate code Generation : Translation into (targetindependent) intermediate code Three Address code formation By tree translations 5. Code optimization: To improve runtime and/or memory behavior

Elimination of Common subexpression, Elimination of dead codes, 6. Code generation: Tailored to target system code Classication of Compiler Phases Analysis :lexical/syntactic/semantic analysis(determination of syntactic structure, error handling) Synthesis :Generation of (intermediate/machine) code + optimization Alternatively: Frontend : Machineindependent parts(analysis + intermediate code + machineindependent optimizations) Backend : Machinedependent parts(generation + optimization of machine code)

Interpreter

Figure 3: Interpreter Is a systems program that looks at and executes programs on a line-by-line basis rather than producing object code Whenever the programs have to be executed repeatedly, the source code has to be interpreted every time. In contrast the compiled programs create an object code and this object code will be executed. Entire source code needs to be present in memory during execution as a result of which the memory space required is more when compared to that of a compiled code. Used in test environments as overhead of compilation is not there

Assembler
System Program Translates programs in assembly language to target language( machine language) Assembly language: A convenient language using mnemonics (symbolic names and symbolic addresses) for coding machine instructions The assembly programmer has access to all the features and instructions available on the target machine and thus can execute every instruction in the instruction set of the target machine Assembly languages varied from machine to machine. Assembly language varied from machine to machine. A typical example of assembly language: add sub and or xor nor $t0,$s0,$s1 $t0,$s0,$s1 $t0,$s0,$s1 $t0,$s0,$s1 $t0,$s0,$s1 $t0,$s0,$s1 # # # # # # set set set set set set $t0 $t0 $t0 $t0 $t0 $t0 to to to to to to ($s0)+($s1) ($s0)-($s1) ($s0)($s1) ($s0)or($s1) ($s0)xor($s1) (($s0)nor($s1))

Assembler Types One pass assembler Two pass assembler

Loader
System program Loader loads the binary code in the memory ready for execution Transfer the control to 1st instruction Responsible for locating program in the main memory every time it is being executed. The loader has the following responsibilities:

Determining the memory needs of the program from its header Copying text and data from the executable program le into memory Modifying (shifting) addresses, where needed, during copying Placing program parameters onto the stack (as in a procedure call) Initializing all machine registers, including the stack pointer Jumping to a start-up routine that calls the programs main routine Types of Loader Assemble and Go Loader Absolute Loader Relocatable Loaders

Linker
System Program Linking is the process of combining various pieces of code and data together to form a single executable that can be loaded in memory. The linker has the following responsibilities: Ensuring correct interpretation (resolution) of labels in all modules Determining the placement of text and data segments in memory Evaluating all data addresses and instruction labels Forming an executable program with no unresolved references Linking can be done at compile time, and also at run time Static Linker Dynamic Linker

S-ar putea să vă placă și