Chapter 17 Programming Tools - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 17 Programming Tools

Description:

Chapter 17. Programming Tools. The Architecture of Computer ... Mnemonic names op codes. Labels memory addresses. Comments. Symbol table. Operations table ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 31
Provided by: anv2
Category:

less

Transcript and Presenter's Notes

Title: Chapter 17 Programming Tools


1
Chapter 17Programming Tools
  • The Architecture of Computer Hardware and Systems
    Software An Information Technology Approach
  • 3rd Edition, Irv Englander
  • John Wiley and Sons ?2003

2
Programming Tools Overview
  • Editors
  • Assemblers
  • Debuggers
  • Compilers
  • Linkers
  • Loaders
  • Interpreters

Integrated Development Environments (IDEs)
combine several of the above programming tools
3
The Program Translation Process
  • Terms,terms, andmore terms!

Source
Object
Translator
Linker
Loader
Executable
4
Visual Basic IDE
5
Program Text Editors
  • Word processors format the appearance of the text
  • Text editors
  • Format the spacing between words for legibility
  • Ideal for structured languages
  • Text is the same font size
  • Examples
  • DOS Edit
  • Windows Notepad, Wordpad
  • Unix / Linux ed, vi, emacs
  • IDEs
  • MS Visual C, Symantec Visual Cafe

6
Programming Language Categories
  • Machine Language
  • Binary coded instructions
  • Assembly Language
  • Symbolic coded instructions
  • Procedural Languages
  • procedural statements or arithmetic notation
  • Four-generation Languages
  • Natural language and nonprocedural statements
  • Object-oriented Languages
  • Combination of objects and procedures

7
Assembly Language
  • When to use
  • When speed or size of program is critical
  • Hybrid approach
  • Hardware Drivers
  • Can use specialized instructions
  • Disadvantages
  • Inherently machine specific
  • Architectures may become obsolete
  • Lack of programming structure

8
Assemblers
  • Binary code machine code
  • Hex code
  • Assembly Language
  • Mnemonic names ? op codes
  • Labels ? memory addresses
  • Comments
  • Symbol table
  • Operations table
  • Memory Relocation
  • Cross Assembler

9
What Does This Program Do?
10
LMC Program in Java
  • Use instructions in a more understandable
    language
  • static int max (int x)
  • for (i1 ilt3 i)
  • xi input.getint()
  • max_int x1
  • for (i2 ilt3 i)
  • if (xI gt max_int)
  • max_int xI
  • System.output.println(max_int)

11
Procedural Languages
  • COBOL
  • Wordy but easier to maintain
  • FORTRAN
  • Scientists and engineers
  • BASIC
  • Pascal
  • Highly structured teaching language
  • C
  • high-level commands and low-level access to
    hardware

12
Object-Oriented Languages
  • SmallTalk
  • C
  • Java
  • Based on C
  • Platform independent

13
Compilers
  • Translates high-level language into low-level
    instructions
  • High-level language Source code
  • Machine-level Object code
  • Changes, including bug fixes, require recompiling

14
Language Components
  • Lexicon
  • All legal words in the language
  • Meaning and type
  • Syntax
  • grammar rules
  • Semantics
  • meaning of command

15
Computer Language Descriptions
  • Narrative
  • Syntax (Railroad) Diagrams
  • BNF
  • Backus-Naur Form
  • Context-Free Grammar

16
Railroad Diagram Examples
17
Typical BNF Rules for Java
18
Parsed English Sentence
19
The Compilation Process
Updates internal tables
Checks for errors
Generates CPU instructions or library calls
20
Process of Parsing
  • Lexical analysis
  • Also known as scanning
  • Divides the string of input characters into
    single elements, tokens, based on strict computer
    punctuation
  • Syntactic analysis
  • Checks for errors in grammar rules
  • Semantic parsing
  • Determines the meaning of the string

21
Source Code Instructions
  • Data declarations
  • Data type such as floating point, integer
  • Data operations
  • Instructions that update or compute data value
    (lots of moving around!)
  • Control Structures
  • Branches, Goto (yetch!), If-then-else, loops such
    as While-do and Repeat-until
  • Function, procedure, or subroutine calls
  • Receives control via a call instruction, receives
    and possibly modifies parameters, and returns
    control to the instruction after the call

22
Recursive Descent Parsing
23
Optimization
  • Compiler analyzes code in order to
  • Reduce amount of code
  • Eliminate repeated operations
  • Reorganize parts of of the program to execute
    faster and more efficiently
  • Use computer resources more effectively
  • Example
  • Move a calculation repeated within the body of a
    loop that does not use any value modified by the
    loop
  • Different compilers can produce different results!

24
Linking
Object file
Object file or object module
Executable file
Linker
C library
25
Linkers
  • Searches program libraries to find library
    routines used by the program
  • Library collection of pre-written functions and
    subroutines made available to perform commonly
    required activities
  • Determines the memory locations that code from
    each module will occupy and relocates
    instructions by adjusting absolute references
  • Resolves references among files

26
Why Link?
  • Construct single executable program from multiple
    object code files compiled at different times
  • Program can be subdivided into components and
    parceled out to different developers
  • Example
  • Main program and multiple subroutines written and
    compiled by different programmers at different
    times

27
Loader
  • Loads binary files that have been linked into
    main memory
  • Program is ready for execution

28
Interpreters
  • Translates source code instructions into machine
    language and executes it one statement at a time
  • Disadvantages
  • Longer to execute, particularly bad for loops
  • Uses more memory
  • Advantage
  • Faster testing and code modification
  • Examples of interpreted languages
  • Java, BASIC, LISP

29
Interpreter vs. Compiler
Resources during execution Interpreter Compiler
Contents in memory
Interpreter/compiler Yes No
Source code Partial No
Executable code Yes Yes
CPU cycles
Translation operations Yes No
Library linking Yes No
Application program Yes Yes
30
Debuggers
  • Assembly language debuggers
  • Source code debuggers
  • Step through programs
  • Check variable values
Write a Comment
User Comments (0)
About PowerShow.com