Guide to the HP Structure Definition Language


Previous Contents Index

The HP MACRO output routine produces declarations that can generate either local symbol or global symbol definitions. The following is an example of HP SDL source code:


MODULE simple; 
 CONSTANT bits EQUALS 4; 
 ITEM field BYTE PREFIX tst$ COMMON; 
END_MODULE; 

The following is the resulting HP MACRO output:


  .MACRO simple,..EQU=<=>,..COL=<:> 
bits'..equ'4 
  .SAVE 
  .PSECT tst$b_field PIC,OVR,REL,GBL,- 
                     SHR,NOEXE,RD,WRT,LONG 
tst$b_field'..col'  <P>lkb 1 
  .RESTORE 
; tst$b_field'..equ'0 
  .ENDM 

When the macro is invoked without arguments, the resulting local definitions are as follows:


bits = 4 
tst$b_field1: 
 blkb 1 

To generate these names as global symbols, invoke the macro with the arguments <= => and <::>, as follows:


 simple ..EQU=<==> ..COL=<::> 

This invocation results in the following definitions:


bits == 4 
tst$b_field1:: 
 blkb 1 

The HP MACRO output routine always generates a size variable for bitfields, aggregates, arrays, and character strings, using the tag S_ preceding the output identifier.

The /VMS_DEVELOPMENT qualifier on the SDL command produces special forms of macros for entry point declarations.

Note

  1. Each identifier produces a constant assignment equal to the byte offset of the item, as follows:

    name = offset-value 
    


    Offset-value is the byte offset relative to the origin of the level-1 aggregate. A constant assignment of the following form gives the size in bytes for aggregates, arrays, and character strings:

    prefix$_name = byte-size 
    

  2. If /VMS_DEVELOPMENT was specified, the CONSTANT x EQUALS STRING "s" declaration translates to the following:


    .SAVE 
    .PSECT  module_name_STRCONST PIC,CON,REL,NOEXE,GBL,SHR,RD,NOWRT,LONG 
    $EQU  S_x size
    $DEF x .ASCII /s/ 
    .RESTORE 
    

    If /NOVMS_DEVELOPMENT was specified (default), this declaration translates to the following:


    .SAVE 
    .PSECT  module_name STRCONST PIC,CON,REL,NOEXE,GBL,SHR,RD,NOWRT,LONG 
    S_x ..equ'size
    x'..col' .ASCII /s/ 
    .RESTORE 
    

    where size represents the number of bytes in the string.
    Note:


HP Pascal Translation Summary

The following table shows the HP SDL to HP Pascal language translation summary.
HP SDL Declaration HP Pascal Output
MODULE name IDENT string (*** MODULE name IDENT string ***)
  Note that when /MODULE is used, a HP Pascal MODULE statement of the form MODULE name; is generated.
