home *** CD-ROM | disk | FTP | other *** search
- extrn __AHSHIFT : word
-
- DGROUP group _NULL,_DATA,CONST,STRINGS,DATA,XIB,XI,XIE,_emu_init_start,_emu_init,_emu_init_end,_BSS
-
- public pLocalHeap
- public pAtomTable
- public pStackTop
- public pStackMin
- public pStackBot
-
- pLocalHeap equ 0006H
- pAtomTable equ 0008H
- pStackTop equ 000AH
- pStackMin equ 000CH
- pStackBot equ 000EH
-
-
- DOSSEG
- memS equ 1
-
- .xlist
- include cmacros.inc
- include windows.inc
- .list
-
- FAR_DATA segment byte public 'FAR_DATA'
- FAR_DATA ends
-
- _BSS segment word public 'BSS'
- _BSS ends
-
- DATA segment word public 'DATA'
- DATA ends
-
- CONST segment word public 'DATA'
- CONST ends
-
- STRINGS segment word public 'DATA'
- STRINGS ends
-
- XIB segment word public 'DATA'
- xistart label byte
- XIB ends
- XI segment word public 'DATA'
- XI ends
- XIE segment word public 'DATA'
- xiend label byte
- XIE ends
-
- _emu_init_start segment word public 'EMU'
- __emu_init_start label word
- _emu_init_start ends
-
- _emu_init segment byte public 'EMU'
- _emu_init ends
-
- _emu_init_end segment word public 'EMU'
- __emu_init_end label word
- _emu_init_end ends
-
- _NULL segment para public 'BEGDATA'
- __nullarea label word
- dw 0,0
- dw 5
- dw 0 ; pLocalHeap
- dw 0 ; pAtomTable
- __STACKLOW dw 0 ; pStackTop: lowest address in stack
- __STACKTOP dw 0 ; pStackMin:
- dw 0 ; pStackBot: highest address in stack
- public __nullarea
- _NULL ends
-
- _DATA segment word public 'DATA'
- ;*
- ;*** externals we need
- ;*
- assume es:nothing
- assume ss:nothing
- assume ds:dgroup
- assume cs:_TEXT
-
- __aaltstkovr dw -1 ; alternate stack overflow routine address
- __dynend dw 0 ; top of dynamic data area
- __curbrk dw 0 ; top of usable memory
- __psp dw 0 ; segment addr of program segment prefix
- __osmajor db 0 ; major DOS version number
- __osminor db 0 ; minor DOS version number
- __osmode db 0 ; 0 => DOS real mode
- __HShift db 0 ; Huge Shift value
- __cbyte dw 0 ; used by getch, getche
- __child dw 0 ; non-zero => a spawned process is running
- __no87 dw 0 ; always try to use the 8087
- __get_ovl_stack dw 0,0 ; get overlay stack pointer
- __restore_ovl_stack dw 0,0 ; restore overlay stack pointer
- __FPE_handler label dword
- ___FPE_handler dw 0,0 ; FPE handler
- __LpCmdLine dw 0,0 ; lpCmdLine (for _argc, _argv processing)
- db 0 ; slack byte
-
- public __dynend
- public __curbrk
- public __psp
- public __osmajor
- public __osminor
- public __osmode
- public __STACKLOW
- public __STACKTOP
- public __cbyte
- public __child
- public __no87
- public __HShift
- public __get_ovl_stack
- public __restore_ovl_stack
- public __FPE_handler
- public ___FPE_handler
- public __LpCmdLine
-
- _DATA ends
-
- externFP <LocalInit> ; Windows heap init routine
- externFP <__FInitRtns> ; initializer
-
- _TEXT segment word public 'CODE'
-
- public _large_code_
- _large_code_ equ 0
-
- ;****************************************************************************
- ;*** ***
- ;*** LibEntry - 16-bit library entry point ***
- ;*** ***
- ;****************************************************************************
- externFP <LibMain> ; startup code
- cProc LibEntry, <PUBLIC,FAR> ; entry point into DLL
-
- cBegin
- push di ; handle of the module instance
- push ds ; library data segment
- push cx ; heap size
- push es ; command line segment
- push si ; command line offset
- jcxz callc ; skip heap init
- xor ax,ax
- cCall LocalInit <ds, ax, cx>
- or ax,ax ; did it do it ok ?
- jz error ; quit if it failed
-
- callc:
- mov ax,offset __AHSHIFT ; get huge shift value
- mov __HShift,al ; ...
- cmp al,12 ; real mode?
- je notprot ; yes, so leave osmode alone
- mov al,1
- mov __osmode,al ; protected mode!
- notprot:
- call __FInitRtns ; call initializer routines
- call LibMain ; invoke the 'C' routine (result in AX)
- jmp short exit ; LibMain is responsible for stack clean up
-
- error:
-
- pop si ; clean up stack on a LocalInit error
- pop es
- pop cx
- pop ds
- pop di
- jmp short exit
-
- __exit_:
- public __exit_with_msg_
- public __exit_
-
- ; input: DX:AX - far pointer to message to print
- ; BX - exit code
-
- __exit_with_msg_:
- mov ah,04cH ; DOS call to exit with return code
- int 021h ; back to DOS
-
- exit:
- cEnd
-
- _TEXT ends
- end LibEntry
-