1.91k likes | 2.74k Views
UNIT-1 Introduction to System Programming. Introduction: Components of System Software, Language Processing Activities, Fundamentals of Language Processing
E N D
UNIT-1Introduction to System Programming Introduction: Components of System Software, Language Processing Activities, Fundamentals of Language Processing Assemblers: Elements of Assembly Language Programming, A simple Assembly Scheme, Pass structure of Assemblers, Design of Two Pass Assembler, Single pass assembler Macro Processor: Macro Definition and call, Macro Expansion, Nested Macro Calls and definition,Advanced Macro Facilities, Design of Macro Processor
Unit-1 • Introduction: • Components of System Software, • Language Processing Activities, • Fundamentals of Language Processing
Unit-1 Basic • Software • Types of software • Application software-Word, Excel etc. • System Software- Compiler, Assembler,O.S., Linker etc. Applicationsoftware Operatingandsystemssoftware Users Hardware Sytem Programming
Unit-1 Application Software • Develop using Programming Lang. and Tools • Application software interact with systems software; • systems software then directs computer hardware to perform the necessary tasks Sytem Programming
Unit-1 System Software • Needed for program development. • Controls operations of computer hardware • Definition: System Software Consist of a variety of program that support the operation of a computer. Sytem Programming
Language processing Model Source Program C,C++,java etc Compiler Target Assembly Program Assembler Relocatable M/c Code Loader/Linkeditor Lib+ relocatableobj file Executable M/c Code
Unit-1 Components of System Software, Example: • Assembler • Compiler • Macro processor • Loader • Linker • Interpreter • Operating System • Debugger • Text editor Sytem Programming
Programming Languages: Terminology • Language translator • Systems software that converts a programmer’s source code into its equivalent in machine language • Source code • High-level program code written by the programmer • Object code • Another name for machine language code
Unit-1 Assembler • A Translator • Assembler make two passes over the assembly file • First Pass: reads each line and records labels in a symbol table. • Second Pass : use info in symbol table to produce actual machine code for each line. Assembly Language Program Assembler Machine Language format or object file Fig.: Assembler
Unit-1 Assembler… • Assembly lang. a symbolic representation of machine language. • uses a mnemonic to represent each low-level machine instruction or operation. • Assemblers with different syntax for a particular CPU or instruction set architecture. • Example:- An instruction to add memory data to a register x86-family processor: add eax,[ebx], whereas this would be written addl (%ebx),%eax in the AT&T syntax used by the GNU Assembler.
Unit-1 Compiler • Once the target program is generated, the user can execute the program. Error Messages Program in Source Language Target code(Program in machine code) Compiler Fig.: A Compiler
Unit-1 Compiler… • Early compilers were written in assembly language. • A compiler verifies code syntax, • generates efficient object code, • performs run-time organization, • and formats the output according to assembler • and linker conventions
Unit-1 Macro Processor • It allows the programmer to write shorthand version of a program . • Macro allows a sequence of source language code to be defined once and then referred to by name each time it is to be referred. • Each time this name Occurs in a program, the sequence of codes is substituted at that point.
Unit-1 Copy code -- Example Expanded source . . . STA DATA1 STB DATA2 STX DATA3 . STA DATA1 STB DATA2 STX DATA3 . Source STRG MACRO STA DATA1 STB DATA2 STX DATA3 MEND . STRG . STRG . . { {
Unit-1 Loader and Linker • A program which accepts object program and prepares them for execution. • 4 main functions: • Allocationof space in main memory for the programs. • Linking of object modules with each other. • Adjust all address dependent locations. • Physically loading the machine instructions and data into the main memory.
Unit-1 Interpreter • A Interpreter reads the source code oneinstruction or line at a this lineintomachine code or some intermediate form and executes it. Program statement Interpreter Machine language statement Statementexecution Fig.: Interpreter
Unit-1 • Operating System- Interface between users and the hardware of a computer system. • Debugger- helps to detect error in the program. • Text editor- used to create and modify the program.
Unit-1 Language Processing Activities • It Involvestranslation of a program written in a high level language into machine code • It can be divided into two groups: • Program generation activities • Program execution activities
Unit-1 Language Processing Activities..
Unit-1 1.Program generation activities • The program generator is a software which accepts the specification of program to be generated Andgenerates a program in target programming lang. Error Messages Program specification Program in target PL Program generator Sytem Programming Fig.: Program generator
Unit-1 1.Program generation activities… Fig.: Specification and Execution gap • Execution gap is bridged by the compiler or interpreter. • The program generator bridges the gap between application domain & Programming lang. (PL)domain Sytem Programming
Unit-1 1.Program generation activities… • Example- A Screen handling Program. • Employee name: • Address: • Married: • Age Sex Sytem Programming
Unit-1 2.Program Execution activities • 2 Models for Program Execution: 1.Translation 2.Interpretion • A program must be translated before it can be executed. • The translated program may be saved in a file.The saved program may be executed repeatedly.
Unit-1 1.Program Translation Fig.: Program Translation Model Sytem Programming
Unit-1 Program Interpretation Sytem Programming
Unit-1 Fundamental of Language Processing • Language Processing=Analysis of SP + Synthesis of TP Fig.: Phases of language of language processing Sp=source prog. TP=target program System Programming
Unit-1 Analysis Phase • Three components: 1. Lexical rules -the formation of valid lexical units in the source language. Example:percent_profit = (profit * 100) / cost_price; identifies =, * and / operators, 100 as constant, and the remaining strings as identifiers. 2. Syntax rules the formation of valid statements in the source language. Example : percent_profit as the left hand side and (profit * 100) / cost_price as the expression on the right hand side. System Programming
Unit-1 Analysis Phase… 3. Semantic rules -associate meaning with valid statements of the language. example: percent_profit = (profit * 100) / cost_price; Semantic analysis : assignment of profit X 100 / cost_price to percent_profit Sytem Programming
Unit-1 Synthesis Phase • It performs two main activities: • Creation of data structures in the target program (memory allocation) • Generation of target code (code generation) Example MOVER AREG, PROFIT MULT AREG, 100 DIV AREG, COST_PRICE MOVEM AREG, PERCENT_PROFIT … PERCENT_PROFIT DW 1 PROFIT DW 1 COST_PRICE DW 1 Sytem Programming
Unit-1 • Assemblers: • Elements of Assembly Language Programming, • A simple Assembly Scheme, • Pass structure of Assemblers, • Design of Two Pass Assembler, • Single pass assembler
Unit-1 Assembler • A Translator • Assembler make two passes over the assembly file • First Pass: reads each line and records labels in a symbol table. • Second Pass : use info in symbol table to produce actual machine code for each line. Assembly Language Program Assembler Machine Language format or object file Fig.: Assembler
Unit-1 Assembler… • The translated program contains 3 kinds of entities: • Relative entities- address of instructions and variables. • Absolute entities- operation code , numeric and string constant and fixed addresses. • The object program- addresses are relative symbols are defined externally Sytem Programming
Unit-1 Assembler… • Assembly lang. a symbolic representation of machine language. • uses a mnemonic to represent each low-level machine instruction or operation. • Assemblers with different syntax for a particular CPU or instruction set architecture. • Example:- An instruction to add memory data to a register x86-family processor: add eax,[ebx], whereas this would be written addl (%ebx),%eax in the AT&T syntax used by the GNU Assembler.
Unit-1 Assembler Elements of assembly language programs: • Basic features • Statement format • Operation code Sytem Programming
Unit-1 A.Basic features • Assembly lang. Provides 3 basic features: • 1. Mnemonic Operation Codes(Opcodes) • Ex: MOVER or MOVEM • 2. Symbolic Operand: • Ex: DS – Declare as storage • DC – Declare as Constant • 3. Data Declaration: • Ex: X DC ‘-10.5’ Sytem Programming
Unit-1 B.Statement Format Statement Format: [Label] <opcode> <operand1> [ <operand2>..] Label-Optional Opcode-it contain symbolic operation code Operand- Operand can also be a CPU register: AREG, BREG,CREG. Example- LOOP : MOVER AREG, ‘=5’
Unit-1 Machine Instruction Format Fig.: Machine Instruction format for assembly lang. • Sign is not part of the instruction • Reg.operand: AREG, BREG,CREG,DREG. • Memory operand: Refers memory word using symbolic name Memory operand(3) Sytem Programming Sign Reg.operand(1) Opcode(2)
Unit-1 Machine supports 11 Different Operations
Unit-1 Machine supports 11 Different Operations First operand is always a CPU register Second operand is always a memory operand
Unit-1 Assembly language statements 3 types of Statement in Assembly Language Imperative Declaration Assembler directives
Unit-1 1.Imperative Statement Executable statement Indicates an action to be taken. translates into a machine instruction. class IS Ex.: MOVER BREG, X STOP READ X PRINT Y BC NE,L1
Unit-1 2.Declaration statements Reserves memory for variables Initial value of a variable can also be specified. [label] DS <const specifying size of memory to be reserved> [label] DC <Initial value of variable> DS declare storage, DC declare constant Class-DL >
Unit-1 2.Declaration statements… Reserve memory area of 1 word for variable X X DS 1 Y DS 5
Unit-1 2.Declaration Statements… Reserve one word of memory for variable ONE Memory is initialized with ‘1’ ONE DC ‘1’
Unit-1 MOT for declaration statements
Unit-1 3.Assembler Directive • Instructs the assembler to perform certain actions during assembly of a program. • A directive is a direction for the assembler • A directive is also known as pseudo instruction • machine code is not generated for AD.
Unit-1 3.Assembler Directive… START <Constant> It indicates that the first word of the m/c code should be placed in the memory word with the address <CONSTANT>
Unit-1 3.Assembler Directive… END [<OPERAND SPECIFICATION>] Optional, indicates address of the instruction where the address of program should begin. By default, execution begins from the first instruction. It indicates the end of the source program. Class:AD
Advanced Assembler Directives These directive include: ORIGIN Symbol LTORG
ORIGIN Useful when m/c code is not stored in consecutive memory location. ORIGIN <address specification> Operand or constant or expression containing an operand and a constant. Sets LC to the address given by <address specification> LC processing in a relative rather than absolute manner