BASIC COMPUTER ORGANISATION AND DESIGN
the loop, so the computer returns to repeat the loop once again. When location CTR reaches zero (after the
loop is executed 100 times), the next instruction is skipped and the computer executes the instructions in
lines 11 and 12. The sum obtained in the accumulator is stored in SUM and the computer halts. The halt
instruction is inserted here for clarity; actually, the program will branch to a location where it will continue
to execute the rest of the program or it can branch to the beginning of another program. Note that ISZ in
line 8 is used merely to add 1 to the address pointer PTR. Since the address is a positive number, a skip will
never occur.
Top
#
%
In a large system the number of instructions available in a computer may be a few hundred or a few dozen
in a small one. Some computers execute a given operation with one machine instruction; some may require
many machine instructions to perform the same operation. For example, consider the four basic arithmetic
operations. Some computers have machine instructions to add, subtract, multiply, and divide. Others, such
as the basic computer, have only one arithmetic instruction, such as ADD. A program must implement
operations not included in the set of machine instructions.
We have shown in Table 2.8 a program for subtracting two numbers. Programs for the other arithmetic
operations can be developed in a similar fashion.
If operations are implemented in a computer with one machine instruction, then it is said to be implemented
by hardware. Operations implemented by a set of instructions that form a program are said to be
implemented by software. Some computers provide an extensive set of hardware instructions designed so
that common tasks can be performed efficiently. Others contain a smaller set of hardware instructions and
depend more heavily on the software implementation of many operations. Hardware implementation is
more costly because of the additional circuits needed to implement the operation. Software implementation
results in long programs both in number of instructions and in execution time.
We use the conventional method of multiplying two numbers to write the program for multiplying two
numbers. As shown in the example of Fig. 2.11, the multiplication process consists of checking the bits of
the multiplier Y and adding the multiplicand X as many times as there are 1's in Y, provided that the value
of X is shifted left from one line to the next. Since the computer can add only two numbers at a time, we
reserve a memory location, denoted by P, to store intermediate sums. The intermediate sums are called
partial products since they hold a partial product until all numbers are added. As shown in the numerical
example under P, the partial product starts with zero. The multiplicand X is added to the content of P for
each bit of the multiplier Y that is 1. The value of X is shifted left after checking each bit of the multiplier.
The final value in P forms the product. The example has numbers with four significant bits. When
multiplied, the product contains eight significant bits. The computer can use numbers with eight significant
bits to produce a product of up to 16 bits. The flowchart of Fig. 2.11 shows the step-by-step procedure for
programming the multiplication operation. The program has a loop that is traversed eight times, once for
each significant bit of the multiplier. Initially, location X holds the multip