I don't want to highjack my own thread. Here is the output (probably edited a 
little) from EDCDSECT and the sort of thing you can do with the results:
        
struct cvt {
  void          *cvttcbp;         /* -  Address of PSATNEW.                   
@PTC          */
  void          *cvt0ef00;        /* - ADDRESS OF ROUTINE TO SCHEDULE           
            */
  void          *cvtlink;         /* -  ADDRESS OF DCB FOR SYS1.LINKLIB DATA 
SET.           */
  void          *cvtauscb;        /* - ADDRESS OF ASSIGN/UNASSIGN SERVICE    
@H1A           */
  void          *cvtbuf;          /* -        ADDRESS OF THE BUFFER OF THE 
RESIDENT         */
  void          *cvtxapg;         /* -  ADDRESS OF I/O SUPERVISOR APPENDAGE 
VECTOR          */
  void          *cvt0vl00;        /* - ADDRESS OF ENTRY POINT OF THE TASK       
            */
  void          *cvtpcnvt;        /* - ADDRESS OF ENTRY POINT OF THE ROUTINE    
            */
  void          *cvtprltv;        /* - ADDRESS OF ENTRY POINT OF THE ROUTINE    
            */
  void          *cvtllcb;         /* -  ADDRESS OF THE LLCB.                  
@P1M          */

etc.

void GetStepname(char name[9])
{
        psa* psaPtr = NULL;
        tcb* tcbPtr = (tcb *)psaPtr->psatold;
        tiot* tiotPtr = (tiot *)tcbPtr->tcbtio;
        memcpy(name, &tiotPtr->tiocstep._tiocjstn, sizeof(name)-1);
        name[8] = '\0';
}

BTW, My union example below is wrong. What I mean is it gets the offsets 
correct but it "factors" the ORG illogically. Hard to explain. What you 
logically think of as two alternate record layouts, one {a,b} and one {c,d}:

union {
   struct {int a; int b;};
   struct {int c; int d;}; };

it instead renders as

struct {
   union {int a; int c;};
   union {int b; int d;}; };

If one of those int's is instead itself a struct of a short and two chars it 
ends being a hard-to-read mess.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Charles Mills
Sent: Saturday, March 19, 2016 3:47 PM
To: [email protected]
Subject: Re: C struct to DSECT utility?

Well, it's one of those things. EDCDSECT does not do a perfect job but it does 
a better job than no job at all. You're not using it "in production" so if it 
does a 95% job you are 95% ahead. Well, in my experience it is about 95% pretty 
much right and about 1% totally wrong, where it gets an offset wrong. Sometimes 
it generates such a flipping mess of unions that it is hopeless to read. It 
tends to get unions wrong. How do I say this? Something that logically should 
have been rendered

union x {int a; int b;};
union y {int c; int d;};

it instead renders as

union z {int a; int c;};
union w {int b; int d;};

Yes, of course, assembler is weakly typed, and even there, people misuse what 
typing there is. EDCDSECT has some options, for example, how do you want to 
deal with

FLAG  DS  X
INPUT EQU X'80'
OPEN  EQU X'40'
etc.

Do you want INPUT to be a one-bit integer or a #define mask suitable for use 
with logical or? EDCDSECT gives you a choice.

You have a choice whether to lowercase the assembler symbols (because old 
assembler is typically all uppercase and C culture is lowercase).

Yes, there would be some challenges going the other direction: Foo and foo are 
different C symbols but the same assembler symbol (but do you use both in the 
same struct???). C struct symbols typically have local scope; all assembler 
symbols have global scope. You could deal with the latter by letting the user 
specify a prefix or by rendering

struct Foo { int Bar; };

in assembler as

Foo_Bar DS F

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to