Writing your Language Environment-conforming assembler DLL code

To build a simple assembler DLL, your assembler routine must conform to Language Environment conventions. To do this, begin by using the Language Environment® macros CEEENTRY and CEETERM. The EXPORT= keyword parameter on the CEEENTRY macro allows you to identify specific assembler entry points for export. The CEEPDDA macro allows you to define data in your assembler routine that can be exported. Details on all Language Environment assembler macros are in Assembler macros.

Figure 1 shows how to use Language Environment macros to create an Assembler DLL. The CEEENTRY prolog macro has EXPORT=YES specified to mark this entry point exported. In this particular case we want the exported function known externally in lower case, so the CEEENTRY is followed by an assembler ALIAS statement. The ALIAS can be used to "name" the exported function with a mixed-case name up to 256 characters long. This assembler DLL also has two exported variables, "DllVar" (initial value = 123) and "DllStr" (initial value is the C string "Hello World"). When the exported function "dllfunc" is called, it sets "DllVar" to 456 and truncates the "DllStr" C string to "Hello".

Figure 1. Using Language Environment macros to create an assembler DLL executable named ADLLBEV2
DLLFUNC  CEEENTRY MAIN=NO,PPA=DLLPPA,EXPORT=YES
DLLFUNC  ALIAS C'dllfunc'
*        Symbolic Register Definitions and Usage
R8       EQU   8             Work register
R9       EQU   9             Work register
R15      EQU   15            Entry point address
*
         WTO   'ADLLBEV2: Exported function dllfunc entered',ROUTCDE=11
*
         WTO   'ADLLBEV2: Setting DllVar to 456',ROUTCDE=11
*
         CEEPLDA DllVar,REG=9
         LA    R8,456
         ST    R8,0(R9)
*
         WTO   'ADLLBEV2: Truncating exported string to "Hello"',      X
               ROUTCDE=11
*
         CEEPLDA DllStr,REG=9
         LA    R8,0
         STC   R8,5(R9)
*
         WTO   'ADLLBEV2: Done.',ROUTCDE=11
*
         SR    R15,R15
RETURN   DS   0H
         CEETERM  RC=(R15),MODIFIER=0
*
         CEEPDDA DllVar,SCOPE=EXPORT
         DC      A(123)
         CEEPDDA END
         CEEPDDA DllStr,SCOPE=EXPORT
         DC      C'Hello World'
         DC      X'00'
         CEEPDDA END
*
DLLPPA   CEEPPA
         CEEDSA
         CEECAA
         END      DLLFUNC