[Info-vax] Whither VMS?

VAXman- at SendSpamHere.ORG VAXman- at SendSpamHere.ORG
Fri Oct 9 07:07:39 EDT 2009


In article <004a5c02$0$32494$c3e8da3 at news.astraweb.com>, JF Mezei <jfmezei.spamnot at vaxination.ca> writes:
>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 ?

With the counted example, long strings might be implemented with
long moves with the odd remainder being byte moves.  That would
be much more efficient for large data copies than the byte moves.


-- 
VAXman- A Bored Certified VMS Kernel Mode Hacker    VAXman(at)TMESIS(dot)ORG

  http://www.quirkfactory.com/popart/asskey/eqn2.png
  
  "Well my son, life is like a beanstalk, isn't it?"



More information about the Info-vax mailing list