Program TestExcp;
uses excptest;

Procedure Do_Something;
var a:byte;
begin
a:=0;
writeln(2 div a); {I can't write just "2 div 0" because of the FPC sanity check :-)}
end;


var be:boolean;
begin

writeln('Let'#39's try to catch an exception.');
writeln('Try to catch ILL and GPF signals and execute SSE1 instruction.');
readln;

be:=Try_to_call_SSE_instruction;

if be=false
   then begin
   writeln('Oh no! Exception occured. But we survived that :-)');
   readln;
   writeln('Uninstalling handlers and going to standard handlers.');
   readln;
   end
   else begin
   writeln('No problem during executing the SSE1 instruction.');
   writeln;
   writeln('Now something different: try to call AVX instruction.');
   writeln('It should fail in any case. Either the processor does not');
   writeln('support it at all or it is disabled until explicitely allowed it.');
   readln;
   end;

if be=false then Halt(0);

be:=Try_to_call_AVX_instruction;

if be=false
   then begin
   writeln('Exception during AVX instruction (as we expected)');
   end
   else begin
   writeln('Huh? We performed AVX instruction without exception signal?');
   writeln('...a bit strange, but OK, no crash occured.');
   writeln('Uninstalling handlers and going to standard handlers.');
   readln;
   end;

writeln('Handlers uninstalled, everything is OK');
readln;
end.
