On Tue, 11 Oct 2005 09:36:07 -0600 Steve Comstock <[EMAIL PROTECTED]>
wrote:

:>Art Celestini wrote:
:>> I realize this is more suited for the Assembler List, but as a brief 
follow-on 
:>> to Steve's parenthetical comment below: 
:>>  
:>> Many years ago, I had similar disdain for the use of literals.  But, as I 
wrote 
:>> more and more code that I knew would be handed over to others to support 
and 
:>> maintain, I came to realize that defining my constants "in-line" often 
:>> contributed to making that code a little easier for the next guy to 
understand.  
:>> (While reading the code to get the gist of what it's doing, he won't have 
to 
:>> interrupt his train of thought to go off somewhere else in the source to 
find 
:>> the value of some labeled constant.)


:>The point is to use "meaningful labels", so the reader
:>will not need to interrupt their study of the code.

  
:>> A couple weeks ago, I posted a question regarding CONVTOD, so I happened to 
:>> have the snippet below handy, which I'll use as an example.  This routine 
uses 
:>> hex floating point to accommodate the somewhat odd size and structure of 
the 
:>> STCK(E) clock format, so the instructions used are not typically among 
those 
:>> that most of us see on a daily basis.  I think with the constants being 
defined 
:>> in-line, it's easier to grasp what the code is doing:
  
 
:>>>*  When the CONVTOD macro is successful, the difference between  ``````
:>>>*  the ETOD values (plus one day), converted to seconds, repre-  ``````
:>>>*  sents the Retention-In-Seconds value:                         ``````
:>>>*                                                                ``````
:>>>CvExp020 DS    0H                                                ``````
:>>>         LM    R2,R3,CvExpEtodExp  Get exp. date's ETOD value    ``````
:>>>         SRDL  R2,8                Make room for exponent        ``````
:>>>         STM   R2,R3,CvExpHfpExp   Save in units of micro- ...   ``````
:>>>         MVI   CvExpHfpExp,79      ... seconds in HFP format     ``````
:>>>         LD    FR0,CvExpHfpExp     Get difference between ...    ``````
:>>>         SD    FR0,CvExpHfpNow     ...expiration & current dates ``````+
:>>>                                   Zero or less?                 ``````
:>>>         BNP   CvExp900            Yes ==> Go use zero retention ``````
:>>>         DD    FR0,=D'1000000'           Get difference in secs  ``````
:>>>         AD    FR0,=D'86400.999999'      Round up date/second    ``````
:>>>         AW    FR0,=X'4E00000000000000'  Align & store for ...   ``````
:>>>         STD   FR0,CvExpRetSecs          ... use as fixed point  ``````
:>>>         MVI   CvExpRetSecs,0     Clear HFP exponent byte        ``````
:>>>         B     CvExp900           ==> Go return result to caller `````` 
 

:>I disagree this is easier to grasp the flow
:>with the literals there; I'm not sure of the
:>right labels to choose, but maybe something
:>like:

:>          DD    FR0,Seconds_Adjuster      Get difference in secs
:>          AD    FR0,Rounder               Round up date/second
:>          AW    FR0,Aligner               Align & store for

:>then, if you are checking the details, or debugging, or
:>validating the code, you can look at the values.

Because in the included version, the comment explains the value and one can
see the value in-line and easily confirm that it is correct.

Your version just has the comment - not the true value. Thus one must scan to
find it.

I guess you could use

          DD    FR0,Seconds_Adjuster      Get difference in secs
          AD    FR0,Rounder               Round up date/second
          AW    FR0,Aligner               Align & store for

LITERALS  LOCTR ,

Seconds_Adjuster  DC  D'1000000'    
Rounder           DC  D'86400.999999'   
Aligner           DC  X'4E00000000000000'  

main      LOCTR ,

but it is a lot messier without providing any real advantage.

--
Binyamin Dissen <[EMAIL PROTECTED]>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to