File Archive

 
Output of file : MAIN.PAS contained in archive : ITP9012.ZIP

{$M 16384,0,0 -- 16k stack, no heap!}
PROGRAM Main;

USES MemAlloc, Init;

TYPE
Str8 = String [8];
Str9 = String [9];

FUNCTION Hex (Value: Longint; NDigits: Byte): Str8;
{Convert an integer value into a hexadecimal string.}
CONST
HexDigits: ARRAY [0 .. 15] OF Char = '0123456789ABCDEF';

VAR
I: Byte;
HexStr: Str8;

BEGIN {Hex}
FOR I := NDigits DOWNTO 1 DO
BEGIN
HexStr [I] := HexDigits [Value AND $F];
Value := Value SHR 4;
END;

HexStr [0] := Char (NDigits); {set string length}
Hex := HexStr;
END; {Hex}

FUNCTION HexAddr (Value: Pointer): Str9;
BEGIN {HexAddr}
HexAddr := Hex (Seg (Value^), 4) + ':' +
Hex (ofs (Value^), 4);
END; {HexAddr}

VAR
P: Pointer;

BEGIN {Main}
Initialize;

WriteLn ('@Initialize = ', HexAddr (@Initialize));

{The size below, 75 bytes, was picked to illustrate the fact
that the "Initialize" procedure is being reused; 75 happens
to be the size of the sample routine given in Listing 3.}

IF GetMem (P, DiffPtr(@Initialize,@InitEnd)) THEN
WriteLn ('"P" allocated at ', HexAddr (P))
ELSE
WriteLn ('GetMem failed!');
END. {Main}