[Info-vax] Whither VMS?

glen herrmannsfeldt gah at ugcs.caltech.edu
Thu Oct 8 21:35:48 EDT 2009


JF Mezei <jfmezei.spamnot at vaxination.ca> wrote:
 
< 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.

(snip)

It depends on the instructions set.  VAX has an indexed addressing
mode, so you only need the counter register and supply that as
the index to the instruction(s) operating on the string.  For VAX
the index is optional and may cost some extra cycles.

For S/360, the usual addressing mode includes an index register.
One many processors there is no extra cost, on some one cycles more.

IA32 has special instructions for counting (in CX, ECX) and
for incremented address load/store.  It is probably easier and
maybe faster to do the counted loop.  Some loops can be done
with one instruction with a LOOP prefix.

-- glen



More information about the Info-vax mailing list