/* comment (* comment *)
CONSTANT x  
EQUALS n; CONST x = n;
EQUALS STRING "s"; CONST x = 's';
ENTRY [ASYNCHRONOUS] FUNCTION
  [ASYNCHRONOUS] PROCEDURE
PARAMETER (type,...) (formal param_list)
ANY %REF param-name: [UNSAFE] ARRAY [$l1..$u1:INTEGER] OF $UBYTE
DESCRIPTOR [CLASS_S] for scalars;
  [CLASS_S] for CHARACTER LENGTH 1;
  [CLASS_A] for nonscalars;
  %DESCR for fixed-length VARYING;
RTL_STR_DESC PACKED ARRAY [$l1..$u1:INTEGER] OF CHAR;
IN Default semantics (unless overridden by OUT)
OUT (or IN OUT) VAR, except for CHARACTER LENGTH * and ANY (which generate %REF)
NAMED param-name Parameter name. If none is given, names will be generated of the form $P1,...$Pn.
VALUE %IMMED
REFERENCE %REF for CHARACTER LENGTH * and ANY; VAR for all others if mode OUT or IN OUT; otherwise (IN only) default mechanism
DEFAULT n := %IMMED value
LIST If OPTIONAL is not specified, generates one required parameter followed by a parameter with the [LIST] attribute; if OPTIONAL is specified, only the parameter with [LIST] is generated.
OPTIONAL :=%IMMED 0
TYPENAME type-name n/a
RETURNS return-data-type FUNCTION name : data-type;
NAMED param-name n/a
VARIABLE n/a
ALIAS internal-name Results in [EXTERNAL (entry-name)] and internal-name being used as entry-name
LINKAGE n/a
TYPENAME type-name n/a
STRUCTURE RECORD
UNION RECORD CASE INTEGER OF
  0: ...
  .
  .
  n: ...
BYTE [SIGNED ] $BYTE--- [BYTE ] -128..127
INTEGER _BYTE [SIGNED ] $BYTE--- [BYTE ] -128..127
WORD [SIGNED ] $WORD--- [WORD ] -32768..32767
INTEGER _WORD [SIGNED ] $WORD--- [WORD ] -32768..32767
LONGWORD [SIGNED ] INTEGER
INTEGER _LONG [SIGNED ] INTEGER
INTEGER [SIGNED ] INTEGER
INTEGER _HW [SIGNED ] $QUAD--- [QUAD,UNSAFE ]RECORD L0: UNSIGNED; L1: INTEGER; END for /ALPHA
  INTEGER for /VAX
HARDWARE _INTEGER [SIGNED ] $QUAD for /ALPHA
  $QUAD for /ALPHA, INTEGER for /VAX
QUADWORD [SIGNED ] $QUAD
INTEGER _QUADWORD [SIGNED ] $QUAD
OCTAWORD [SIGNED ] $OCTA--- [OCTA,UNSAFE ]RECORD L0,L1,L2: UNSIGNED; L3: INTEGER; END
BYTE UNSIGNED $UBYTE--- [BYTE ] 0..255
INTEGER _BYTE UNSIGNED $UBYTE--- [BYTE ] 0..255
WORD UNSIGNED $UWORD--- [WORD ] 0..65535
INTEGER _WORD UNSIGNED $UWORD--- [WORD ] 0..65535
LONGWORD UNSIGNED UNSIGNED
INTEGER _LONG UNSIGNED UNSIGNED
INTEGER UNSIGNED UNSIGNED
INTEGER _HW UNSIGNED $UQUAD--- [QUAD,UNSAFE ]RECORD L0,L1: UNSIGNED; END for /ALPHA
  INTEGER for /VAX
HARDWARE _INTEGER UNSIGNED $UQUAD for /ALPHA
  INTEGER for /VAX
QUADWORD UNSIGNED $UQUAD
INTEGER _QUADWORD UNSIGNED $UQUAD
OCTAWORD UNSIGNED $UOCTA--- [OCTA,UNSAFE ]RECORD L0,L1,L2,L3: UNSIGNED; END
F_FLOATING SINGLE
D _FLOATING DOUBLE (D _FLOAT $ $TYPE if the logical name SDLPASCAL $FLAG is defined)
G _FLOATING DOUBLE (G _FLOAT $ $TYPE if the logical name SDLPASCAL $FLAG is defined)
H_FLOATING QUADRUPLE
F_FLOATING COMPLEX $UQAD
D_FLOATING COMPLEX $UOCTA
G_FLOATING COMPLEX $UOCTA
H_FLOATING COMPLEX $UOCTAQUAD --[OCTA(2),UNSAFE]RECORD L0,L1,L3,L4,L5,L6,L7:UNSIGNED; END;
DECIMAL PRECISION (p,q) PACKED ARRAY [1..p+2-mod(p,2)] OF $PACKED_DEC
  $PACKED_DEC---[BIT(4),UNSAFE] 0..15
BITFIELD LENGTH n $BIT1---[BIT(1), UNSAFE] BOOLEAN
  $BIT n---[BIT( n),UNSAFE] 0..2**n-1
MASK CONST prefixM_name = mask-value;
SIGNED n/a
CHARACTER CHAR
LENGTH n PACKED ARRAY [1..n] OF CHAR
LENGTH * PACKED ARRAY [$l..$u] OF CHAR
  or VARYING [$m] OF CHAR (if VARYING is also specified)
VARYING VARYING [n] OF CHAR
  or VARYING [$m] OF CHAR (if LENGTH * is also specified)
ADDRESS (object-type) ^object-type
  If object type is not supplied, generates $DEFPTR, which is defined as ^ $DEFTYP; $DEFTYP is defined as [UNSAFE ] INTEGER
POINTER (object-type) ^object-type
  If object type is not supplied, generates UNSIGNED
POINTER _LONG (object-type) ^object-type
  If object type is not supplied, generates UNSIGNED
POINTER _HW (object-type) $QUAD for /ALPHA
  INTEGER for /VAX
HARDWARE _ADDRESS (object-type) $QUAD for /ALPHA
  INTEGER for /VAX
POINTER _QUAD (object-type) $QUAD
BOOLEAN BOOLEAN
user-type-name user-type-name
Default storage class TYPE
COMMON storage class [COMMON]
GLOBAL storage class [EXTERNAL]
with /GLOBALDEF [GLOBAL]
BASED pointer-name TYPE pointer-name = structure-name
TYPEDEF n/a
name DIMENSION [lbound:]hbound ARRAY [lbound..hbound] OF data type; if lbound is not supplied, it defaults to 1
ORIGIN member-name n/a

Notes

  1. When the /MODULE (default) qualifier is used, HP SDL generates the HP Pascal MODULE statement followed by a block of data type definitions. Both of these items are omitted when /NOMODULE is specified. This behavior facilitates combining multiple HP SDL-generated HP Pascal output files into a single module.
  2. Where type names are required (for example, in parameter lists, function return types, and pointer data types), they will be generated in a TYPE block at the beginning of the module. Names have the form module-name$$TYPn, where module-name is truncated to 20 characters if necessary, and n is an integer beginning at 1 and incremented by 1 for each type generated in a module.
  3. Bitfields cannot be more than 32 bits in length, so type names giving the appropriate subranges will be generated for each possible bitfield size. Bitfields of length 1 are a special case.
  4. The mask-value generated by HP SDL for the MASK option of the BITFIELD data type is an integer.
  5. HP SDL generates only single-level records for HP Pascal. Thus, you can avoid writing many long intermediate field names in the HP Pascal source program. If the outer level is a structure, a PACKED RECORD is typically declared. If the outer level is a union, a PACKED RECORD CASE INTEGER is declared.
    In the case of multiple levels of structures or unions in HP SDL, the entire aggregate is transformed into a PACKED RECORD CASE INTEGER. The intermediate field-names are themselves declared as BYTE_DATA fields. This translation scheme may result in several fields in the record having the same name.


Previous Next Contents Index