Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An...
-
Upload
ada-golden -
Category
Documents
-
view
235 -
download
5
Transcript of Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An...
![Page 1: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/1.jpg)
Chapter 17Programming Tools
The Architecture of Computer Hardware and Systems Software:
An Information Technology Approach
3rd Edition, Irv Englander
John Wiley and Sons 2003
![Page 2: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/2.jpg)
Chapter 17 Programming Tools 17-2
Programming Tools OverviewProgramming Tools Overview
EditorsEditors AssemblersAssemblers DebuggersDebuggers
CompilersCompilers LinkersLinkers LoadersLoaders InterpretersInterpreters
Integrated Development Environments (IDEs) Integrated Development Environments (IDEs) combine several of the above programming toolscombine several of the above programming tools
![Page 3: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/3.jpg)
Chapter 17 Programming Tools 17-3
The Program Translation Process
Terms,terms, andmore terms!
Source
Object
Executable
Translator
Linker
Loader
![Page 4: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/4.jpg)
Chapter 17 Programming Tools 17-4
Visual Basic IDE
![Page 5: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/5.jpg)
Chapter 17 Programming Tools 17-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
![Page 6: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/6.jpg)
Chapter 17 Programming Tools 17-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
![Page 7: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/7.jpg)
Chapter 17 Programming Tools 17-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
![Page 8: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/8.jpg)
Chapter 17 Programming Tools 17-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
![Page 9: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/9.jpg)
Chapter 17 Programming Tools 17-9
What Does This Program Do?
00 IN 901 ;input three numbers and save01 STO 99 39902 IN 90103 STO 98 39804 IN 90105 STO 97 397 ;subtract number in 98 from that in 9706 SUB 98 298 ;number in 97 larger07 BRP 10 811 ;number in 98 larger, restore 9808 LDA 98 59809 BR 11 61110 LDA 97 597 ;restore 9711 STO 96 396 ;store larger of (97, 98) in 9612 SUB 99 299 ;subtract number in 99 from larger13 BRP 16 816 ;number in 96 larger14 LDA 96 599 ;number in 99 larger, restore 9915 BR 17 61716 LDA 96 596 ;restore 9617 OUT 90218 COB 000
![Page 10: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/10.jpg)
Chapter 17 Programming Tools 17-10
LMC Program in Java Use instructions in a more understandable
language
static int max (int x[]){
for (i=1; i<=3; i++)x[i] = input.getint();
max_int = x[1];for (i=2; i<=3; i++)
if (x[I] > max_int)max_int = x[I];
System.output.println(max_int);}
![Page 11: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/11.jpg)
Chapter 17 Programming Tools 17-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
![Page 12: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/12.jpg)
Chapter 17 Programming Tools 17-12
Object-Oriented Languages
SmallTalk C++ Java
Based on C++ Platform independent
![Page 13: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/13.jpg)
Chapter 17 Programming Tools 17-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
![Page 14: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/14.jpg)
Chapter 17 Programming Tools 17-14
Language Components
Lexicon All legal words in the language Meaning and type
Syntax grammar rules
Semantics meaning of command
![Page 15: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/15.jpg)
Chapter 17 Programming Tools 17-15
Computer Language Descriptions
Narrative Syntax (Railroad) Diagrams BNF
Backus-Naur Form Context-Free Grammar
![Page 16: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/16.jpg)
Chapter 17 Programming Tools 17-16
Railroad Diagram Examples
![Page 17: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/17.jpg)
Chapter 17 Programming Tools 17-17
Typical BNF Rules for Java
![Page 18: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/18.jpg)
Chapter 17 Programming Tools 17-18
Parsed English Sentence
![Page 19: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/19.jpg)
Chapter 17 Programming Tools 17-19
The Compilation Process
Checks for errors
Generates CPU instructions or library calls
Updates internal tables
![Page 20: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/20.jpg)
Chapter 17 Programming Tools 17-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
![Page 21: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/21.jpg)
Chapter 17 Programming Tools 17-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
![Page 22: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/22.jpg)
Chapter 17 Programming Tools 17-22
Recursive Descent Parsing
![Page 23: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/23.jpg)
Chapter 17 Programming Tools 17-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!
![Page 24: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/24.jpg)
Chapter 17 Programming Tools 17-24
Object file or object
module
Object file
C library
Executable file
Linker
Linking
![Page 25: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/25.jpg)
Chapter 17 Programming Tools 17-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
![Page 26: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/26.jpg)
Chapter 17 Programming Tools 17-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
![Page 27: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/27.jpg)
Chapter 17 Programming Tools 17-27
Loader
Loads binary files that have been linked into main memory
Program is ready for execution
![Page 28: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/28.jpg)
Chapter 17 Programming Tools 17-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
![Page 29: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/29.jpg)
Chapter 17 Programming Tools 17-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
![Page 30: Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.](https://reader035.fdocuments.net/reader035/viewer/2022062304/56649e045503460f94aefcde/html5/thumbnails/30.jpg)
Chapter 17 Programming Tools 17-30
Debuggers
Assembly language debuggers Source code debuggers Step through programs Check variable values