The Program Translation Process Terms, terms, and more terms!. Source Object Executable Translator Linker Loader... Translates high-level language into level instructions low- High-l
Trang 1Chapter 17
Programming Tools
The Architecture of Computer Hardware
and Systems Software:
An Information Technology Approach
3rd Edition, Irv Englander John Wiley and Sons 2003
Trang 2Programming Tools Overview
Integrated Development Environments (IDEs)
combine several of the above programming tools
Trang 3The Program Translation Process
Terms,
terms, and
more terms!
Source Object
Executable
Translator Linker
Loader
Trang 4Visual Basic IDE
Trang 5Program 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
Trang 7 Inherently machine specific
Architectures may become obsolete
Lack of programming structure
Trang 8 Binary code = machine code
Hex code
Assembly Language
Mnemonic names op codes
Labels memory addresses
Trang 9What Does This Program Do?
00 IN 901 ;input three numbers and save
01 STO 99 399
02 IN 901
03 STO 98 398
04 IN 901
05 STO 97 397 ;subtract number in 98 from that in 97
06 SUB 98 298 ;number in 97 larger
07 BRP 10 811 ;number in 98 larger, restore 98
08 LDA 98 598
09 BR 11 611
10 LDA 97 597 ;restore 97
11 STO 96 396 ;store larger of (97, 98) in 96
12 SUB 99 299 ;subtract number in 99 from larger
Trang 13 Translates high-level language into level instructions
low- High-level language: Source code
Machine-level: Object code
Changes, including bug fixes, require
recompiling
Trang 14Language Components
Lexicon
All legal words in the language
Meaning and type
Syntax
grammar rules
Semantics
meaning of command
Trang 15Computer Language Descriptions
Trang 16Railroad Diagram Examples
Trang 17Typical BNF Rules for Java
Trang 18Parsed English Sentence
Trang 19The Compilation Process
Trang 20Process of Parsing
Lexical analysis
Also known as scanning
Divides the string of input characters into single elements, tokens, based on strict computer punctuation
Trang 21Source Code Instructions
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
Trang 22Recursive Descent Parsing
Trang 23 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
Trang 24Object file or object
Linking
Trang 25 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
Trang 26Why 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
Trang 28 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
Trang 29Interpreter 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
Trang 30 Assembly language debuggers
Source code debuggers
Step through programs
Check variable values