home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / FOREIGN / TC / TCINIT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-16  |  3.4 KB  |  208 lines

  1.  
  2.     TITLE    INIT - Initiate execution of a PROLOG program from TC
  3.     SUBTTL    Copyright 1987,90 by Prolog Development Center
  4.     NAME    INIT
  5.  
  6. ;**
  7. ;
  8. ; name        PROLOG -- initiate execution of PDC PROLOG program
  9. ;
  10. ; description    Initializes memory manager and global prolog variables.
  11. ;               Used when PROLOG is linked together with TC and TC
  12. ;               defines the main program
  13. ;**
  14.  
  15.  
  16. ;
  17. ;---------------------- Define the code Segment ------------------------------
  18. ;
  19.  
  20. extrn _MEM_Initialized: byte
  21. extrn MEM_AllocHeap: far
  22. extrn MEM_ReleaseHeap: far
  23. extrn _MEM_Init: far
  24. extrn _PTR_PtrDiff: far
  25. extrn _MEM_MarkTemp: far
  26. extrn _MEM_MarkGStack: far
  27.  
  28. INIT_TEXT    SEGMENT BYTE PUBLIC 'CODE'
  29. assume cs:INIT_TEXT, ds:DGROUP
  30.  
  31. public _malloc
  32. _malloc proc far
  33.     push    bp
  34.     mov    bp,sp
  35.     cmp    _MEM_Initialized,0
  36.     jne    init_ok
  37.     call    _MEM_Init
  38. init_ok:
  39.     mov    ax,[bp+6]
  40.     inc    ax
  41.     inc    ax
  42.     push    ax
  43.     call    MEM_AllocHeap
  44.     mov    es,dx
  45.     mov    bx,ax
  46.     mov    cx,[bp+6]
  47.     mov    es:[bx],cx
  48.     inc    ax
  49.     inc    ax
  50.     pop    bp
  51.     ret
  52. _malloc endp
  53.  
  54. public _free
  55. _free proc far
  56.     push    bp
  57.     mov    bp,sp
  58.     les    bx,[bp+6]
  59.     dec    bx
  60.     dec    bx
  61.     push    es
  62.     push    bx
  63.     mov    ax,es:[bx]
  64.     inc    ax
  65.     inc    ax
  66.     push    ax
  67.     call    MEM_ReleaseHeap
  68.     pop    bp
  69.     ret
  70. _free endp
  71.  
  72. public _coreleft
  73. _coreleft proc far
  74.     call    _MEM_MarkGStack
  75.     push    dx
  76.     push    ax
  77.     call    _MEM_MarkTemp
  78.     push    dx
  79.     push    ax
  80.     call    _PTR_PtrDiff
  81.     add    sp,8
  82.     ret
  83. _coreleft endp
  84.  
  85.  
  86. public _realloc
  87. _realloc label far
  88. public _farcalloc
  89. _farcalloc label far
  90. public _farcoreleft
  91. _farcoreleft label far
  92. public _farmalloc
  93. _farmalloc label far
  94. public _farrealloc
  95. _farrealloc label far
  96. public _calloc
  97. _calloc label far
  98. public _allocmem
  99. _allocmem label far
  100. public null_ret
  101.  
  102. null_ret proc far
  103.     xor    ax,ax
  104.     cwd
  105. public _farfree
  106. _farfree label far
  107.     ret
  108. null_ret endp
  109.  
  110.  
  111. public _sbrk
  112. _sbrk label far
  113. public _brk
  114. _brk label far
  115. public _freemem
  116. _freemem label far
  117.  
  118. public neg_ret
  119. neg_ret proc far
  120.     mov    ax,-1
  121.     cwd
  122.     ret
  123. neg_ret endp
  124.  
  125.  
  126. ; Should never be called !!
  127. public _INIT_Exit
  128. _INIT_Exit proc far
  129.     ret
  130. _INIT_Exit endp
  131.  
  132.  
  133. public    __turboFloat
  134. __turboFloat:
  135.     int    1
  136. INIT_TEXT    ENDS
  137.  
  138. ;
  139. ;--------------------------- DATA Segment ------------------------------
  140. ;
  141.  
  142. PUBLIC    FIDRQQ        ; wait, esc
  143. FIDRQQ    equ    05C32h
  144.  
  145.  
  146. _DATA    SEGMENT word PUBLIC 'DATA'
  147.  
  148. _INIT_PPSP    DD    0            ; program segment _prefix pointer
  149. PUBLIC    _INIT_PPSP
  150.  
  151. _INIT_Comstr    dd    0            ; pointer to COMSPEC=c:\command.com
  152. PUBLIC    _INIT_Comstr
  153.  
  154. _DATA    ENDS
  155.  
  156.  
  157.  
  158. DGROUP    GROUP    _DATA ; ,_BSS,_BSSEND
  159.  
  160.  
  161. ;
  162. ;------------------------- PC-PROLOG Segments ---------------------------
  163. ;
  164.  
  165. ; Prolog private datastructures
  166. PROCONST SEGMENT WORD PUBLIC 'PROCONST'
  167. extrn     _PROLOG_Vars : dword ; Misc parameters transfered from prolog main module
  168. PROCONST ENDS
  169.  
  170.  
  171.  
  172. ; _Symbol table from .SYM file
  173. PROSYMB    SEGMENT PARA COMMON 'PROSYMB'
  174. extrn     _PROLOG_SymbolTable : dword ; Root of the prolog symbol table
  175. PROSYMB    ENDS
  176.  
  177.  
  178.  
  179. ;
  180. ;--------------------------- Stack segment ------------------------------
  181. ;
  182.  
  183. _STACK    SEGMENT STACK 'STACK'
  184.  
  185. PUBLIC    _PFP_Err
  186. _PFP_Err        db    0
  187.  
  188. public    _CPU_Type        ; 286/386.
  189. _CPU_Type        db    0
  190.  
  191. public    _BRK_BreakEnabled    ; Break enabled.
  192. _BRK_BreakEnabled    db 1
  193.  
  194. public    _BRK_BreakPressed    ; Break pressed.
  195. _BRK_BreakPressed    db 0
  196.  
  197. EVEN
  198. public _INIT_DataSeg        ; Default Dataseg.
  199. _INIT_DataSeg        dw    0
  200.  
  201. public    _KB_CheckCount        ; Check keyboard for every 256 pred calls
  202. _KB_CheckCount        db 0
  203.  
  204. EVEN
  205. _STACK    ENDS
  206.  
  207.     END
  208.