TEXT A. THE BASIC PRINCIPLES OF PROGRAMMING

 

1. The Use of Temporaries. Memory space in a computer should be conserved. From this point of view there are two kinds of numbers contained in addresses: permanent, or constant numbers, such as 2 and g, and temporary numbers, i.e., numbers that appear only in intermediate stages of the computation. These temporary numbers can share their address with other temporary numbers that appear at some other time. Hence we call such memory locations temporaries.

2. Flow Chart. A flow chart is a diagram, or picture, of a code that is often helpful for visualizing interrelationship between various parts of a code. Such diagram is almost always made before the specific instructions are written. There are essentially three kinds of symbols used in a flow chart. The first represents function calculations, the second represents decisions and the various associated alternatives, the third, called a variable connector, is simply a way to eliminate too many crossing lines in the picture or to indicate which lines to follow when one has to continue the diagram on another page.

3. Symbolic Coding Aids. It is another intermediate aid between the statement of the problem and the final code. Symbolic coding consists in writing a code not in terms of specific numerical addresses, but rather in terms of some name description or other symbolism to represent the addresses. Then, at a later time, specific addresses can be assigned for these symbols, or names, to produce the actual code. The intermediate code in terms of symbols is called the symbolic code. This technique is extremely useful particularly in those cases where one must write instructions involving addresses of constants or of other instructions that have not yet been specially assigned.

4. The Use of a Subroutine. A subroutine is a subcode that may be used many times during the computation of a program but written only once in the whole code. As the computer proceeds down the main program, the control will occasionally jump to this subroutine and then, after doing the subroutine, will jump back to the main program where it left off. The term "jump" or "branch" is commonly used in the sense of "take the next instruction from". Thus the expression "jump to a subroutine" means "take the next instruction from the address where the first instruction of the subroutine is located".

5. The detour from the main program through the subroutine may occur several times during the computation of the program. Hence a subroutine must have an entrance, а wау of getting into it, and an exit, a way of getting out of it. Each time when an entrance is made to a subroutine, some initial conditions must be set up that are characteristic of the place in the main program from which the entrance was made. For instance, if the subroutine calculates some function, the initial values of the independent variables at that point in the main program must be given to the subroutine. In addition, as an entrance to a subroutine is made, the exit must be set up; i.e., the subroutine must be told where to transfer control back to the main program.

6. Hence, in order to use a subroutine, the coder must know (1) the entrance, i.e., the address of the first instruction; (2) the addresses of the temporaries in which the initial conditions are to be set up; (3) the addresses of the temporaries whose contents will be the results of the subroutine computation; (4)the exit, i.e., the address of some jump (branch) instruction that is to be preset (when entering the subroutine) so that when the computation of the subroutine has been completed, the computer will transfer control back to the proper address of the main program.

7. Library of Subroutines. Several subroutines may be used in one program. In fact it is found that many common subroutines are used quite often, such as sin x, cos x, ex, √x, etc. Hence it often becomes profitable to have a library of subroutines available to the programmer, stored at all times in some part of the computer memory. There would also be some catalogue kept outside the computer that the programmer can consult when he wants to use a subroutine. This catalogue would tell where each subroutine is located and all data about how to use it, such as where to put the initial values of independent variables, where the computed values of the dependent variables are found, etc.

Notes

1. symbolic coding aids - средства символического кодирования

2. initial [I'nijal] conditions - начальные (исходные) условия

3. independent variables - независимые переменные

4. the proper address - правильный (соответствующий) адрес

5. self-explanatory - ясный, не требующий разъяснения

6. dependent variables - зависимые переменные

 








Дата добавления: 2015-03-11; просмотров: 1747;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.005 сек.