(* * * * * * * * * * * * * * * * * * *
 *
 * prog2-1.pas
 *
 * Demonstration of 
 *    getMcbPointer(...)
 *
 * * * * * * * * * * * * * * * * * * *)

program prog2_1;

uses    _globals,
        _mcb;

var
    mcbPtr:             MCB_McbPtr;
    
begin

    (*
     * fill Mem Cntl
     * block with info
     *)
    mcbPtr:= getMcbPointer;

    (*
     * print header
     *)
    writeln;
    writeln;
    writeln('Bax Boy''s Memory Display Program  (Rev .1) ');
    writeln;
    writeln('CHAIN   MCB     PSP    PARAGRAPHS ');
    writeln('----------------------------------');


    (*
     * loop and print MCB
     * information
     *)
    while True do begin

        (*
         * format buffer to print 
         * primitave information
         *)
        writeln(mcbPtr^.chain_status, '       ',
                hex(Seg(mcbPtr^), 4), '    ',
                hex(mcbPtr^.owner_psp, 4), '   ',
                mcbPtr^.size_paragraphs:6);

        (*
         * if the 'Z' is reached 
         * then break
         *)
        if mcbPtr^.chain_status = 'Z' then begin
            Exit;
            end

        (*
         * otherwise add 
         * paragraph size to 
         * pointer segment
         * and add 1 to cover mcb
         *)
        else begin
            mcbPtr:= Ptr(Seg(mcbPtr^)+mcbPtr^.size_paragraphs+1, 0);
            end;
        end;
end.
