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