




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Computer Program 1 Introduction Computer Program, set of instructions that directs a computer to perform somep rocessing function or combination of functions. For the instructions to be carried out, a computer must execute a program, that is, the computer reads the program, and then follow the steps
2、 encoded in the program in a precise order until completion. A program can be executed many different times, with each execution yielding a potentially different result depending upon the options and data that the user gives the computer. Programs fall into two major classes: application programs an
3、d operating systems. An application program is one that carries out some function directly for a user, such as word processing or game-playing. An operating system is a program that manages the computer and the various resources and devices connected to it, such as RAM,h ard drives, monitors, keyboa
4、rds, printers, and modems,s o that they mayb e used by other programs. Examples of operating systems are DOS, Windows 95, OS2, and UNIX. 2 Program Development Software designers create new programs by using special applications programs, often called utility programs or development programs. A progr
5、ammer uses another type of program called a text editor to write the new program in a special notation called a programming language. With the text editor, the programmer creates a text file, which is an ordered list of instructions, also called the program source file. The individual instructions t
6、hat make up the program source file are called source code. At this point, a special applications program translates the source code into machine language, or object code a format that the operating system will recognize as a proper program and be able to execute. Three types of applications program
7、s translate from source code to object code: compilers, interpreters, and assemblers. The three operate differently and on different types of programming languages, but they serve the same purpose of translating from a programming language into machine language. A compiler translates text files writ
8、ten in a high-level programming language-such as FORTRAN, C,o r Pascal from the source code to the object code all at once. This differs from the approach taken by interpreted languages such as BASIC, APL and LISP, in which a program is translated into object code statement by statement as each inst
9、ruction is executed. The advantage to interpreted languages is that they can begin executing the program immediately instead of having to wait for all of the source code to be compiled. Changes can also be made to the program fairly quicklywithout having to wait for it to be compiled again. The disa
10、dvantage of interpreted languages is that they are slow to execute, since the entire program must be translated one instruction at a time, each time the program is run. On the other hand, compiled languages are compiled only once and thus can be executed by the computer much more quickly than interp
11、reted languages. For this reason, compiled languages are more common and are almost always used in professional and scientific applications. Another type of translator is the assembler, which is used for programs or parts of programs written in assembly language. Assembly language is another program
12、ming language, but it is much more similar to machine language than other types of high-level languages. In assembly language, a single statement can usually be translated into a single instruction of machine language. Today, assembly language is rarely used to write an entire program, but is instea
13、d most often used when the programmer needs to directly control some aspect of the computer s function. Programs are often written as a set of smaller pieces, with each piece representing some aspect of the overall application program. After each piece has been compiled separately, a program called
14、a linker combines all of the translated pieces into a single executable program. Programs seldom work correctly the first time, so a program called a debugger is often used to help find problems called bugs. Debugging programs usually detect an event in the executing program and point the programmer
15、 back to the origin of the event in the program code. Recent programming systems, such as Java, use a combination of approaches to create and execute programs. A compiler takes a Java source program and translates it into an intermediate form. Such intermediate programs are then transferred over the
16、 Internet into computers where an interpreter program then executes the intermediate form as an application program. 3 Program Elements Most programs are built from just a few kinds of steps that are repeated many times in different contexts and in different combinations throughout the program. The
17、most common step performs some computation, and then proceeds to the next step in the program, in the order specified by the programmer. Programs often need to repeat a short series of steps many times, for instance in lookingthrough a list of game scores and finding the highest score. Such repetiti
18、ve sequences of code are called loops. One of the capabilities that makes computer so useful is their ability to make conditional decisions and perform different instructions based on the values of data being processed. If-then-else statements implement this function by testing some piece of data an
19、d then selecting one of two sequences of instructions on the basis of the result. One of the instructions in these alternatives may be a goto statement that directs the computer to select its next instruction from a different part of the program. For example, a program might compare two numbers and
20、branch to a different part of the program depending on the result of the comparison: If x is greater than y Then Goto instruction # 10 Else continue Program often use a specific sequence of steps more than once. Such a sequence of steps can be grouped together into a subroutine, which can then be ca
21、lled, or accessed, as needed in different parts of the main program. Each time a subroutine is called, the computer remembers where it was in the program when the call was made, so that it can return there upon completion of the subroutine, allowing a very general piece of code to be written once an
22、d used in multiple ways. Most programs use several varieties of subroutines. The most common of these are functions, procedures, library routines, system routines, and device drivers. Functions are short subroutines that compute some value, such as computations of angles, which the computer cannot c
23、ompute with a single basic instruction. Procedures perform amore complex function, such as sorting a set of names. Library routines are subroutines that are written for use by many different programs. System routines are similar to library routines but are actually found in the operating system. The
24、y provide somes ervice for the application programs, such as printing a line of text. Device drivers are system routines that are added to an operating system to allow the computer to communicate with a new device, such as a scanner, modem,o r printer. Device drivers often have features that can be
25、executed directly as applications programs. This allows the user to directly control the device, which is useful if, for instance, a color printer needs to be realigned to attain the best printing quality after changing an ink cartridge. 4 Program Function Modern computers usually store programs on
26、some form of magnetic storage media that can be accessed randomly by the computer, such as the hard drive disk permanently located in the computer, or a portable floppy disk. Additional information on such disks, called directories, indicate the names of the various program begins on the disk media.
27、 When a user directs the computer to execute a particular application program, the operating system looks through these directories, locates the program, and reads a copy into RAM. The operating system then directs the CPU to start executing the instructions at the beginning of the program. Instruct
28、ions at the beginning of the program prepare the computer to process information by locating free memory locations in RAM to hold working data, retrieving copies of the standard options and defaults the user has indicated from a disk, and drawing initial displays on the monitor. The application prog
29、ram requests copy of any information the user enters by making a call to a system routine. The operating system converts any data so entered into a standard internal form. The application then uses this information to decide what to do next-forexample, perform some desired processing function such a
30、s reformatting a page of text, or obtain some additional information from another file on a disk. In either case, calls to other system routines are used to actually carry out the display of the results or the accessing of the file from the disk. Whent he application reaches completion or is prompte
31、d to quit, it makes further system calls to make sure that all data that needs to be saved has been written back to disk. It then makes a final system call to the operating system indicating that it is finished. The operating system then frees up the RAMa nd any device that the application was using
32、 and awaits a commandfr om the user to start another program. 5 History People have been storing sequences of instructions in the form of a program for several centuries. Music boxes of the 18 th century and player pianos of the late 19th and early 20th centuries played musical programs stored as se
33、ries if metal pins, or holes in paper, with each line representing when a note was to be played, and the pin or hole indicating what note was to be played at that time. More elaborate control of physical devices became common in the early 1800s with French inventor Joseph Marie Jacquard s invention
34、of the punch-card controlled weaving loom. In the process of weaving a particular pattern, various parts of the loom had to be mechanically positioned. To automate this process, Jacquard used a single paper card to represent each positioning of the loom, with hole in the card to indicate which loom
35、actions should be done. An entire tapestry could be encoded onto a deck of such cards, with the same deck yielding the same tapestry design each time it was used. Programs of over 24,000 card were developed and used. The world s first programmable machine was This machine, called the Analytical Engi
36、ne, used punch cards similar to those designed-althoughnever fullybuilt-bythe English mathematician and inventor, Charles Babbage. used in the Jacquard loom to select the specific arithmetic operation to apply at each step. Inserting a different set of cards changed the computations the machine perf
37、ormed. This machine had counterparts for almost everything found in modern computers, although it was mechanical rather than electrical. Construction of the Analytical Engine was never completed because the technology required to build it did not exist at the time. The first card deck programs for t
38、he Analytical Engine were developed by British mathematician Countess Augusta Ada Lovelace, daughter of the poet Lord Byron. For this reason she is recognized as the world s first programmer. The modern concept of an internally stored computer program was first proposed by Hungarian-American mathema
39、tician John von Neumannin 1945. Von Neumann s idea was to use the computer s memory to store the program as well as the data. In this way, programs can be viewed as data and can be processed like data by other programs. This idea greatly simplifies the role of program storage and execution in comput
40、ers. 6 The Future The field of computer science has grown rapidly since the 1950s due to the increase in their use. Computer programs have undergone manyc hanges during this time in response to user need and advances in technology. Newer ideas in computing such as parallel computing, distributed com
41、puting, and artificial intelligence, have radically altered the traditional concepts that once determined program form and function. Computer scientists working in the field of parallel computing, in which multiple CPUsc ooperate on the samep roblem at the same time, have introduced a number of new program models. In parallel computing parts of a problem are worked on simultaneously by different processors, and this speeds up the solution of the problem. Many challenges
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 贵州省考试院2025年4月高三年级适应性考试物理试题及答案
- 烘焙食品项目风险评估报告
- 重庆师范大学《音乐创作软件基础》2023-2024学年第二学期期末试卷
- 广东海洋大学《健身理论与指导》2023-2024学年第二学期期末试卷
- 荆州职业技术学院《口腔生物学》2023-2024学年第二学期期末试卷
- 信阳艺术职业学院《BIM应用技术》2023-2024学年第二学期期末试卷
- 四川省广安市华蓥市2024-2025学年初三下学期调研英语试题含答案
- 中国人民大学《应用文写作与训练》2023-2024学年第一学期期末试卷
- 长春建筑学院《制药过程安全与环境评价》2023-2024学年第二学期期末试卷
- 新余学院《钢琴基础(3)》2023-2024学年第一学期期末试卷
- 反假货币《外币美元》知识考试题库(含答案)
- 重庆大轰炸优秀课件
- 专题01《水银花开的夜晚》 高考语文二轮复习
- 外贸客户报价单中英文格式模板
- 中药学中药性味归经功效归纳
- 专业技术人员职务聘任书
- GB/T 13911-1992金属镀覆和化学处理表示方法
- GB/T 13452.2-2008色漆和清漆漆膜厚度的测定
- 【泉州南音传承与发展研究(论文7200字)】
- 《马克思主义发展史》第五章 马克思列宁主义在苏联的发展及曲折
- 现代汉语词汇学精选课件
评论
0/150
提交评论