Professional Documents
Culture Documents
We Discussed On
Machine Architecture Assemblers Loaders and Linkers Editors and Debugging Systems Macro Processor Compilers Lex and Yacc
Machine Architecture
Memory and Registers Data Formats Instruction Formats Addressing Modes Instruction Set Input and Output
RISC Machines
Reduced Instruction Set Computers Intended to simplify the design of processors. Greater reliability, faster execution and less expensive processors Standard and fixed instruction length Number of machine instructions, instruction formats, and addressing modes relatively small
Assemblers
Assemblers
Translating source code written in assembly language to object code. Assigning machine address to symbolic labels.
Assembler Design
Assembler Design can be done in:
Single pass Two pass
First pass:
Scans the code Validates the tokens Creates a symbol table
Second Pass:
Solves forward references Converts the code to the machine code
Machine independent features Literals Symbol defining statements Expressions Program blocks Control Sections and program linkings
Types of Assemblers
One-pass assembler Multi-pass assembler Two-pass assembler with overlay
Role of Loader
Source Program Translator Object Program Loader
Object program ready for execution
Translator Assembler/Compiler
Memory
Role of Loader
Source Program Assembler Object Program Loader
Object program ready for execution
Memory
Object Program
Linker
Object program ready for execution
2000
Memory
Absolute Loader Simple and efficient Disadvantage is programmer has to specify the starting address One program to run no problem not for several Difficult to use subroutine libraries efficiently
Linking Loaders
Object Program(s)
Library
Linking loader
Memory
The source program is first assembled or compiled, producing an object program. A linking loader performs all linking and loading operations, and loads the program into memory for execution
Linkage Editors
Library
Object Program(s)
Linkage editor
Memory
Implementation examples
Brief description of loaders and linkers for actual computers They are MS-DOS Linker SunOS Linkers - Pentium architecture - SPARC architecture
Macros
A macro instruction (Macro) is a notational convenience for the programmer Allows the programmer to write short hand programs (modular programming). The macro processor replaces each macro instruction with its equivalent block of instructions. The macro processor is not concerned with the meaning of the involved statements during expansion. The design of the macro processor is generally machine independent.
Pass 2:
Expand all macro invocation statements
-Machine-Independent Macro Processor Features -Concatenation of Macro Parameters -Generating Unique Labels -Macro-time Looping -Conditional Macro expansion -Keyword macro parameters -Recursive Macros -Line-by-Line Macros -Integrated Macros
Compilers
Introduction Basic Compiler Function Lexical Analysis, Syntactic Analysis Operator-Precedence Parsing Shift Reduce Parsing Recusive Descent Parsing
Source Program
Phases of Compilers
Table Management
Lexical analysis Syntax analysis Intermediate Code generation Code Optimization Code Generation Target Program Error Handling
Code Generation Machine - Dependent Code Optimization Machine Independent Compiler Features Machine - Independent Code Optimization
Machine Independent Compiler Features Storage Allocation Block Structured Languages Compiler Design Options Division Into Passes Interpreters P-Code Compilers Compiler-Compilers
YACC Yet Another Compiler-Compiler YACC Basic Specification How does the Parser Works? Ambiguity and Conflicts YACC Programs simple expression with +, - , /, and *. recognize an valid variable. Lex and Yacc