Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Automatic Generation of Assembler Language DSECTs to Match C Structures

IP.com Disclosure Number: IPCOM000107850D
Original Publication Date: 1992-Mar-01
Included in the Prior Art Database: 2005-Mar-22
Document File: 4 page(s) / 168K

Publishing Venue

IBM

Related People

Brenner, LB: AUTHOR

Abstract

A method for automatic generation of assembly language DSECTs to map C language structures or selected fields thereof is described. Use of generated DSECTs eliminates program failures associated with the difficult task of maintaining bilingual applications.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 36% of the total text.

Automatic Generation of Assembler Language DSECTs to Match C Structures

       A method for automatic generation of assembly language
DSECTs to map C language structures or selected fields thereof is
described.  Use of generated DSECTs eliminates program failures
associated with the difficult task of maintaining bilingual
applications.

      A definition language for the convenient writing of assembler
language DSECTs based on C language structures is described.  The C
DSECT generation language consists of several pseudo-code statements
including:
      DSECT   - to start the dsect definition,
      DSEND   - to complete the dsect definition,
      DS      - to "export" the definition of a storage occupying
structure element into the dsect,
      EQU     - to "export" the definition of useful self-defining
terms,
      DEF     - to "export" a #defined value directly,
      BFBIT   - to "export" the definition of a bit field, and
      COMMENT - to add commentary to the generated dsect.

      The key thing to note about these statements is that all the
programmer provides are the names of the fields he needs.  The
implemented tool automatically determines the attributes (for DS,
offset and length; for BFBIT, byte offset and bit mask; for EQU and
DEF, value) of the fields, and produces a DSECT suitable for
inclusion in an assembler language routine.  Any field so exported is
guaranteed correct in the particular programming "environment" in
use.

      Note that this "pseudo" dsect is not actually written in the
assembler language of any machine platform.  It is written in C to
resemble IBM 370 assembly language.  The actual ability to export
details from a structure to assembler routines is machine
independent.  All that would be required to use the same structure on
another hardware platform are different internal C functions to
generate in the assembler language of that platform from the C macros
defined here.

      The actual working of the macros is fairly straightforward.
The generation program #defines the structure being mapped as BLOCK,
and whether BLOCK is a structure or a union as STRUCT (which defaults
to "struct"). In the descriptions below, wherever "X" appears, it
represents the substituted value of a macro parameter names C.  The
basic C macros then work as follows: DSECT(A)

      Passes the string "A" to the dsect statement routine. This
routine just prints a standard top of dsect sequence:
      #ifndef_d_"A"
      #define_d_"A"
      ***This is a generated dsect.  Do not update it.***
      ***Update the source from which it is generated.***
      "A"  dsect
DSEND

      This macro just prints a standard bottom of dsect sequence:
      #endif
      and exits via exit(0).
DS(A,C,COMMENT)

      This macro calls the ds routine, passing it:
      1.   the string "A", which is the name of...