home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c496 / 4.img / FILEDLL.WEX / LIBENTRY.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-08-20  |  4.8 KB  |  185 lines

  1.     extrn    __AHSHIFT    : word
  2.  
  3.  DGROUP group _NULL,_DATA,CONST,STRINGS,DATA,XIB,XI,XIE,_emu_init_start,_emu_init,_emu_init_end,_BSS
  4.  
  5. public  pLocalHeap
  6. public  pAtomTable
  7. public  pStackTop
  8. public  pStackMin
  9. public  pStackBot
  10.  
  11. pLocalHeap      equ     0006H
  12. pAtomTable      equ     0008H
  13. pStackTop       equ     000AH
  14. pStackMin       equ     000CH
  15. pStackBot       equ     000EH
  16.  
  17.  
  18.     DOSSEG
  19. memS    equ     1
  20.  
  21.     .xlist
  22.     include cmacros.inc
  23.     include windows.inc
  24.     .list
  25.  
  26. FAR_DATA segment byte public 'FAR_DATA' 
  27. FAR_DATA ends
  28.  
  29. _BSS          segment word public 'BSS' 
  30. _BSS          ends
  31.  
  32. DATA    segment word public 'DATA' 
  33. DATA    ends
  34.  
  35. CONST    segment word public 'DATA'
  36. CONST    ends
  37.  
  38. STRINGS segment word public 'DATA'
  39. STRINGS ends
  40.  
  41. XIB    segment word public 'DATA'
  42. xistart label    byte
  43. XIB    ends
  44. XI    segment word public 'DATA'
  45. XI    ends
  46. XIE    segment word public 'DATA'
  47. xiend    label    byte
  48. XIE    ends
  49.  
  50. _emu_init_start segment word public 'EMU' 
  51. __emu_init_start label word
  52. _emu_init_start ends
  53.  
  54. _emu_init segment byte public 'EMU' 
  55. _emu_init ends
  56.  
  57. _emu_init_end segment word public 'EMU' 
  58. __emu_init_end label word
  59. _emu_init_end ends
  60.  
  61. _NULL   segment para public 'BEGDATA' 
  62. __nullarea label word
  63.        dw   0,0
  64.        dw   5
  65.        dw   0               ; pLocalHeap
  66.        dw   0               ; pAtomTable
  67. __STACKLOW dw   0               ; pStackTop: lowest address in stack
  68. __STACKTOP dw   0               ; pStackMin:
  69.        dw   0               ; pStackBot: highest address in stack
  70.     public  __nullarea
  71. _NULL   ends
  72.  
  73. _DATA segment word public 'DATA' 
  74. ;*
  75. ;*** externals we need
  76. ;*
  77. assume es:nothing
  78. assume ss:nothing
  79. assume ds:dgroup
  80. assume cs:_TEXT
  81.  
  82. __aaltstkovr dw -1        ; alternate stack overflow routine address
  83. __dynend   dw 0         ; top of dynamic data area
  84. __curbrk   dw 0         ; top of usable memory
  85. __psp       dw 0         ; segment addr of program segment prefix
  86. __osmajor  db 0         ; major DOS version number
  87. __osminor  db 0         ; minor DOS version number
  88. __osmode   db 0         ; 0 => DOS real mode
  89. __HShift   db 0         ; Huge Shift value
  90. __cbyte    dw 0         ; used by getch, getche
  91. __child    dw 0         ; non-zero => a spawned process is running
  92. __no87       dw 0         ; always try to use the 8087
  93. __get_ovl_stack dw 0,0        ; get overlay stack pointer
  94. __restore_ovl_stack dw 0,0    ; restore overlay stack pointer
  95.  __FPE_handler label dword
  96. ___FPE_handler dw 0,0        ; FPE handler
  97. __LpCmdLine dw 0,0        ; lpCmdLine (for _argc, _argv processing)
  98.        db 0                 ; slack byte
  99.        
  100.     public    __dynend
  101.     public    __curbrk
  102.     public    __psp
  103.     public    __osmajor
  104.     public    __osminor
  105.     public    __osmode
  106.     public    __STACKLOW
  107.     public    __STACKTOP
  108.     public    __cbyte
  109.     public    __child
  110.     public    __no87
  111.     public    __HShift
  112.     public    __get_ovl_stack
  113.     public    __restore_ovl_stack
  114.     public     __FPE_handler
  115.     public    ___FPE_handler
  116.     public    __LpCmdLine
  117.  
  118. _DATA ends
  119.  
  120. externFP <LocalInit>        ; Windows heap init routine
  121. externFP <__FInitRtns>        ; initializer
  122.  
  123. _TEXT segment word public 'CODE' 
  124.  
  125. public          _large_code_
  126. _large_code_    equ 0
  127.  
  128. ;****************************************************************************
  129. ;***                                                                      ***
  130. ;*** LibEntry - 16-bit library entry point                                ***
  131. ;***                                                                      ***
  132. ;****************************************************************************
  133. externFP <LibMain>               ; startup code
  134. cProc   LibEntry, <PUBLIC,FAR>   ; entry point into DLL
  135.  
  136. cBegin
  137.     push    di               ; handle of the module instance
  138.     push    ds               ; library data segment
  139.     push    cx               ; heap size
  140.     push    es               ; command line segment
  141.     push    si               ; command line offset
  142.     jcxz    callc            ; skip heap init
  143.     xor     ax,ax
  144.     cCall   LocalInit <ds, ax, cx>
  145.     or      ax,ax            ; did it do it ok ?
  146.     jz      error            ; quit if it failed
  147.  
  148. callc:
  149.     mov    ax,offset __AHSHIFT ; get huge shift value
  150.     mov    __HShift,al    ; ...
  151.     cmp    al,12        ; real mode?
  152.     je    notprot        ; yes, so leave osmode alone
  153.     mov    al,1
  154.     mov    __osmode,al    ; protected mode!
  155. notprot:
  156.     call    __FInitRtns    ; call initializer routines
  157.     call    LibMain        ; invoke the 'C' routine (result in AX)
  158.     jmp    short exit    ; LibMain is responsible for stack clean up
  159.  
  160. error:
  161.  
  162.     pop     si               ; clean up stack on a LocalInit error
  163.     pop     es               
  164.     pop     cx               
  165.     pop     ds
  166.     pop     di
  167.     jmp     short exit
  168.     
  169. __exit_:
  170.     public    __exit_with_msg_
  171.     public    __exit_
  172.  
  173. ; input: DX:AX - far pointer to message to print
  174. ;     BX    - exit code
  175.  
  176. __exit_with_msg_:
  177.     mov     ah,04cH                 ; DOS call to exit with return code
  178.     int     021h                    ; back to DOS
  179.  
  180. exit:
  181. cEnd
  182.  
  183. _TEXT    ends
  184.     end    LibEntry
  185.