× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Hans Boldt
Sent: Friday, November 21, 2003 11:43 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Infinit loop in /free


Steve Richter wrote:

> well I just had to test this ( comparing a count to a 31 digit packed
> decimal hival number seems a bit wasteful ) ...
>
> the following million iteration loop runs for 63 milliseconds on a
170/2386
> ( 400+ cpw ):
> ...
>
> and this do *hival version runs for 390 milliseconds
> ...

Hans replied:

>So this means that in a loop that does nothing, a DOW loop is preferable
>to DO *HIVAL. In practice, most loops do a bit more than that, and so
>the difference in loop overhead is usually swamped by the operations
>within the loop.

there is also the extra code needed to init, count and then compare for
*hival:
  InternalLoopCount = 0 ;
  Bgn:
    Inc  InternalLoopCount ;
    if   InternalLoopCount > *hival ;
      goto  End ;
    endif ;

vs:
  Bgn:
    if   1 != 1 ;
      goto End ;
    endif ;

Interestingly, I compiled two modules. one containing 20 loops in the do
*hival style and the other containing 20 loops in the dow '1' way.  The size
of the "do *hival" module is 4100 bytes greater than the other.  That is 200
bytes per loop! Unless /free code compiles to a smaller module than
comparable calc code, what we have here is a big waste of an abundant
resource.

here is the "dow '1'" style loop:

 // 001
     dow         conTrue ;
       Ix        = Ix + 1 ;
       if        Ix > conLoopCx ;
         leave ;
       endif ;
     enddo ;

 // 002
     dow         conTrue ;
       Ix        = Ix + 1 ;
       if        Ix > conLoopCx ;
         leave ;
       endif ;
     enddo ;

and the "do *hival" style loop:

**  001
C                   do        *hival
c                   eval      Ix = Ix + 1
c                   if        ix > conLoopCx
c                   leave
c                   endif
c                   enddo

**  002
C                   do        *hival
c                   eval      Ix = Ix + 1
c                   if        ix > conLoopCx
c                   leave
c                   endif
c                   enddo

Hans then wrote:

>But the comparison itself is flawed. The former uses a 10I0 variable as
>loop index, the latter uses an implicitly defined decimal variable with
>a precision of 31 digits. To make the comparison fair, define IX as 31P0
>in the first program.

Both loops have 10i0 fields that actually limit the iterations of the loop.
The comparison is accurate.

-Steve



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.