home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
MEMMAP01
/
UPDATE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-11-20
|
4KB
|
116 lines
{UPDATE ver 1.00 Copyright (C) 1992, John H. Gohde, All Rights Reserved }
{
Put this unit in the Target Program to be debugged. If you want keep
track of STACK & HEAP usage.
}
{This unit and software code is COPYRIGHTED MATERIAL and may only be used }
{in accordance with the following LICENSE: }
{ 1. If you alter it in any way, the copyright notice must not be }
{ changed. }
{ 2. If you use code excerpts in your own programs, due credit must be }
{ given, along with a copyright notice - }
{ "Parts Copyright 1992 John H. Gohde" }
{ 3. This software code may not be used for any commerical purpose which}
{ charges money for a program or software code that substantially }
{ Duplicates what this code does.
{ If you find this unit useful here is the author's contact address: }
{ John H. Gohde }
{ MEMMAP }
{ P O BOX 17581 }
{ RICHMOND, VA 23226-7581 }
{ USA }
{ }
{ FidoNet: }
{ 1:264/212,The FreeBoard BBS }
{ 1:264/152,The Inter City BBS }
{$A+,B-,D-,E-,F+,G-,I-,L-,N-,O-,R-,S-,V+,X-}
unit Update;
interface
uses
Dos,
Misc;
const
MinStack: Word=MaxInt; {Assures value is not always zero.}
MaxStack: Word=0; {Starts counting at a known value.}
MinHeap: Longint=MaxInt; {Assures value is not always zero.}
MaxHeap: Longint=0; {Starts counting at a known value.}
{**************************************************************************}
procedure PollStatus;
{Polls Heap & Stack Usage}
function PtrDiff(Hi, Lo: Pointer) : Longint;
{size difference between 2 pointers}
function WordDiff(Hi,Lo:Word):Longint;
{size difference between 2 word segments}
function UsedHeap:Longint;
{Computes Heap used}
function UsedStack: Word;
{computes Stack Used}
{**************************************************************************}
implementation
{UPDATE ver 1.00 Copyright (C) 1992, John H. Gohde, All Rights Reserved }
{**************************************************************************}
function PtrDiff(Hi, Lo: Pointer) : Longint;
var
High, Low: Longint;
BEGIN
High := Longint(Seg(Hi^)) shl 4+Longint(Ofs(Hi^));
Low := Longint(Seg(Lo^)) shl 4+Longint(Ofs(Lo^));
PtrDiff := High-Low;
END;
function WordDiff(Hi,Lo:Word):Longint;
BEGIN
WordDiff:=(PtrDiff(ptr(Hi,0),ptr(Lo,0)));
END;
function UsedHeap:Longint;
BEGIN
UsedHeap:=PtrDiff(HeapPtr,HeapOrg);
END;
function UsedStack: Word;
BEGIN
UsedStack:=PtrDiff(ptr(OvrHeapOrg,0),ptr(SSeg,SPtr));
END;
procedure PollStatus;
var
Stack:Word;
Heap:Longint;
BEGIN
Stack:=UsedStack;
Heap:=UsedHeap;
MinStack:=Min(MinStack,Stack);
MaxStack:=Max(MaxStack,Stack);
MinHeap:=Min(MinHeap,Heap);
MaxHeap:=Max(MaxHeap,Heap);
END;
{**************************************************************************}
end.
{UPDATE ver 1.00 Copyright (C) 1992, John H. Gohde, All Rights Reserved }