home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 92.img / TCPLUS-6.ZIP / STARTUP.ZIP / C0.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-04  |  24.4 KB  |  722 lines

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