home *** CD-ROM | disk | FTP | other *** search
-
- TITLE INIT - Initiate execution of a PROLOG program from TC
- SUBTTL Copyright 1987,90 by Prolog Development Center
- NAME INIT
-
- ;**
- ;
- ; name PROLOG -- initiate execution of PDC PROLOG program
- ;
- ; description Initializes memory manager and global prolog variables.
- ; Used when PROLOG is linked together with TC and TC
- ; defines the main program
- ;**
-
-
- ;
- ;---------------------- Define the code Segment ------------------------------
- ;
-
- extrn _MEM_Initialized: byte
- extrn MEM_AllocHeap: far
- extrn MEM_ReleaseHeap: far
- extrn _MEM_Init: far
- extrn _PTR_PtrDiff: far
- extrn _MEM_MarkTemp: far
- extrn _MEM_MarkGStack: far
-
- INIT_TEXT SEGMENT BYTE PUBLIC 'CODE'
- assume cs:INIT_TEXT, ds:DGROUP
-
- public _malloc
- _malloc proc far
- push bp
- mov bp,sp
- cmp _MEM_Initialized,0
- jne init_ok
- call _MEM_Init
- init_ok:
- mov ax,[bp+6]
- inc ax
- inc ax
- push ax
- call MEM_AllocHeap
- mov es,dx
- mov bx,ax
- mov cx,[bp+6]
- mov es:[bx],cx
- inc ax
- inc ax
- pop bp
- ret
- _malloc endp
-
- public _free
- _free proc far
- push bp
- mov bp,sp
- les bx,[bp+6]
- dec bx
- dec bx
- push es
- push bx
- mov ax,es:[bx]
- inc ax
- inc ax
- push ax
- call MEM_ReleaseHeap
- pop bp
- ret
- _free endp
-
- public _coreleft
- _coreleft proc far
- call _MEM_MarkGStack
- push dx
- push ax
- call _MEM_MarkTemp
- push dx
- push ax
- call _PTR_PtrDiff
- add sp,8
- ret
- _coreleft endp
-
-
- public _realloc
- _realloc label far
- public _farcalloc
- _farcalloc label far
- public _farcoreleft
- _farcoreleft label far
- public _farmalloc
- _farmalloc label far
- public _farrealloc
- _farrealloc label far
- public _calloc
- _calloc label far
- public _allocmem
- _allocmem label far
- public null_ret
-
- null_ret proc far
- xor ax,ax
- cwd
- public _farfree
- _farfree label far
- ret
- null_ret endp
-
-
- public _sbrk
- _sbrk label far
- public _brk
- _brk label far
- public _freemem
- _freemem label far
-
- public neg_ret
- neg_ret proc far
- mov ax,-1
- cwd
- ret
- neg_ret endp
-
-
- ; Should never be called !!
- public _INIT_Exit
- _INIT_Exit proc far
- ret
- _INIT_Exit endp
-
-
- public __turboFloat
- __turboFloat:
- int 1
- INIT_TEXT ENDS
-
- ;
- ;--------------------------- DATA Segment ------------------------------
- ;
-
- PUBLIC FIDRQQ ; wait, esc
- FIDRQQ equ 05C32h
-
-
- _DATA SEGMENT word PUBLIC 'DATA'
-
- _INIT_PPSP DD 0 ; program segment _prefix pointer
- PUBLIC _INIT_PPSP
-
- _INIT_Comstr dd 0 ; pointer to COMSPEC=c:\command.com
- PUBLIC _INIT_Comstr
-
- _DATA ENDS
-
-
-
- DGROUP GROUP _DATA ; ,_BSS,_BSSEND
-
-
- ;
- ;------------------------- PC-PROLOG Segments ---------------------------
- ;
-
- ; Prolog private datastructures
- PROCONST SEGMENT WORD PUBLIC 'PROCONST'
- extrn _PROLOG_Vars : dword ; Misc parameters transfered from prolog main module
- PROCONST ENDS
-
-
-
- ; _Symbol table from .SYM file
- PROSYMB SEGMENT PARA COMMON 'PROSYMB'
- extrn _PROLOG_SymbolTable : dword ; Root of the prolog symbol table
- PROSYMB ENDS
-
-
-
- ;
- ;--------------------------- Stack segment ------------------------------
- ;
-
- _STACK SEGMENT STACK 'STACK'
-
- PUBLIC _PFP_Err
- _PFP_Err db 0
-
- public _CPU_Type ; 286/386.
- _CPU_Type db 0
-
- public _BRK_BreakEnabled ; Break enabled.
- _BRK_BreakEnabled db 1
-
- public _BRK_BreakPressed ; Break pressed.
- _BRK_BreakPressed db 0
-
- EVEN
- public _INIT_DataSeg ; Default Dataseg.
- _INIT_DataSeg dw 0
-
- public _KB_CheckCount ; Check keyboard for every 256 pred calls
- _KB_CheckCount db 0
-
- EVEN
- _STACK ENDS
-
- END
-