home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / FOREIGN / MSC / MSCINIT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-29  |  3.7 KB  |  214 lines

  1.  
  2.     TITLE    INIT - Initiate execution of a PROLOG program from MC
  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 MC and MC
  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.  
  55. public _free
  56. _free proc far
  57.     push    bp
  58.     mov    bp,sp
  59.     les    bx,[bp+6]
  60.     dec    bx
  61.     dec    bx
  62.     push    es
  63.     push    bx
  64.     mov    ax,es:[bx]
  65.     inc    ax
  66.     inc    ax
  67.     push    ax
  68.     call    MEM_ReleaseHeap
  69.     pop    bp
  70.     ret
  71. _free endp
  72.  
  73.  
  74. public _coreleft
  75. _coreleft proc far
  76.     call    _MEM_MarkGStack
  77.     push    dx
  78.     push    ax
  79.     call    _MEM_MarkTemp
  80.     push    dx
  81.     push    ax
  82.     call    _PTR_PtrDiff
  83.     add    sp,8
  84.     ret
  85. _coreleft endp
  86.  
  87.  
  88. public _realloc
  89. _realloc label far
  90. public _farcalloc
  91. _farcalloc label far
  92. public _farcoreleft
  93. _farcoreleft label far
  94. public _farmalloc
  95. _farmalloc label far
  96. public _farrealloc
  97. _farrealloc label far
  98. public _calloc
  99. _calloc label far
  100. public _allocmem
  101. _allocmem label far
  102. public null_ret
  103.  
  104. null_ret proc far
  105.     xor    ax,ax
  106.     cwd
  107. public _farfree
  108. _farfree label far
  109.     ret
  110. null_ret endp
  111.  
  112.  
  113. public _sbrk
  114. _sbrk label far
  115. public _brk
  116. _brk label far
  117. public _freemem
  118. _freemem label far
  119.  
  120. public neg_ret
  121. neg_ret proc far
  122.     mov    ax,-1
  123.     cwd
  124.     ret
  125. neg_ret endp
  126.  
  127. ; Should never be called !!
  128. public _INIT_Exit
  129. _INIT_Exit proc far
  130.     ret
  131. _INIT_Exit endp
  132.  
  133.  
  134. public    __turboFloat
  135. __turboFloat:
  136.     int    1
  137. INIT_TEXT    ENDS
  138.  
  139. ;
  140. ;------------------------- PC-PROLOG Segments ---------------------------
  141. ;
  142.  
  143. ; Prolog private datastructures
  144. PROCONST SEGMENT WORD PUBLIC 'PROCONST'
  145. extrn     _PROLOG_Vars : dword ; Misc parameters transfered from prolog main module
  146. PROCONST ENDS
  147.  
  148.  
  149.  
  150. ; _Symbol table from .SYM file
  151. PROSYMB    SEGMENT PARA COMMON 'PROSYMB'
  152. extrn     _PROLOG_SymbolTable : dword ; Root of the prolog symbol table
  153. PROSYMB    ENDS
  154.  
  155.  
  156. ;
  157. ;--------------------------- DATA Segment ------------------------------
  158. ;
  159.  
  160. PUBLIC    FIDRQQ        ; wait, esc
  161. FIDRQQ    equ    05C32h
  162.  
  163.  
  164. _DATA    SEGMENT word PUBLIC 'DATA'
  165.  
  166. _INIT_PPSP    DD    0            ; program segment _prefix pointer
  167. PUBLIC    _INIT_PPSP
  168.  
  169. _INIT_Comstr    dd    0            ; pointer to COMSPEC=c:\command.com
  170. PUBLIC    _INIT_Comstr
  171.  
  172. _DATA    ENDS
  173.  
  174.  
  175.  
  176. DGROUP    GROUP    _DATA ; ,_BSS,_BSSEND
  177.  
  178.  
  179. ;
  180. ;--------------------------- Stack segment ------------------------------
  181. ;
  182.  
  183. ; Due to MS C's memory management, these will end up at the bottom of the
  184. ; data/stack segment, causing a null-pointer assignment error unless a
  185. ; dummy __nullcheck is installed in one of the libraries - see the read.me
  186. ; file.
  187.  
  188.  
  189. _DATA    SEGMENT word PUBLIC 'DATA'
  190.  
  191. PUBLIC    _PFP_Err
  192. _PFP_Err        db    0
  193.  
  194. public    _CPU_Type        ; 286/386.
  195. _CPU_Type        db    0
  196.  
  197. public    _BRK_BreakEnabled    ; Break enabled.
  198. _BRK_BreakEnabled    db 1
  199.  
  200. public    _BRK_BreakPressed    ; Break pressed.
  201. _BRK_BreakPressed    db 0
  202.  
  203. EVEN
  204. public _INIT_DataSeg        ; Default Dataseg.
  205. _INIT_DataSeg        dw    0
  206.  
  207. public    _KB_CheckCount        ; Check keyboard for every 256 pred calls
  208. _KB_CheckCount        db 0
  209.  
  210.     DB    "Copyright (c) 1990 by Prolog Development Center"
  211. _DATA    ENDS
  212.  
  213.     END
  214.