Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : OPTZTEST.PAS

 
Output of file : OPTZTEST.PAS contained in archive : PCTJ8804.ZIP
{$R-} {Range checking off}
{$B+} {Boolean complete evaluation on}
{$S+} {Stack checking on}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
{$T+} {Turbo map on}
{$D+} {Debug on}

{ Test code optimizations done by Turbo Pascal Version 4.0.
Run with SYMDEB, Periscope debugger, or other compatible
source level debugger and look at the generated code.

Copyright (c) 1988, Ben Myers }

program optztest;

const
_Copyright : string[80] = 'Copyright 1987, Ben Myers';
Source_String : string [80] =
'Source data for string manipulation test';
Max_Vector = 2;
Constant5 = 5;

var
i, j, k, l, i2, j2, k2 : integer;
g3, h3, i3, j3, k3, i4, i5, j5, k5 : integer;
i6 : byte;
IVector : array [0..2] of integer;
IVector2 : array [0..2] of byte;
IVector3 : array [0..2] of integer;
Target_String : string[80];
String_Length : integer;

begin {optztest}
i := 5; { Test arithmetic identities }
j := i + 0;
k := i div 1;
l := i * 1;

i2 := 1; { Test strength reduction }
j2 := 2 * i2;
k2 := 4 * i2;

IVector[0] := 1; { See how subscripts are handled }
IVector[i2] := 2; { i2 remains 1 }
IVector[i2] := 2; { see what register optimizations are done }
IVector[2] := 3;

i3 := 1 + 2; { Test constant arithmetic }

j3 := i3 + 3; { Test constant propagation }

k3 := 6; { Test common subexpression elimination }
g3 := i3 + j3 * k3;
h3 := (j3 * k3) div i3;

for i4 := 0 to Max_Vector do { Test invariant code motion }
IVector2[i4] := j * k; { byte array }

{ Test strength reduction and subscripting }
for i4 := 0 to 2 do
begin
IVector3[i4] := i4 * 4; { strength reduction }
IVector2[i4] := IVector2[i4] + IVector3[i4];
end;

j5 := 0; { Look at code for simple loop }
k5 := 10000;
repeat
k5 := k5 - 1;
j5 := j5 + 1;
i5 := (k5 * 3) div (j5 * Constant5);
until k5 = 0;

Target_String := ''; { Look at code for string operations }
for i4 := 1 to length(Source_String) do
Target_String := Target_String + Source_String[i4];
String_Length := length(Source_String);
for i4 := 1 to String_Length do
Target_String := concat (Target_String,Source_String[i4]);
Target_String := Source_String;
{ Write out all results }
Writeln ( i:4, j:4, k:4, l:4 );
Writeln ( i2:4,j2:4,k2:4 );
for i4 := 0 to 2 do
Write ( IVector[i4]:4 );
Writeln;
Writeln ( g3:4, h3:4, i3:4, j3:4 );
for i4 := 0 to 2 do
Write ( IVector2[i4]:4 );
Writeln;
for i4 := 0 to 2 do
Write ( IVector3[i4]:4 );
Writeln;
Writeln ( i5:4, j5:6, k5:4 );
Writeln ( Target_String );

end. {optztest}


  3 Responses to “Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : OPTZTEST.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/