1、论文资料- 计算机应用软件外文翻译资料 1 什么是软件 读者知道了操作系统是一些软件模块的集合,这些模块完成支持功能,有效地把用户和硬件隔开。本文转入对软件较一般的讨论。本文不期望教会读者如何编程序,读者也不要打算通过读一本入门书中的一章就学会编程序。本文的意图是通过向读者展示在机器级上程序究竟是什么,然后简单地讨论当开发一个程序时程序员应该遵循的过程,从而力求揭示那些常常与软件有关的奥妙。 让我们从定义开始,程序是引导计算机通过一个过程的一组指令。每条指令都告诉机器完成它的基本功能中的一个。如加、减、乘、除、比较、复制、请求输入或请求输出等。读者知道了在每个机器周期内处理器取出并执行一条指令
2、。一条典型的指令包含一个操作码和一组操作数,操作码规定了要完成的功能,操作数规定了存放要被处理的数据的存储单元地址或寄存器编号。 例如:指令 ADD 3,4 告诉一台假想的计算机把寄存器 R3 和 R4 的内容相加。 由于计算机指令组的功能如此有限,甚至一个简单的逻辑操作也需要若干条指令。例如,假设二个数据的值存放在主存中,在很多机器上为了把它们相加,首先要把两个数值加载到寄存器中,然后把寄存器的内容相加,结果再送回到主存中。这样就要用四条指令 LOAD, LOAD、ADD 和 STORE。如果为两个数相加就需要四条指令的话,可以想象在一个完整的程序中指令的数目。 计算机是由存放在自己主存中的
3、程序控制的。因为主存存放数位,所以程序必须以二进制代码形式存在。图 1 所示的是二进制机器级指令、就是上例所需要的四条指令:把两个数值加载到寄存器中,再把它们相加及结果放在主存中等。如果程序员必须用机器语言编程序的话,那么就几乎没有人能做程序员了。 2 编程语言 2.1 汇编语言 用汇编语言编程是一种选择。例如,图 2 展示用 IBM 主机的汇编程序如何把两个数相加。程序员为每一条机器指令写一条助记符指令。AR(把寄存器的内容相加)比等效的二进制操作数 000110101 容易记忆;字母 L(用做装入)也比 01011000 容易记忆。操作数用标志符 A, B 和 C,取代了主存的地址编号,这
4、样也简化了代码。 遗憾的是没有能直接执行汇编语言指令的计算机写助记符代码可以简化程序员的工作,但是计算机是二进制的机器,要求二进制指令,因此需要翻译。汇编程序读入程序的源代码,把源语句翻译成二进制数,产生目标模块。因为目标模块是程序源代码的机器级的版本。所以它能被装入主存中并加以执行。 汇编语言程序设计员为每条机器指令写一条助记符指令。因为汇编指令和机器指令之间存在一一对应的关系,汇编语言和机器语言都是依赖于机器的,所以为一种型号计算机编写的程序不能在另一种型号的机器上执行。在一台给定的机器上,汇编语言尽可能产生最直接有效的程序,因此经常用它写操作系统或其它系统软件。然而,当它应用于应用程序时
5、,依赖于机器的属性是要为效率付出高代价的,所以应用程序很少用汇编语言来写。2.2 编译程序和解释程序 为了把两个数相加,计算机需要四条机器指令。因为这是计算机工作的方法。人类不必象计算机一样地思维,程序员只简单地指明做加法,采用另一些指令就行了,例如,一种方法就是把加法看成一个代数表达式: c=AB 为什么不允许程序员用类似于代数表达式的形式去写语句呢?又为什么不能把这些源语句编在程序中,并让程序产生所需的机器码呢?肯定这就是编译程序所要完成的。 许多编程语言,包括 FORTRAN, BASIC, PASCAL, PL/1 和 ALGOL 都是基于代数表达的。面向商业的最常用的 COBOL 语
6、言要求语句类似于简短的英语句子。然而必须提醒注意的是,采用什么语言没关系,目标 是相同的。程序员编源码程序,汇编程序接受助记符源码程序,并产生机器目标模块;FORTRAN 编译程序接受 FORTRAN 源码,也产生机器目标模块;COBOL 编译程序接受 COBOL 源码,产生同上的目标模块。 汇编程序和编译程序之间有何差别呢?对于汇编程序,每一个源语句都转换成一条机器指令。但对于编译程序,一个源语句可以转换任意数目的机器指令。 还有一种选择是采用解释程序。汇编程序和编译程序都读入一个完整的源程序,并产生一个完整的目标模块。另一方面,解释程序每次只对一个源语句操作,读入它,把它转换成机器指令,执
7、行被转换成的二进制指令,然后继续下一条源语句。编译程序和解释程序两者都产生机器指令,但过程是不同的。 每种语言都有它自己的语法、标点和拼写规则。例如PASCAL 源程序对 COBOL 编译程序或者 BASIC 解释程序是无意义的。然而,所有的这些语言都支持编写程序。无论用什么语言,程序员的目标是相同的。都是要确定一系列步骤,引导计算机通过某个过程。2.3 非过程语言 用传统的汇编语言、编译语言和解释语言,程序员确定了一个确切地告诉计算机如何去解决问题的过程。然而,用现代非过程语言,有时称第四代语言或说明语言,程序员只须简单地确定问题的逻辑关系,而让语言变换程序推算出如何解决问题。商业上使用的非
8、过程语言的例子有:Prolog, Focus, Lonusl-2-3 和其它等。它们正变得越来越流行。3 程序库 设想程序员编写一个庞大程序,当源语句被键入时,可用编辑程序处理它,并存放在磁盘上。因为庞大的程序不可能用一次预约的时间就全部写入,所以程序员最终要停止键入,并把已键入的程序通过驱动器送到磁盘上。以后当工作恢复时,软磁盘重新插入,新的源语句接在后面键入。同一磁盘可以保存其它一些源程序甚至其他程序员所写的一些程序。源语句库的例子就是一个很好的说明。 最终,完成了源程序的键入和编译,得到的目标模块可以直接装入到主存,但更多的时候它存放在目标模块库中。因为目标模块是二进制的机器级的子程序,
9、所以一个目标模块由汇编程序产生和 FORTRAN 编译 程序(或任何其它编译程序)产生没有根本差别。因此,用不同的源语言产生的目标模块可存放在同一个程序库内。 有些目标模块能装入到主存中,并被执行。而另一些模块,包括了对一些子程序的调用,这些子程序不属于目标模块的一部分。例如,一个计算机仿真扑克牌的程序,如果以前有人编写了一段很优秀的发牌子程序,那么重新用那个子程序是有意义的。4 程序开发过程 程序如何修改软件包呢?更普遍地讲,职业的程序员如何编写原始程序呢?编程序不完全是科学,还涉及到一点艺术。因此,不同的程序员用不同的方法编程序是没什么奇怪的。然而,大多数程序员都从仔细地定义问题开始,然后
10、,在写编码前详细地设计出解决办法。让我们简单地研究一下程序的开发过程。 4.1 问题的定义程序开发的第一步是问题定义,这一点看起来是常识,但常常有些程序还不清为什么需要就编出来了,对一个未能正确定义的问题所得到的结果,即使是一个伟大的结果,也是无用的。 因为人们需要信息,才写程序,因此程序员应在明确了所期望的信息后才能开始写。接着,要确定产生那个信息的算法或规则。给出了所要求的输出信息和算法,要输入的数据也就确定了结果是,一个清晰的问题定义,给了程序员一个好思想,明确了这个程序必须完成的事情。 4. 2 编排 算法确定了必须做的事情,接下来的任务是决定如何去做目的是要用计算机能理解的术语去陈述
11、问题的解。由于计算机只能完成算术运算、比较、复制和请求 I/0 等操作,因此程序员受到这些基本操作的限制。一个良好的起点总是首先确定求解问题的一个小型方案通过实际求解的这一算法,甚至是在规模上有限的一个算法。使程序员获得编程问题所需的步骤。 4.3 编写程序在实施阶段,程序员把问题的解法转换成用某种编程语言写成的一系列源语句,而每一种编程语言都有它自己的语法、标点和拼写规则。学习一种新语言要花时间,写指令基本上是机械性工作。编程的真正秘密不是简单地编写指令,而是要思考接下来该写什么指令,这就需要逻辑性。有幸的是知道如何编程序并不是使用计算机的先决条件。4.4 调试和文档编写程序一旦编成,程序员
12、就必须调试它。首先要纠正它的一些无意识的错误,譬如错误的标点或拼写等。编译程序或解释程序通常能发现这些错误,较困难的是发现并纠正逻辑错误,这类错误是由于采用错误的指令而引起的。仅仅指令正确是不够的,程序还必须是顺序正确的指令组。再重复一次,精心的编程设计是关键,优良的设计可简化程序的调试。 程序的文档由段落、注释和其它解释或阐明编程的说明材料组成,在程序调试阶段,文档是极宝贵的,也是有效的维护程序的基础。最有用的是出现在程序中的注释,这些注释列举出并解释了逻辑关系。4.5 维护程序一调好,维护就开始了。由于不可能彻底地测试许多大程序。在调试阶段中、一些缺欠可能滑过去了,几个月甚至几年以后才暴露
13、出来,测定出这些缺欠是非常重要的维护任务。更为重要的维护是为了适应现时应用的需要而修改程序。例如,由于所得税经常变化,工资程序必须经常修改。维护的关键是认真的计划,完整的文档资料和优良的程序设计。5 编写用户程序 能演奏一种乐器并不是欣赏音乐的基础。同样,知道如何编程序也不是使用计算机的先决条件。大多数计算机用户不能编程序。 正如一种乐器的初步知识能增长你对音乐的欣赏水平一样,知道了如何编程序能使你成为一个比较有效率的计算机用户。当然,如果你希望以计算机职业谋生的话,编程序的知识是基础,这就不用说了。有些人发现编程容易,还有些人发现编程序极困难。关键是要实践,学习编程序的唯一方法就是实际地去编
14、程序。Application software 1 What is the software Readers know that the operating system is a collection of software modules, these modules complete support functions, effectively separating the users and hardware. In this paper, the software into more general discussion. In this paper, readers do not
15、expect the church how the procedures, the reader should not intend to read an entry through a chapter book for the Institute procedures. The intent of this paper to readers through machine-level display in what is the procedure, and then briefly discuss the development of a procedure when programmer
16、s should follow the process so as to those who often seek to reveal the secret of the software. Let us start from the definition, the process is a process guided by computer for a group of instructions. Instructions tell each machine to complete its basic functions in one. If adds, subtracts, multip
17、lies, in addition, comparison, replication, importation request or request output. Readers know that the cycle in each processor machines removed and the implementation of a directive. A typical directive contains an operation code and a group of several operations, the operation code provides for t
18、he functions to be completed, the operation of several provisions of the stored data to be dealt with the memory cell address or register numbers. For example: 3,4 directive ADD Tell a hypothetical computer to register R3 and R4 sum of the contents. As computer instruction set such a limited functio
19、n, or even a simple logic operations also need some instructions. For example, suppose two data values stored in the main memory, in many machines to put them together, we must first two numerical loaded in the register, then add the contents of the register, before sending it back to the main resul
20、ts of depositors. This will use four instructions LOAD, LOAD, ADD and STORE. If the two numbers add up to four instructions on the needs of the imagination in a complete process of the number of instructions. The computer is stored in main memory in their program. Because a number of main memory sto
21、rage, procedures must be in the form of binary code. Figure 1 shows the binary machine-level instructions, is needed on the cases of four instructions: Numerical loaded to the two registers, then put them together and the results of the middle. If programmers must use procedures for the machine lang
22、uage, then there would be almost no one can do the programmers. 2 programming language 2.1 assembly language Using assembly language programming is an option. For example, Figure 2 display IBM mainframe assembler how to add two numbers. A machine for each programmer to write a directive x87 instruct
23、ions. AR (the contents of the register together) than the equivalent of the binary number 000110101 easy operation memory; Letter L (used as load) than 01011000 easy memory. Operate with few signs at A, B and C, replacing the main memory address number, this also simplifies the code. Unfortunately t
24、here is no direct implementation of the computer assembly language instructions. Write x87 code programmers can simplify the work, but the computer is a binary machine for binary instructions, requiring translation. Read procedures assembler source code, the source statement translated into binary,
25、a target module. Because the module is the goal of the program source code machine-class version. Therefore, it can be installed in the main memory and to implement them. Members of assembly language programming instructions for each machine to write a x87 instructions. Because compilation machinery
26、 orders and instructions between 一一对应 relations, assembly language and machine language are dependent on machines, as a computer model prepared by the procedure can not be another type of machine implementation. In a given machine, the assembly language as far as possible, have the most direct and e
27、ffective process, often using it to write the operating system or other system software. However, when it applied to applications, rely on machines attributes is to pay a high price for efficiency, so applications rarely use assembly language to write. 2.2 compiler and interpreterIn order to add two
28、 numbers, the computer needs 104 machine instructions. Because this is the work of the computer method. Human beings do not have the same manner as computers, programmers simply specified boosting using other instructions on the roll, for example, is a way of the addition as an algebraic expression:
29、 C = A + B Why do they not allow programmers using algebraic expressions similar to the form of written statements? And why not the source of these statements made in the proceedings, and procedures necessary for native? This is the compiler sure to be completed. Many programming languages, includin
30、g Fortran, BASIC, PASCAL, PL / 1 and ALGOL are based on the algebraic expression. Business-oriented COBOL language most commonly used language similar to the requirements of the short English phrases. However, it must be recalled that, It does not matter what language, the target is the same. Progra
31、mmers for source, assembler accept x87 source procedures, and produce machines goals module; FORTRAN compiler accept FORTRAN source, also produced machines goals module; COBOL compiler accept COBOL source code, the goals have ibid. module. The compilation process and the difference between the compi
32、ler? For assembler, every source query has been converted into a machine instructions. But compiler, a source statements can be converted arbitrary number of machine instructions. Another option is to adopt the interpretation of the procedures. The compilation process and procedures are compiled int
33、o a complete reading of the source files, and produce a complete module targets. On the other hand, only the interpretation of the procedures each operation of a source statement, read it, put it into machine instructions, implementation is converted into binary instructions, and then proceed to the
34、 next source of a statement. Compiler procedures and the interpretation of the procedures both produce machine instructions, but the process is different. Each language has its own grammar, punctuation and spelling rules. PASCAL source such as the COBOL compiler or BASIC interpreter is meaningless.
35、However, all these languages are in support of the preparation procedures. No matter what language, programmers goal is the same. A series of steps are to determine, through a computer to guide the process.2.3 Non-ProcessLanguage Using traditional assembly language, compiler language and interpretat
36、ion of language, programmers determined to tell a computer exactly how to solve the problem of process. However, the use of modern non-process language, and sometimes said that the fourth-generation language or languages, programmers need only simple logic to determine the relationship, so the langu
37、age transform procedures calculated how to solve the problem. The non-commercial use of language examples are: Prolog, Focus, Lonusl-2 - 3 and other, and so on. They are becoming increasingly popular.3 libraries Programmers envisaged to prepare a huge procedure, when the type of statement, it may be
38、 editing procedures, both on the disk. Because the procedure can not be used huge booking a write all the time, so programmers eventually have to stop typing, and the type of procedure has been adopted to the disk drives. When work resumed later, the floppy disk re-inserted, the new source statement
39、 by typing in the back. The same can be preserved for some other disk source code written by programmers and even some of the other procedures. The source of the statement is a good example of that. Finally, the completion of the type and source compiler, the target modules can be directly loaded in
40、to main memory, but more often it deposited in the target module library. Because the target module is binary machine-class subroutine, a target module generated by the compilation process and FORTRAN compiler (or any other compiler) have no fundamental differences. Therefore, the language used diff
41、erent source modules and that the objective can be stored in the same stored procedure. Some of modules can be loaded to the main deposit, and was implementation. While other modules, including some of the subroutine call, the goal of these subroutine modules are not part of. For example, a computer
42、 simulation poker the procedure, if someone previously prepared for a very good brand of procedures, then re-use that subroutine is meaningful. 4 program development process Procedures how to amend the package? More generally speaking, professional programmers how to prepare the original procedure?
43、Part procedure is not entirely a scientific, but also to point arts. Therefore, different programmers use different methods for procedures is nothing strange. However, most programmers are careful definition of problems from the start, and then write code in detail before design solutions. Let us br
44、iefly examine the procedures for the development process.4.1 the definition of the problemProgram development is the first step in problem definition, which appears to be common sense, but it often is not clear why certain procedures need to come out for the definition of a failure to correct the pr
45、oblem by the results, even if the result is a great, but also useless. Because people need information before writing process, the programmer should be clear after the desired information can start writing. Then, have that information to determine the algorithms or rules. Given the requested informa
46、tion and the output method, the data will have to import identified a result, a clear definition of the problem to the programmer a good idea, a clear procedure must be completed this thing.4.2 Schedule The algorithm for determining what must be done, the next task is to decide what to do purpose is
47、 to use the computer to understand the terminology solution to the problem statement. The computer can only be completed arithmetic operations, compare, replication and requests I / 0, and other operations, so programmers are the basic operation of these restrictions. A good starting point is always
48、 the first to identify a small problem solving program. Through practical solution of this algorithm, even in a limited scale algorithm. Programming problems programmers access to the necessary steps.4.3 preparation procedures In the implementation phase, programmers solution to the problem into som
49、e kind of programming language with a series of statements, each programming language has its own grammar, punctuation and spelling rules. Learning a new language takes time, writing instruction is basically mechanical work. Programming the real secret is not a simple preparation instructions, but to think what was then the directive, which requires logic. Honor is aware of how the process is not a prerequisite for the use of computers. 4.4 debug and document preparationOnce the composition process, the programmer must set it up. First to rectify some of its Unconscious errors, such