[Info-vax] Whither VMS?

JF Mezei jfmezei.spamnot at vaxination.ca
Thu Oct 8 20:55:00 EDT 2009


Here is a question.

Going back to all mighty Microvax II and before (especialy late 1970s
computers) when code efficiency was necessary:


in a loop to scan through a string, you would have:

Null terminated:

(while *ptr) do { something; ptr ++ ; }


Counted string:

for ( x=1 ; x < ptr_length ; x ++ )
	{ something ;
	  ptr ++ ;
	}

In the "null terminated" example, you only need to have a single
addition in each iteration of the loop.  And "ptr" would be in a
register and likely that *ptr would also be because "something" is
likely to need the value anyways. So, with 2 registers, you can have the
pointer to the data as well as the data.  Each iteration of the loop
needs only one math operation. (addition)

In the counted string example, you still need to have a pointer and the
data, but also a counter (x) and the loop limit (ptr_length), and each
iteration needs 2 math operations.

OK, you can optimize the second loop with:

for ( x = ptr_length; x > 0; x -- )  since this eliminates a test
against "ptr_length" within the loop,. reducing the need for an extra
register).


OK, having made the above generic argument, could this have been a
consideration when they decided to go with the null terminated string
back in the days when registers and cpu were in short supply ?



More information about the Info-vax mailing list