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.

----------------------------------------------------------------------
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