An assembler subprogram that obeys the standard COBOL calling convention takes the following form:
The assembler subprogram can consist of multiple code and data segments. You should ensure that the initial code entry point is at the start of the first code segment defined or alternatively that you explicitly define the entry point label after the End directive.
LIBRARY libname EXPORTS entry-point-name @1
;--------------------------------------------------------- ; Example skeleton assembler subprogram ;--------------------------------------------------------- ;--------------------------------------------------------- ; Declare local data segment(s) ;--------------------------------------------------------- .386 .MODEL FLAT ; _DATA segment dword use32 public 'DATA' ... data used by subprogram ... _DATA ends ;--------------------------------------------------------- ; Declare local code segment(s) ;--------------------------------------------------------- _TEXT segment dword use32 public 'CODE' assume cs:flat, ds:flat, ss:flat, es:flat ;--------------------------------------------------------- ; Declare public entry point ;--------------------------------------------------------- PUBLIC EXAMPLE ;--------------------------------------------------------- ; Declare equates for accessing params(COBOL convention) ;--------------------------------------------------------- param1 equ ebp+8 param2 equ ebp+12 EXAMPLE proc near push ebp ; preserve ebp mov ebp,esp ; address params on stack push esi ; preserve esi, edi push edi ... program code ... mov esi,[param1] ; access parameter 1 ... mov esi,[param2] ; access parameter 2 ... mov eax,{return-code} ; set up ; return code ... pop edi pop esi ; restored esi,edi pop ebp ; restored ebp ret EXAMPLE endp _TEXT ends end