TEXT A. THE BASIC PRINCIPLES OF PROGRAMMING. 1. Introduction. The purpose of this chapter is to introduce the student to the fundamental principles of coding and programming
1. Introduction. The purpose of this chapter is to introduce the student to the fundamental principles of coding and programming. These principles are connected with the stages of programming, the flow-charting, using the subroutines and the computer manual, etc. In order to leave students free to concentrate on these principles, the four-address format, with a minimum of instruction types, is utilized. However, it should be pointed out that the four-address format is used in this chapter for pedagogical reasons only. In practice commercially available computers use only three-, two-, or one-address formats, the latter perhaps being the most common.
2. The Terms ‘Coding’ and ‘Programming’ are often used as synonyms. However, ‘a code’ is more specifically a short list of instructions that direct the computer to perform only a part of the entire calculations, whereas the term ‘program’ refers to the complete list of instructions used for the problem. Hence the term ‘programming’ usually includes the over-all planning of the use of the computer for a particular problem as well as the writing of the instruction lists, or codes, whereas ‘coding’ is usually limited in meaning to the writing of the instruction lists. Sometimes a code is called a routine.
3. Stages in Programming. There are five stages in programming. First the computations to be performed must-be clearly and precisely defined. The over-all plan of the computations is diagrammed by means of so-called flow chart. The second stage is the actual coding. It is often best to write a code in terms of a symbolic language first, for then changes are easily made. Numbers are assigned to the symbols, and the final code is prepared. In the third stage some procedure is used to get the code into the memory of the computer. The fourth stage consists of debugging the code, i.e., detecting and correcting any errors. The fifth and final stage involves running the code on the computer and tabulating the results. In fact, it is well know that a single error in one instruction invalidates the entire code. Hence, programming is a technique requiring attention to details without loosing sight of the over-all plan.
4. Instruction Format. Some bits of the instruction are set aside for the operation code designation – i.e., they tell the instruction is ‘add’, ‘multiply’, ‘divide’, etc. The rest of the bits usually define the four addresses. For the more usual operations that involve two operands, such as addition, multiplication, etc., two of the addresses are the addresses of operands. The third address tells where the result is to be put; the fourth address tells where to obtain the next instruction. So, the instruction format is the way in which the different digits are allocated to represent specific functions.
5. Octal Shorthand. The first important detail of coding is the fact that the actual bits in an instruction are not written out in the binary code; rather, some shorthand is written instead, i.e., the octal equivalent would be written out. In other words, two octal numbers represent the instruction, and each address would be represented by three octal numbers. Thus, if 101 011 is the binary code for the command ‘add’ then the instruction that says, “Add the contents of address 011 010 110 to the contents of address 011 100 101, put the result into address 011 110 100, and take the next instruction from address 100 000 001,“ is written in octal notation as: operation – 53, the first operand address – 326, the second operand address – 345, the third address – 364, and the fifth address – 401. In such cases it evidently facilitates matters to call addresses in the memory by their octal numbers. Also, numerical quantities will be written on the code sheet in octal (i.e., they will have to be converted from decimal to octal before being written on the code sheet).
6. The Computer Manual. For the computer we must have a computer manual that gives the operation codes of different instructions and also defines precisely the meaning of the addresses for each instruction type. The coding manual must always be at the coder’s side. Two further observations must be reemphasized: first , when a word is called into the arithmetic/logic unit from the memory, it is not erased from its memory address, but remains there also; second, when a word is put into a memory address, it replaces the previous contents of this address, i.e., it erases what had been there.
Notes
1. in order to leave students free to concentrate on these principles – чтобы дать возможность студентам сосредоточиться на этих принципах
2. without loosing sight of – не теряя из виду
3. are set aside for the operation code designation – откладываются для обозначения кода операции
4. it evidently facilitates matters – это, очевидно, облегчает дело (ситуацию)
5. must always be at the coder’s side – должен всегда быть у программиста под рукой
Дата добавления: 2015-03-11; просмотров: 1348;