home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 6.ddi / STARTUP.ZIP / C0.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  26.3 KB  |  764 lines

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