home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / EDMI5.ZIP / IFSR0.ZIP / C0.ASM next >
Assembly Source File  |  1993-07-01  |  6KB  |  175 lines

  1. ;[]------------------------------------------------------------[]
  2. ;|      C0.ASM -- Start Up Code for DOS                         |
  3. ;[]------------------------------------------------------------[]
  4.  
  5. ;
  6. ;       C/C++ Run Time Library - Version 5.0
  7. ;
  8. ;       Copyright (c) 1987, 1992 by Borland International
  9. ;       All Rights Reserved.
  10. ;
  11.  
  12.                 locals
  13.  
  14. ;       Segment and Group declarations
  15.  
  16. _TEXT           SEGMENT BYTE PUBLIC 'CODE'
  17.                 ENDS
  18. _FARDATA        SEGMENT PARA PUBLIC 'FAR_DATA'
  19.                 ENDS
  20. _FARBSS         SEGMENT PARA PUBLIC 'FAR_BSS'
  21.                 ENDS
  22. _DATA           SEGMENT PARA PUBLIC 'DATA'
  23.                 ENDS
  24. _CONST          SEGMENT WORD PUBLIC 'CONST'
  25.                 ENDS
  26. _CVTSEG         SEGMENT WORD PUBLIC 'DATA'
  27.                 ENDS
  28. _SCNSEG         SEGMENT WORD PUBLIC 'DATA'
  29.                 ENDS
  30. _INIT_          SEGMENT WORD PUBLIC 'INITDATA'
  31. InitStart       label byte
  32.                 ENDS
  33. _INITEND_       SEGMENT BYTE PUBLIC 'INITDATA'
  34. InitEnd         label byte
  35.                 ENDS
  36. _EXIT_          SEGMENT WORD PUBLIC 'EXITDATA'
  37. ExitStart       label byte
  38.                 ENDS
  39. _EXITEND_       SEGMENT BYTE PUBLIC 'EXITDATA'
  40. ExitEnd         label byte
  41.                 ENDS
  42.  
  43. IFNDEF __HUGE__
  44. _BSS          SEGMENT WORD PUBLIC 'BSS'
  45. bdata@        label byte
  46.               ENDS
  47. _BSSEND       SEGMENT BYTE PUBLIC 'BSSEND'
  48. edata@        label byte
  49.               ENDS
  50. ENDIF
  51.  
  52.  
  53. IFDEF   __SMALL__ OR __MEDIUM__ OR __COMPACT__ OR __LARGE__
  54.       DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
  55. ELSEIFDEF __HUGE__
  56.       DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_
  57. ELSE
  58.       %OUT  You must supply a model symbol.
  59.       .ERR
  60. ENDIF
  61.  
  62.  
  63. ;/*                                                     */
  64. ;/*-----------------------------------------------------*/
  65. ;/*                                                     */
  66. ;/*     Start Up Code                                   */
  67. ;/*     -------------                                   */
  68. ;/*                                                     */
  69. ;/*-----------------------------------------------------*/
  70. ;/*                                                     */
  71.  
  72. ;
  73. ;       At the start, DS points to DGROUP
  74. ;
  75.  
  76.                 ASSUME  CS:_TEXT, DS:DGROUP
  77.  
  78. _TEXT           SEGMENT
  79.                 PUBLIC  STARTUP
  80. STARTUP         PROC    FAR
  81.  
  82.                 push    ds
  83.                 pop     es
  84.  
  85. IFNDEF  __HUGE__
  86.  
  87. ;       Reset uninitialized data area
  88.  
  89.                 xor     ax, ax
  90.                 mov     di, offset DGROUP: bdata@
  91.                 mov     cx, offset DGROUP: edata@
  92.                 sub     cx, di
  93.                 cld
  94.                 rep     stosb
  95. ENDIF
  96.  
  97.                 mov     si,offset DGROUP:InitStart      ;si = start of table
  98.                 mov     di,offset DGROUP:InitEnd        ;di = end of table
  99.  
  100. ;------------------------------------------------------------------
  101. ;  Loop through a startup/exit (SE) table,
  102. ;  calling functions in order of priority.
  103. ;  ES:SI is assumed to point to the beginning of the SE table
  104. ;  ES:DI is assumed to point to the end of the SE table
  105. ;  First 64 priorities are reserved by Borland
  106. ;------------------------------------------------------------------
  107. PNEAR           EQU     0
  108. PFAR            EQU     1
  109. NOTUSED         EQU     0ffh
  110.  
  111. SE              STRUC
  112. calltype        db      ?                       ; 0=near,1=far,ff=not used
  113. priority        db      ?                       ; 0=highest,ff=lowest
  114. addrlow         dw      ?
  115. addrhigh        dw      ?
  116. SE              ENDS
  117.  
  118. @@Start:        mov     ax,100h                 ;start with lowest priority
  119.                 mov     dx,di                   ;set sentinel to end of table
  120.                 mov     bx,si                   ;bx = start of table
  121.  
  122. @@TopOfTable:   cmp     bx,di                   ;and the end of the table?
  123.                 je      @@EndOfTable            ;yes, exit the loop
  124.                 cmp     es:[bx.calltype],NOTUSED;check the call type
  125.                 je      @@Next
  126.                 mov     cl, es:[bx.priority]    ;move priority to CX
  127.                 xor     ch, ch
  128.                 cmp     cx,ax                   ;check the priority
  129.                 jae     @@Next                  ;too high?  skip
  130.                 mov     ax,cx                   ;keep priority
  131.                 mov     dx,bx                   ;keep index in dx
  132. @@Next:         add     bx,SIZE SE              ;bx = next item in table
  133.                 jmp     @@TopOfTable
  134.  
  135. @@EndOfTable:   cmp     dx,di                   ;did we exhaust the table?
  136.                 je      @@Done                  ;yes, quit
  137.                 mov     bx,dx                   ;bx = highest priority item
  138.                 cmp     es:[bx.calltype],PNEAR  ;is it near or far?
  139.                 mov     es:[bx.calltype],NOTUSED;wipe the call type
  140.                 push    es                      ;save es
  141.                 je      @@NearCall
  142.  
  143. @@FarCall:      call    DWORD PTR es:[bx.addrlow]
  144.                 pop     es                      ;restore es
  145.                 jmp     short @@Start
  146.  
  147. @@NearCall:     call    WORD PTR es:[bx.addrlow]
  148.                 pop     es                      ;restore es
  149.                 jmp     short @@Start
  150.  
  151. @@Done:         ret
  152.  
  153. STARTUP         ENDP
  154.  
  155.  
  156. ;------------------------------------------------------------------
  157.  
  158.                 public abort
  159. abort           label   word
  160. ;
  161.                 public _RealCvtVector
  162. _RealCvtVector label word
  163. ;
  164.                 public _ScanTodVector
  165. _ScanTodVector label word
  166. ;
  167.  
  168. _TEXT           ENDS
  169.  
  170. _DATA           SEGMENT
  171.                 db      'Borland C++ - Copyright 1991 Borland Intl.',0
  172. _DATA           ENDS
  173.  
  174.                 END
  175.