home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / LANGUAGE / BPASCAL / TASMEXMP.ZIP / DLLPROG.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-03-09  |  3.0 KB  |  88 lines

  1. ; Turbo Assembler    Copyright (c) 1988, 1993 By Borland International, Inc.
  2.  
  3. ; DLLPROG.ASM - Template for writing .DLL files.
  4.  
  5. ; From the Turbo Assembler Users Guide
  6.  
  7. P286               ;286 processor; the minimum if we're writing
  8.                    ; for protected mode
  9. WARN PRO           ;enable protected mode warning
  10. MODEL LARGE
  11.  
  12. ;Include files
  13. INCLUDE WINDOWS.INC      ;WINDOWS.INC contains assembly language
  14.                          ; definitions for Windows data types, etc.
  15.  
  16. DATASEG
  17.    ;<<Initialized data goes here>>
  18.  
  19. UDATASEG
  20.    ;<<Uninitialized data goes here>>
  21.  
  22. CODESEG
  23. ;----------------------------------------------------------------------
  24. ;Dynamic link library initialization procedure.
  25. ;LibMain is called to initialize the DLL library routines in module.
  26. ;This routine should return a 1 in AX if the library is
  27. ;successfully initialized, 0 otherwise.
  28. ;----------------------------------------------------------------------
  29. LibMain PROC PASCAL FAR
  30. PUBLIC  PASCAL LibMain
  31. ARG     @@hInstance:WORD,   \Descriptor for instance of application
  32.    @@wDataSeg:WORD,         \Library's data segment
  33.    @@wHeapSize:WORD,        \Heap size
  34.    @@lpszCmdLine:DWORD      ;pointer to command line
  35. USES ES,SI,DI
  36.    ;<<User code that initializes library goes here>>
  37.    MOV AX,1                 ;signals successful initialization
  38.    RET
  39. LibMain ENDP
  40.  
  41. ;----------------------------------------------------------------------
  42. ;Dynamic link library de-initialization procedure.
  43. ;This routine is optional.
  44. ;The example here does nothing; it is included as a guide.
  45. ;Returns AX=1 if deinitialization was successful
  46. ;----------------------------------------------------------------------
  47. WEP PROC  WINDOWS PASCAL FAR
  48. PUBLICDLL PASCAL WEP
  49. ARG       @@nParameter      ;parameter; specifies situation in which
  50.                             ; WEP is called
  51. USES ES,SI,DI
  52.    ;<<De-initialization code goes here>>
  53.    MOV AX,1                 ;signals successful de-initialization
  54.    RET
  55. WEP ENDP
  56.  
  57. ;----------------------------------------------------------------------
  58. ;Dynamic Link Library Routines.
  59. ;All user-defined library routines must be declared as PASCAL FAR
  60. ;procedures, and must be published using the PUBLICDLL directive.
  61. ;The arguments passed to and returned from DLL procedures are
  62. ;determined entirely by the programmer.
  63. ;----------------------------------------------------------------------
  64. ;[SetHello]
  65. ;Copy string 'Hello, Windows from dllprog.dll!' into a buffer.
  66. ;Pass address of buffer.
  67. ;Return length of string in AX.
  68. PUBLICDLL PASCAL SETHELLO
  69. SETHELLO  PROC WINDOWS PASCAL FAR
  70. ARG       @@lpszParam:DWORD         ;storage for string
  71. USES ES,SI,DI
  72.    ;<<User code goes here - here's an example:>>
  73.  
  74.    DATASEG
  75. @@Hello   DB 'Welcome to Windows from Assembly: Press LButton ',0
  76. @@HSize = $-@@Hello
  77.    CODESEG
  78.    MOV SI,OFFSET @@Hello
  79.    LES DI,@@lpszParam
  80.    MOV CX,@@Hsize
  81.    CLD
  82.    REP MOVSB
  83.    MOV AX,@@Hsize-1
  84.    RET
  85. SETHELLO ENDP
  86. END
  87.  
  88.