Scor­pio News

  

January–March 1987 – Volume 1. Issue 1.











Page 49 of 63











FOR...NEXT or their FORTRAN of PASCAL equivalent DO loops work faster if unnecessary arithmetic is reduced – so constants can be placed outside the loop. It is also quicker to dispense with loops altogether in some cases where, for example, an array has to be initialised.

FOR I=1 TO 3
X(I)=0
NEXT I

if it is ‘unrolled’ to give the direct assignments:

X(1)=0
X(2)=0
X(3)=0

since this avoids the work/​time overhead associated with loops.

The worst offenders in almost all respects are programs originally written for mainframe computers in which memory restraints are almost unknown and the clock speed and cycle time are such that even inefficiently-written programs run extremely quickly. Good programs, regardless of their function or the language in which they are written, should take into account most, if not all of the points raised in this article during their development The extra time and care involved will certainly not be wasted!

References

Brown, A.R. and Sampson, W.A (1973) Program debugging: the prevention and cure of program errors. Macdonald.

Monro, D.M. (1978) Basic BASIC. Edward Arnold,

LISTING FOR   "MAKING CP/M USER FRIENDLY – By C. Bowden"












Page 49 of 63