[comp.lang.asm370] LTORGs, coding style, etc

LDW@USCMVSA.BITNET (Leonard D Woren) (12/17/87)

> >(PS I also use implicit lengths, its just that you don't get something
> >for nothing.)
> Good point Harry.   The bugs, when you get 'em, are certainly more subtle
> with implied lengths.  Hopefully, with a good data structure, they should be
> less common though.    Being an MVS hacker, I've not seen that much VM code,

   I'll say it a lot stronger:  if your data structure is well defined,
use of implicit lengths will generate correct code more often than use
of explicit lengths.

> and I don't know the case you quote. I guess someone was going:-
>         CLC   =C'FRED',USERID    where USERID was probably defined as a CL8.
>
> Yes, you'd have to use:
>         CLC   USERID,=CL8'FRED'  so in a sense you lose the 'implicitness'

   Let's compare apples and apples.  One of the literals has an
explicit length and the other doesn't.  If you change the first line
to:
        CLC   =CL8'FRED',USERID
then it works as desired.  If you change the second line to:
        CLC   USERID,=C'FRED'
then it will fail for *exactly* the same reason that the first line
in the original posting will fail.  The order of operands in this
particular example has nothing to do with potential problems.  An
error in the coding does.  Not using literals will not avoid this
problem, because the same error in coding might be done with a DC.

> p.s. I suppose to be utterly pure, one could go:-
>        .......,=CL(L'USERID)'FRED'
> but I'm not even sure that it works, and it looks pretty awful.

   Yes, that's the "best" (safest) way to do it, it works, and I don't
think it looks that awful.  It's just cumbersome to type, and takes a
lot of space in the line.  On the other hand, I have always used a
comment column of 41, so I seldom have operands that run into my
comments...

> I think that's the point where I would stop using literals and go for a
> wholegrain constant, with length properly defined. In fact (said he, warming t
> his theme... :-) ) take care of the data, and the code takes care of itself.

   I find reading programs where every trivial little constant is
defined with a DC instead of a literal to be very annoying to read.
I have to keep flipping back and forth, whereas, if literals were used,
the definition is clear from the location where they're used.  Let's
try an example in another language:
     DCL F1 FIXED BIN(31) INIT(1);
     ...
     IF somevar = F1 THEN DO;
That's a lot more obtuse than
     IF somevar = 1 THEN DO;

Now, back to ASM... I also think that
       CLC  =F'1',somevar
is much cleaner than
       CLC  =F'1',F1
       ...
   F1  DC F'1'
because I don't have to go flipping through the listing to see how F1
is defined.  It's also faster to write, since you don't have to scroll
off somewhere else to put in the constants as you write the code.  And
as a side note, I've seen programs where the same constant was defined
multiple times because the programmer was sloppy and manual management
of constants is time consuming.


/Leonard