program Test;
{$I sets.inc}

{ define TestHaltError}
{$define TestGenError}

uses
  crt,
  NumToStr,
  haltErr;

var
  OldExitProc:Pointer;

procedure MyExitProc; far;
begin
  ExitProc:=OldExitProc;

  if ExitCode<>0 then
  begin
    writeln('ExitCode: ',ExitCode, ', ErrAddr: ', PtrToStr(ErrorAddr));
  end;
 {$ifdef VerMC}
  asm sti end;
  repeat until false;
 {$endif}
end;

label
  a;
begin
  clrscr;
  writeln('Spusteni programu');

  OldExitProc:=ExitProc;
  ExitProc:=@MyExitProc;


  asm
{$ifdef TestHaltError}
    { test HaltError }
    mov  ax, 201
    call HaltError
{$endif}

{$ifdef TestGenError}
    mov  ax, 201
    push ax
    call far ptr @a
@a:
    call GenError
{$endif}
  end;
  writeln('Test1');
 {$ifdef VerMC}
  asm sti end;
  repeat until false;
 {$endif}
end.