home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / START16.PAK / C0.ASM < prev    next >
Assembly Source File  |  1995-08-29  |  26KB  |  746 lines

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