I Tech Group

Friday, April 8, 2011

PROGRAM CODING

It is important to remember program coding is not the first step of programming. Too often we have a tendency to start coding too soon. As we just discussed, a great deal of planning and preparation must be done before sitting down to code the computer instructions to solve a problem. For the example amortization problem (fig. 3-6), we have analyzed the specifications in terms of (1) the output desired; (2) the operations and procedures required to produce the output; and (3) the input data needed. In conjunction with this analysis, we have developed a programming flowchart that outlines the procedures for taking the input data and processing it into usable output. You are now ready to code the instructions that will control the computer during processing. This requires that you know a programming language.
All programming languages, FORTRAN, COBOL, BASIC and so on, are composed of instructions that enable the computer to process a particular application, or perform a particular function.
Instructions
The instruction is the fundamental element in program preparation. Like a sentence, an instruction consists of a subject and a predicate. However, the subject is usually not specifically mentioned; rather it is some implied part of the computer system directed to execute the command that is given. For example, the chief tells a sailor to "dump the trash." The sailor will interpret this instruction correctly even though the subject "you" is omitted. Similarly, if the computer is told to "ADD 1234," the control section may interpret this to mean that the arithmetic-logic section is to add the contents of address 1234 to the contents of the accumulator (a register in which the result of an operation is formed).
In addition to an implied subject, every computer instruction has an explicit predicate consisting of at least two parts. The first part is referred to as the command, or operation; it answers the question "what?" It tells the computer what operation it is to perform; i.e., read, print, input. Each machine has a limited number of built-in operations that it is capable of executing. An operation code is used to communicate the programmer's intent to the computer.
The second specific part of the predicate, known as the operand, names the object of the operation. In general, the operand answers the question "where?." Operands may indicate the following:
  • The location where data to be processed is found.
  • The location where the result of processing is to be stored.
  • The location where the next instruction to be executed is found. (When this type of operand is not specified, the instructions are executed in sequence.)
The number of operands and the structure or format of the instructions vary from one computer to another. However, the operation always comes first in the instruction and is followed by the operand(s). The programmer must prepare instructions according to the format required by the language and the computer to be used. 


http://www.tpub.com/neets/book22/93d.htm

No comments:

Post a Comment