Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Методичка Английский.doc
Скачиваний:
6
Добавлен:
10.11.2019
Размер:
962.05 Кб
Скачать

7. Types of Error

System errors affect the computer or its peripherals. For example, you

might have written a program which needs access to a printer. If there is no

printer present when you run the program the computer will produce a system

error message. Sometimes a system error makes the computer stop working

altogether and you will have to restart the computer. A sensible way of avoiding

system errors is to write code to check that peripherals are present before any

data is sent to it. Then the computer would warn you by a simple message on

the screen, like 'printer is not ready or available'. Syntax errors are mistakes in

the programming language (like typing PRN1T instead of PRINT). Syntax

errors cause the program to fail. Some translator programs won't accept any line

that has syntax errors. Some only report a syntax error when they run the

program. Some languages also contain special commands such as debug, which

will report structural errors in a program. The programming manual for the

particular language you're using will give details of what each error message

means.

Logic errors are much more difficult to detect than syntax errors, This is because a program containing logic errors will run, but it won't work properly. For example, you might write a program to clear the screen and then print 'hello'. Here is a code for this:

10 Message 30 CLS

20 PRINT 'Hello' 40 END.

The code has a logic error in it, but the syntax is right so it will ran. You can get rid of logic errors from simple programs by 'hand-testing' them or doing a 'dry ran' which means working through each line of the program on paper to make sure it does what you want it to do. You should do this long before you type in the code.

8. The Basic Principles of Programming 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 are being the most common.

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 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.

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 diagramed by means of a 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 tire third stage some procedure is used to get the code into the memory of the computer. The fourth stage consists of debugging the code, detecting and correcting any errors. The fifth and final stage involves running the code on the computer and tabulating the results. It is well known 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.

Instruction Format Some bits of the instruction are set a side for the operation code designation; they tell the instruction is "add", "divide", etc. The rest of the bits usually defines 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.

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 11.0 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 addrcss-326, the ■second operand address-345, the third address-364, and the fifth address-401. In such cases it evidently facilitates matters to call address 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).

The Computer Manual. For (he computer we must have; a computer manual that gives the operation codes of different instructions and also defines precisely the meaning of the address for each instructions 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.