home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 21.ddi / START16.PAK / C0.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-12-02  |  25.6 KB  |  746 lines

  1. ;[]------------------------------------------------------------[]
  2. ;|      C0.ASM -- Start Up Code for DOS                         |
  3. ;[]------------------------------------------------------------[]
  4.  
  5. ;
  6. ;       C/C++ Run Time Library - Version 6.0
  7. ;       Copyright (c) 1987, 1992 by Borland International
  8. ;       All Rights Reserved.
  9.  
  10.                 locals
  11.  
  12.                 __C0__ = 1
  13. INCLUDE         RULES.ASI
  14.  
  15. ;       Segment and Group declarations
  16.  
  17. _TEXT           SEGMENT BYTE PUBLIC 'CODE'
  18.                 ENDS
  19. _FARDATA        SEGMENT PARA PUBLIC 'FAR_DATA'
  20.                 ENDS
  21. _FARBSS         SEGMENT PARA PUBLIC 'FAR_BSS'
  22.                 ENDS
  23. IFNDEF __TINY__
  24. _OVERLAY_       SEGMENT PARA PUBLIC 'OVRINFO'
  25.         ENDS
  26. _1STUB_     SEGMENT PARA PUBLIC 'STUBSEG'
  27.         ENDS
  28. ENDIF
  29. _DATA           SEGMENT PARA PUBLIC 'DATA'
  30.                 ENDS
  31. _INIT_          SEGMENT WORD PUBLIC 'INITDATA'
  32. InitStart       label byte
  33.                 ENDS
  34. _INITEND_       SEGMENT BYTE PUBLIC 'INITDATA'
  35. InitEnd         label byte
  36.                 ENDS
  37. _EXIT_          SEGMENT WORD PUBLIC 'EXITDATA'
  38. ExitStart       label byte
  39.                 ENDS
  40. _EXITEND_       SEGMENT BYTE PUBLIC 'EXITDATA'
  41. ExitEnd         label byte
  42.                 ENDS
  43. _CVTSEG         SEGMENT WORD PUBLIC 'DATA'
  44.                 ENDS
  45. _SCNSEG         SEGMENT WORD PUBLIC 'DATA'
  46.                 ENDS
  47. IFNDEF __HUGE__
  48.   _BSS          SEGMENT WORD PUBLIC 'BSS'
  49.                 ENDS
  50.   _BSSEND       SEGMENT BYTE PUBLIC 'BSSEND'
  51.                 ENDS
  52. ENDIF
  53. IFNDEF __TINY__
  54.   _STACK        SEGMENT STACK 'STACK'
  55.                 ENDS
  56. ENDIF
  57.  
  58.         ASSUME  CS:_TEXT, DS:DGROUP
  59.  
  60. ;       External References
  61.  
  62. extrn       _main:DIST
  63. extrn       _exit:DIST
  64. extrn       __exit:DIST
  65. extrn       __abort:DIST
  66. extrn       __ExceptInit:DIST
  67. extrn       ___ErrorMessage:DIST
  68. extrn       __nfile:word
  69. extrn       __setupio:near          ;required!
  70. extrn       __stklen:word
  71. IF LDATA  EQ  false
  72. extrn       __heaplen:word
  73. ENDIF
  74.  
  75.         SUBTTL  Start Up Code
  76.         PAGE
  77. ;/*                                                     */
  78. ;/*-----------------------------------------------------*/
  79. ;/*                                                     */
  80. ;/*     Start Up Code                                   */
  81. ;/*     -------------                                   */
  82. ;/*                                                     */
  83. ;/*-----------------------------------------------------*/
  84. ;/*                                                     */
  85. PSPHigh         equ     00002h
  86. PSPEnv          equ     0002ch
  87. PSPCmd          equ     00080h
  88.  
  89.                 public  __AHINCR
  90.                 public  __AHSHIFT
  91. __AHINCR        equ     1000h
  92. __AHSHIFT       equ     12
  93.  
  94. IFDEF   __NOFLOAT__
  95. MINSTACK        equ     128     ; minimal stack size in words
  96. ELSE
  97. MINSTACK        equ     256     ; minimal stack size in words
  98. ENDIF
  99. ;
  100. ;       At the start, DS and ES both point to the segment prefix.
  101. ;       SS points to the stack segment except in TINY model where
  102. ;       SS is equal to CS
  103. ;
  104. _TEXT           SEGMENT
  105. IFDEF           __TINY__
  106.                 ORG     100h
  107. ENDIF
  108. STARTX          PROC    NEAR
  109. ;       Save general information, such as :
  110. ;               DGROUP segment address
  111. ;               DOS version number
  112. ;               Program Segment Prefix address
  113. ;               Environment address
  114. ;               Top of far heap
  115.  
  116. IFDEF   __TINY__
  117.                 mov     dx, cs          ; DX = GROUP Segment address
  118. ELSE
  119.                 mov     dx, DGROUP      ; DX = GROUP Segment address
  120. ENDIF
  121.                 mov     cs:DGROUP@@, dx ;
  122.                 mov     ah, 30h
  123.                 int     21h             ; get DOS version number
  124.                 mov     bp, ds:[PSPHigh]; BP = Highest Memory Segment Addr
  125.                 mov     bx, ds:[PSPEnv] ; BX = Environment Segment address
  126.                 mov     ds, dx
  127.                 mov     _version@, ax   ; Keep major and minor version number
  128.                 mov     _psp@, es       ; Keep Program Segment Prefix address
  129.                 mov     _envseg@, bx    ; Keep Environment Segment address
  130.                 mov     word ptr _heaptop@ + 2, bp
  131. ;
  132. ;       Save several vectors and install default divide by zero handler.
  133. ;
  134.                 call    SaveVectors
  135.  
  136.  
  137. ;       Count the number of environment variables and compute the size.
  138. ;       Each variable is ended by a 0 and a zero-length variable stops
  139. ;       the environment. The environment can NOT be greater than 32k.
  140.  
  141.                 mov     ax, _envseg@
  142.                 mov     es, ax
  143.                 xor     ax, ax
  144.                 mov     bx, ax
  145.                 mov     di, ax
  146.  
  147.                 mov     cx, 07FFFh      ; Environment cannot be > 32 Kbytes
  148.                 cld
  149. @@EnvLoop:
  150.                 repnz   scasb
  151.                 jcxz    InitFailed      ; Bad environment !!!
  152.  
  153.                 inc     bx              ; BX = Nb environment variables
  154.                 cmp     es:[di], al
  155.                 jne     @@EnvLoop       ; Next variable ...
  156.                 or      ch, 10000000b
  157.                 neg     cx
  158.                 mov     _envLng@, cx    ; Save Environment size
  159.                 mov     cx, dPtrSize / 2
  160.                 shl     bx, cl
  161.                 add     bx, dPtrSize * 4
  162.                 and     bx, not ((dPtrSize * 4) - 1)
  163.                 mov     _envSize@, bx   ; Save Environment Variables Nb.
  164.  
  165.  
  166. ;       Determine the amount of memory that we need to keep
  167.  
  168. IFDEF _DSSTACK_
  169.                 mov     dx, ds
  170. ELSE
  171.                 mov     dx, ss
  172. ENDIF
  173.                 sub     bp, dx          ; BP = remaining size in paragraphs
  174. IF LDATA
  175.                 mov     di, seg __stklen
  176.                 mov     es, di
  177.                 mov     di, es:__stklen ; DI = Requested stack size
  178. ELSE
  179.                 mov     di, __stklen    ; DI = Requested stack size
  180. ENDIF
  181. ;
  182. ; Make sure that the requested stack size is at least MINSTACK words.
  183. ;
  184.                 cmp     di, 2*MINSTACK  ; requested stack big enough ?
  185.                 jae     AskedStackOK
  186.                 mov     di, 2*MINSTACK  ; no --> use minimal value
  187. IF LDATA
  188.                 mov     es:__stklen, di ; override requested stack size
  189. ELSE
  190.                 mov        __stklen, di ; override requested stack size
  191. ENDIF
  192.  
  193. AskedStackOK    label   near
  194. IFDEF _DSSTACK_
  195.                 add     di, offset DGROUP: edata@
  196.                 jb      InitFailed      ; DATA segment can NOT be > 64 Kbytes
  197. ENDIF
  198. IF LDATA  EQ  false
  199.                 add     di, __heaplen
  200.                 jb      InitFailed      ; DATA segment can NOT be > 64 Kbytes
  201. ENDIF
  202.                 mov     cl, 4
  203.                 shr     di, cl          ; $$$ Do not destroy CL $$$
  204.                 inc     di              ; DI = DS size in paragraphs
  205.                 cmp     bp, di
  206. IF LDATA  EQ  false
  207.                 jb      InitFailed      ; Not enough memory
  208.                 cmp     __stklen, 0
  209.                 je      ExpandDS        ; Expand DS up to 64 Kb
  210.                 cmp     __heaplen, 0
  211.                 jne     ExcessOfMemory  ; Much more available than needed
  212. ExpandDS        label   near
  213.                 mov     di, 1000h
  214.                 cmp     bp, di
  215.                 ja      ExcessOfMemory  ; Enough to run the program
  216.                 mov     di, bp
  217.                 jmp     short ExcessOfMemory  ; Enough to run the program
  218. ELSE
  219.                 jnb     ExcessOfMemory  ; Much more available than needed
  220. ENDIF
  221.  
  222. ;       All initialization errors arrive here
  223.  
  224. InitFailed      label   near
  225.                 call    __abort
  226.  
  227. ;       Return to DOS the amount of memory in excess
  228. ;       Set far heap base and pointer
  229.  
  230. ExcessOfMemory  label   near
  231.                 mov     bx, di
  232.                 add     bx, dx
  233.                 mov     word ptr _heapbase@ + 2, bx
  234.                 mov     word ptr _brklvl@ + 2, bx
  235.                 mov     ax, _psp@
  236.                 sub     bx, ax          ; BX = Number of paragraphs to keep
  237.                 mov     es, ax          ; ES = Program Segment Prefix address
  238.                 mov     ah, 04Ah
  239.                 push    di              ; preserve DI
  240.                 int     021h            ; this call clobbers SI,DI,BP !!!!!!
  241.                 pop     di              ; restore  DI
  242.  
  243.                 shl     di, cl          ; $$$ CX is still equal to 4 $$$
  244.  
  245.                 cli                     ; req'd for pre-1983 88/86s
  246.                 mov     ss, dx          ; Set the program stack
  247.                 mov     sp, di
  248.                 sti
  249.  
  250. IFNDEF _DSSTACK_
  251.                 mov     ax, seg __stklen
  252.                 mov     es, ax
  253.                 mov     es:__stklen, di ; If separate stack segment, save size
  254. ENDIF
  255.  
  256.  
  257. IFNDEF  __HUGE__
  258.  
  259. ;       Reset uninitialized data area
  260.  
  261.                 xor     ax, ax
  262.                 mov     es, cs:DGROUP@@
  263.                 mov     di, offset DGROUP: bdata@
  264.                 mov     cx, offset DGROUP: edata@
  265.                 sub     cx, di
  266.                 cld
  267.                 rep     stosb
  268. ENDIF
  269.  
  270. ;   If default number of file handles have changed then tell DOS
  271.                 cmp     __nfile, 20
  272.                 jbe     @@NoChange
  273.  
  274.                 cmp     _osmajor@, 3   ; Check for >= DOS 3.3
  275.                 jb      @@NoChange
  276.                 ja      @@DoChange
  277.                 cmp     _osminor@, 1Eh
  278.                 jb      @@NoChange
  279. @@DoChange:
  280.                 mov     ax, 5801h      ; Set last fit allocation
  281.                 mov     bx, 2
  282.                 int     21h
  283.                 jc      @@BadInit
  284.  
  285.                 mov     ah, 67h        ; Expand handle table
  286.                 mov     bx, __nfile
  287.                 int     21h
  288.                 jc      @@BadInit
  289.  
  290.                 mov     ah, 48h        ; Allocate 16 bytes to find new
  291.                 mov     bx, 1          ;   top of memory address
  292.                 int     21h
  293.                 jc      @@BadInit
  294.                 inc     ax             ; Adjust address to point after block
  295.                 mov     word ptr _heaptop@ + 2, ax
  296.  
  297.                 dec     ax             ; Change back and release block
  298.                 mov     es, ax
  299.                 mov     ah, 49h
  300.                 int     21h
  301.                 jc      @@BadInit
  302.  
  303.                 mov     ax, 5801h      ; Set first fit allocation
  304.                 mov     bx, 0
  305.                 int     21h
  306.                 jnc     @@NoChange
  307.  
  308. @@BadInit:      call    __abort
  309.  
  310. @@NoChange:
  311.  
  312. ;       Prepare main arguments
  313.  
  314.                 xor     bp,bp                   ; set BP to 0 for overlay mgr
  315.  
  316.                 push    bp
  317.                 call    __ExceptInit
  318.                 pop     ax
  319.  
  320.                 mov     es, cs:DGROUP@@
  321.                 mov     si,offset DGROUP:InitStart      ;si = start of table
  322.                 mov     di,offset DGROUP:InitEnd        ;di = end of table
  323.                 call    Initialize
  324.  
  325. ;       ExitCode = main(argc,argv,envp);
  326.  
  327. IF      LDATA
  328.                 push    word ptr __C0environ+2
  329.                 push    word ptr __C0environ
  330.                 push    word ptr __C0argv+2
  331.                 push    word ptr __C0argv
  332. ELSE
  333.                 push    word ptr __C0environ
  334.                 push    word ptr __C0argv
  335. ENDIF
  336.                 push    __C0argc
  337.                 call    _main
  338.  
  339. ;       Flush and close streams and files
  340.  
  341.                 push    ax
  342.                 call    _exit
  343.  
  344. ;---------------------------------------------------------------------------
  345. ;       _cleanup()      call all #pragma exit cleanup routines.
  346. ;       _checknull()    check for null pointer zapping copyright message
  347. ;       _terminate(int) exit program with error code
  348. ;
  349. ;       These functions are called by exit(), _exit(), _cexit(),
  350. ;       and _c_exit().
  351. ;---------------------------------------------------------------------------
  352.  
  353. ;       Call cleanup routines
  354.  
  355. __cleanup       PROC    DIST
  356.                 PUBLIC  __cleanup
  357.  
  358.                 mov     es, cs:DGROUP@@
  359.                 push    si
  360.                 push    di
  361.                 mov     si,offset DGROUP:ExitStart
  362.                 mov     di,offset DGROUP:ExitEnd
  363.                 call    Cleanup
  364.                 pop     di
  365.                 pop     si
  366.                 ret
  367. __cleanup       ENDP
  368.  
  369. ;       Check for null pointers before exit
  370.  
  371. __checknull     PROC    DIST
  372.                 PUBLIC  __checknull
  373. IF      LDATA  EQ  false
  374.   IFNDEF  __TINY__
  375.                 push    si
  376.                 push    di
  377.                 mov     es, cs:DGROUP@@
  378.                 xor     ax, ax
  379.                 mov     si, ax
  380.                 mov     cx, 16
  381. ComputeChecksum label   near
  382.                 add     al, es:[si]
  383.                 adc     ah, 0
  384.                 inc     si
  385.                 loop    ComputeChecksum
  386.                 sub     ax, CheckSum
  387.                 jz      @@SumOK
  388.                 mov     dx, offset DGROUP:NullCheck
  389.                 pushDS_
  390.                 push    dx
  391.                 call    ___ErrorMessage
  392.                 pop     dx
  393.                 popDS_
  394. @@SumOK:        pop     di
  395.                 pop     si
  396.   ENDIF
  397. ENDIF
  398.                 ret
  399. __checknull     ENDP
  400.  
  401. ;       Exit to DOS
  402.  
  403. __terminate     PROC    DIST
  404.                 PUBLIC  __terminate
  405.                 mov     bp,sp
  406.                 mov     ah,4Ch
  407.                 mov     al,[bp+cPtrSize]
  408.                 int     21h                     ; Exit to DOS
  409. __terminate     ENDP
  410.  
  411. STARTX          ENDP
  412.  
  413.         SUBTTL  Vector save/restore & default Zero divide routines
  414.         PAGE
  415. ;[]------------------------------------------------------------[]
  416. ;|                                                              |
  417. ;| Interrupt Save/Restore routines and default divide by zero   |
  418. ;| handler.                                                     |
  419. ;|                                                              |
  420. ;[]------------------------------------------------------------[]
  421.  
  422. ZeroDivision    PROC    FAR
  423.                 mov     dx, offset DGROUP:ZeroDivMSG
  424.                 pushDS_
  425.                 push    dx
  426.                 call    ___ErrorMessage
  427.                 pop     dx
  428.                 popDS_
  429.                 mov     ax, 3
  430.                 push    ax
  431.                 call    __exit           ; _exit(3);
  432. ZeroDivision    ENDP
  433.  
  434. ;--------------------------------------------------------------------------
  435. ;       savevectors()
  436. ;
  437. ;       Save vectors for 0, 4, 5 & 6 interrupts.  This is for extended
  438. ;       signal()/raise() support as the signal functions can steal these
  439. ;       vectors during runtime.
  440. ;--------------------------------------------------------------------------
  441. SaveVectors     PROC    NEAR
  442.                 push    ds
  443. ; Save INT 0
  444.                 mov     ax, 3500h
  445.                 int     021h
  446.                 mov     word ptr _Int0Vector@, bx
  447.                 mov     word ptr _Int0Vector@+2, es
  448. ; Save INT 4
  449.                 mov     ax, 3504h
  450.                 int     021h
  451.                 mov     word ptr _Int4Vector@, bx
  452.                 mov     word ptr _Int4Vector@+2, es
  453. ; Save INT 5
  454.                 mov     ax, 3505h
  455.                 int     021h
  456.                 mov     word ptr _Int5Vector@, bx
  457.                 mov     word ptr _Int5Vector@+2, es
  458. ; Save INT 6
  459.                 mov     ax, 3506h
  460.                 int     021h
  461.                 mov     word ptr _Int6Vector@, bx
  462.                 mov     word ptr _Int6Vector@+2, es
  463. ;
  464. ;       Install default divide by zero handler.
  465. ;
  466.                 mov     ax, 2500h
  467.                 mov     dx, cs
  468.                 mov     ds, dx
  469.                 mov     dx, offset ZeroDivision
  470.                 int     21h
  471.  
  472.                 pop     ds
  473.                 ret
  474. SaveVectors     ENDP
  475.  
  476. ;--------------------------------------------------------------------------
  477. ;       _restorezero() puts back all the vectors that SaveVectors took.
  478. ;
  479. ;NOTE : TSRs must BE AWARE that signal() functions which take these
  480. ;       vectors will be deactivated if the keep() function is executed.
  481. ;       If a TSR wants to use the signal functions when it is active it
  482. ;       will have to save/restore these vectors itself when activated and
  483. ;       deactivated.
  484. ;--------------------------------------------------------------------------
  485. __restorezero   PROC    DIST
  486.                 PUBLIC  __restorezero
  487. IFDEF   __HUGE__
  488.                 push    ds
  489.                 mov     ds, cs: DGROUP@@
  490. ENDIF
  491.                 push    ds
  492.                 mov     ax, 2500h
  493.                 lds     dx, _Int0Vector@
  494.                 int     21h
  495.                 pop     ds
  496.  
  497.                 push    ds
  498.                 mov     ax, 2504h
  499.                 lds     dx, _Int4Vector@
  500.                 int     21h
  501.                 pop     ds
  502.  
  503.                 push    ds
  504.                 mov     ax, 2505h
  505.                 lds     dx, _Int5Vector@
  506.                 int     21h
  507.                 pop     ds
  508.  
  509. IFNDEF   __HUGE__
  510.                 push    ds
  511. ENDIF
  512.                 mov     ax, 2506h
  513.                 lds     dx, _Int6Vector@
  514.                 int     21h
  515.                 pop     ds
  516.  
  517.                 ret
  518.                 ENDP
  519.  
  520. ;------------------------------------------------------------------
  521. ;  Loop through a startup/exit (SE) table,
  522. ;  calling functions in order of priority.
  523. ;  ES:SI is assumed to point to the beginning of the SE table
  524. ;  ES:DI is assumed to point to the end of the SE table
  525. ;  First 64 priorities are reserved by Borland
  526. ;------------------------------------------------------------------
  527. PNEAR           EQU     0
  528. PFAR            EQU     1
  529. NOTUSED         EQU     0ffh
  530.  
  531. SE              STRUC
  532. calltype        db      ?                       ; 0=near,1=far,ff=not used
  533. priority        db      ?                       ; 0=highest,ff=lowest
  534. addrlow         dw      ?
  535. addrhigh        dw      ?
  536. SE              ENDS
  537.  
  538. Initialize      proc near
  539. @@Start:        mov     ax,100h                 ;start with lowest priority
  540.                 mov     dx,di                   ;set sentinel to end of table
  541.                 mov     bx,si                   ;bx = start of table
  542.  
  543. @@TopOfTable:   cmp     bx,di                   ;and the end of the table?
  544.                 je      @@EndOfTable            ;yes, exit the loop
  545.                 cmp     es:[bx.calltype],NOTUSED;check the call type
  546.                 je      @@Next
  547.                 mov     cl, es:[bx.priority]    ;move priority to CX
  548.                 xor     ch, ch
  549.                 cmp     cx,ax                   ;check the priority
  550.                 jae     @@Next                  ;too high?  skip
  551.                 mov     ax,cx                   ;keep priority
  552.                 mov     dx,bx                   ;keep index in dx
  553. @@Next:         add     bx,SIZE SE              ;bx = next item in table
  554.                 jmp     @@TopOfTable
  555.  
  556. @@EndOfTable:   cmp     dx,di                   ;did we exhaust the table?
  557.                 je      @@Done                  ;yes, quit
  558.                 mov     bx,dx                   ;bx = highest priority item
  559.                 cmp     es:[bx.calltype],PNEAR  ;is it near or far?
  560.                 mov     es:[bx.calltype],NOTUSED;wipe the call type
  561.                 push    es                      ;save es
  562.                 je      @@NearCall
  563.  
  564. @@FarCall:      call    DWORD PTR es:[bx.addrlow]
  565.                 pop     es                      ;restore es
  566.                 jmp     short @@Start
  567.  
  568. @@NearCall:     call    WORD PTR es:[bx.addrlow]
  569.                 pop     es                      ;restore es
  570.                 jmp     short @@Start
  571.  
  572. @@Done:         ret
  573.                 endp
  574.  
  575. Cleanup         proc near
  576. @@Start:        mov     ah,0                    ;start with highest priority
  577.                 mov     dx,di                   ;set sentinel to end of table
  578.                 mov     bx,si                   ;bx = start of table
  579.  
  580. @@TopOfTable:   cmp     bx,di                   ;and the end of the table?
  581.                 je      @@EndOfTable            ;yes, exit the loop
  582.                 cmp     es:[bx.calltype],NOTUSED;check the call type
  583.                 je      @@Next
  584.                 cmp     es:[bx.priority],ah     ;check the priority
  585.                 jb      @@Next                  ;too low?  skip
  586.                 mov     ah,es:[bx.priority]     ;keep priority
  587.                 mov     dx,bx                   ;keep index in dx
  588. @@Next:         add     bx,SIZE SE              ;bx = next item in table
  589.                 jmp     @@TopOfTable
  590.  
  591. @@EndOfTable:   cmp     dx,di                   ;did we exhaust the table?
  592.                 je      @@Done                  ;yes, quit
  593.                 mov     bx,dx                   ;bx = highest priority item
  594.                 cmp     es:[bx.calltype],PNEAR  ;is it near or far?
  595.                 mov     es:[bx.calltype],NOTUSED;wipe the call type
  596.                 push    es                      ;save es
  597.                 je      @@NearCall
  598.  
  599. @@FarCall:      call    DWORD PTR es:[bx.addrlow]
  600.                 pop     es                      ;restore es
  601.                 jmp     short @@Start
  602.  
  603. @@NearCall:     call    WORD PTR es:[bx.addrlow]
  604.                 pop     es                      ;restore es
  605.                 jmp     short @@Start
  606.  
  607. @@Done:         ret
  608.                 endp
  609.  
  610. ;------------------------------------------------------------------
  611.  
  612. ; The DGROUP@ variable is used to reload DS with DGROUP
  613.  
  614. PubSym@         DGROUP@, <dw    ?>, __PASCAL__
  615.  
  616.  
  617.  
  618. ; __MMODEL is used to determine the memory model or the default
  619. ; pointer types at run time.
  620.  
  621.                 public __MMODEL
  622. __MMODEL        dw      MMODEL
  623.  
  624. _TEXT           ENDS
  625.  
  626.                 SUBTTL  Start Up Data Area
  627.                 PAGE
  628. ;[]------------------------------------------------------------[]
  629. ;|      Start Up Data Area                                      |
  630. ;|                                                              |
  631. ;|      WARNING         Do not move any variables in the data   |
  632. ;|                      segment unless you're absolutely sure   |
  633. ;|                      that it does not matter.                |
  634. ;[]------------------------------------------------------------[]
  635.  
  636. _DATA           SEGMENT
  637.  
  638. ;       Magic symbol used by the debug info to locate the data segment
  639.                 public DATASEG@
  640. DATASEG@        label   byte
  641.  
  642. ;       The Check string must NOT be moved or changed without
  643. ;       changing the null pointer check logic
  644.  
  645. NULL            db       4 dup(0)
  646. CheckStr        db      'NULL CHECK'
  647.                 db       2 dup (0)
  648.                 db       4 dup (0)              ;destructor count
  649.                 db       2 dup (0)              ;exception list
  650.                 db       4 dup (0)              ;exception vptr
  651. CopyRight       db      'Borland C++ - Copyright 1993 Borland Intl.',0
  652.  
  653. IF      LDATA  EQ  false
  654. IFNDEF  __TINY__
  655. CheckSum        equ     002B9h
  656. NullCheck       db      'Null pointer assignment', 13, 10, 0
  657. ENDIF
  658. ENDIF
  659.  
  660. ZeroDivMSG      db      'Divide error', 13, 10, 0
  661.  
  662. ;
  663. ;                       Interrupt vector save areas
  664. ;
  665. ;       Interrupt vectors 0,4,5 & 6 are saved at startup and then restored
  666. ;       when the program terminates.  The signal/raise functions might
  667. ;       steal these vectors during execution.
  668. ;
  669. ;       Note: These vectors save area must not be altered
  670. ;             without changing the save/restore logic.
  671. ;
  672. PubSym@         _Int0Vector     <dd     0>,             __CDECL__
  673. PubSym@         _Int4Vector     <dd     0>,             __CDECL__
  674. PubSym@         _Int5Vector     <dd     0>,             __CDECL__
  675. PubSym@         _Int6Vector     <dd     0>,             __CDECL__
  676. ;
  677. ;                       Miscellaneous variables
  678. ;
  679. PubSym@         _C0argc,        <dw     0>,             __CDECL__
  680. dPtrPub@        _C0argv,        0,                      __CDECL__
  681. dPtrPub@        _C0environ,     0,                      __CDECL__
  682. PubSym@         _envLng,        <dw     0>,             __CDECL__
  683. PubSym@         _envseg,        <dw     0>,             __CDECL__
  684. PubSym@         _envSize,       <dw     0>,             __CDECL__
  685. PubSym@         _psp,           <dw     0>,             __CDECL__
  686. PubSym@         _version,       <label word>,           __CDECL__
  687. PubSym@         _osversion,     <label word>,           __CDECL__
  688. PubSym@         _osmajor,       <db     0>,             __CDECL__
  689. PubSym@         _osminor,       <db     0>,             __CDECL__
  690. PubSym@         errno,          <dw     0>,             __CDECL__
  691. PubSym@         _Exception_list,<dw    -1>,             __CDECL__
  692.  
  693.  
  694.  
  695. ;       Memory management variables
  696.  
  697. IF      LDATA  EQ  false
  698. PubSym@         __heapbase,     <dw   DGROUP:edata@>,   __CDECL__
  699. ENDIF
  700. IFNDEF __HUGE__
  701. PubSym@         __brklvl,       <dw   DGROUP:edata@>,   __CDECL__
  702. ENDIF
  703. PubSym@         _heapbase,      <dd   0>,       __CDECL__
  704. PubSym@         _brklvl,        <dd   0>,       __CDECL__
  705. PubSym@         _heaptop,       <dd   0>,       __CDECL__
  706.  
  707. ;       If stack in DS and Large data model then override location of __emu
  708.  
  709. IFDEF   _DSSTACK_
  710. IF      LDATA
  711. public  __emu
  712. __emu   db      044h    DUP (0)
  713.         db      0CCh    DUP (?)
  714. ENDIF
  715. ENDIF
  716.  
  717. _DATA           ENDS
  718.  
  719.  
  720. _CVTSEG         SEGMENT
  721. PubSym@         _RealCvtVector, <label  word>,  __CDECL__
  722.                 ENDS
  723.  
  724. _SCNSEG         SEGMENT
  725. PubSym@         _ScanTodVector,  <label word>,  __CDECL__
  726.                 ENDS
  727.  
  728. IFNDEF __HUGE__
  729. _BSS            SEGMENT
  730. bdata@          label   byte
  731.                 ENDS
  732.  
  733. _BSSEND         SEGMENT
  734. edata@          label   byte
  735.                 ENDS
  736. ENDIF
  737.  
  738. IFNDEF __TINY__
  739. _STACK          SEGMENT
  740.                 db      128 dup(?)               ;minimum stack size
  741.                 ENDS
  742. ENDIF  ; __TINY__
  743.                 END     STARTX
  744.