program shift(input,output);
{
This demonstrates how the machine code routine at the start of the file is
called.  It used OSBYTE to deduce its address (by finding OSHWM) and calls
the code three bytes above that. If the machine code were not relocatable,
its address  might  as  well be declared in a constant declaration, as the
program would work at any other location. }

const
    osbyte    = &FFF4;        { Operating system call }
    findOshwm = 131;          { Code to find OSHWM }
    mcOffset  = 3;            { Offset from OSHWM to code }

var
    count     : integer;      { Looping variable }
    mcAddr    : integer;      { Address of machine code }
    oshwm     : integer;      { Current OSHWM value }
    anInteger : integer;      { A variable accessed by 'shift' }
    dummy     : integer;      { A dummy variable for code1 }

begin
    { Find OSHWM - Returned in XY hence the mod and div }
    oshwm := code0(osbyte,findOshwm,0,0) mod &1000000 div &100;
    mcAddr := oshwm + mcOffset;
    { Simply print the integer and shift it left, 32 times }
    for count := 0 to 31 do
        begin
            anInteger := 1;
            dummy := code1(mcAddr,count,anInteger);
            write(~anInteger : 10)
        end;
    writeln
end.
