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

 
Output of file : OPTZTEST.LST contained in archive : PCTJ8804.ZIP
program optztest;
const
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;
begin {optztest}

OPTZTEST:@:
2EDA:0000 CALL SYSTEM:@
2EDA:0005 MOV BP,SP
2EDA:0007 SUB SP,0202

i := 5; { Test arithmetic identities }

2EDA:000B MOV Word Ptr [00A2],0005

j := i + 0;

2EDA:0011 MOV AX,[00A2]
2EDA:0014 ADD AX,0000 ; superfluous
2EDA:0017 MOV [00A4],AX

k := i div 1;

2EDA:001A MOV AX,[00A2]
2EDA:001D CWD ; superfluous
2EDA:001E MOV CX,0001 ; "
2EDA:0021 IDIV CX ; "
2EDA:0023 MOV [00A6],AX

l := i * 1;

2EDA:0026 MOV AX,[00A2]
2EDA:0029 XOR CX,CX ; superfluous, but
2EDA:002B SHL AX,CL ; does SHL, not IMUL
2EDA:002D MOV [00A8],AX

i2 := 1; { Test strength reduction }

2EDA:0030 MOV Word Ptr [00AA],0001

j2 := 2 * i2;

2EDA:0036 MOV AX,[00AA]
2EDA:0039 SHL AX,1 ; SHL instead of IMUL
2EDA:003B MOV [00AC],AX

k2 := 4 * i2;

2EDA:003E MOV AX,[00AA]
2EDA:0041 MOV CX,0002 ; SHL instead of IMUL
2EDA:0044 SHL AX,CL ; "
2EDA:0046 MOV [00AE],AX

IVector[0] := 1; { See how subscripts are handled }

2EDA:0049 MOV Word Ptr [00C3],0001

IVector[i2] := 2; { i2 remains 1 }

2EDA:004F MOV DI,[00AA]
2EDA:0053 SHL DI,1
2EDA:0055 MOV Word Ptr [DI+00C3],0002

IVector[i2] := 2;

2EDA:005B MOV DI,[00AA] ; No reuse of offset
2EDA:005F SHL DI,1 ; or subscript
2EDA:0061 MOV Word Ptr [DI+00C3],0002

IVector[2] := 3;

2EDA:0067 MOV Word Ptr [00C7],0003

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

2EDA:006D MOV Word Ptr [00B4],0003 ; Constant folded

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

2EDA:0073 MOV AX,[00B4]
2EDA:0076 ADD AX,0003 ; No propagation
2EDA:0079 MOV [00B6],AX

k3 := 6; { Test common subexpression elimination }

2EDA:007C MOV Word Ptr [00B8],0006

g3 := i3 + j3 * k3;

2EDA:0082 MOV AX,[00B6] ; Common
2EDA:0085 IMUL Word Ptr [00B8] ; expression
2EDA:0089 ADD AX,[00B4]
2EDA:008D MOV [00B0],AX

h3 := (j3 * k3) div i3;

2EDA:0090 MOV AX,[00B6] ; Common
2EDA:0093 IMUL Word Ptr [00B8] ; expression
2EDA:0097 CWD ; not eliminated
2EDA:0098 IDIV Word Ptr [00B4]
2EDA:009C MOV [00B2],AX

for i4 := 0 to Max_Vector do { Test invariant code motion }

2EDA:009F XOR AX,AX ; Good !
2EDA:00A1 MOV [00BA],AX
2EDA:00A4 JMP @+AA (00AA)
2EDA:00A6 INC Word Ptr [00BA] ; Good !

IVector2[i4] := j * k; { byte array }

2EDA:00AA MOV AX,[00A4] ; invariant j * k
2EDA:00AD IMUL Word Ptr [00A6] ; not removed from
2EDA:00B1 MOV DI,[00BA] ; loop
2EDA:00B5 MOV [DI+00C9],AL
2EDA:00B9 CMP Word Ptr [00BA],+02
2EDA:00BE JNZ @+A6 (00A6)

for i4 := 0 to 2 do
begin

2EDA:00C0 XOR AX,AX
2EDA:00C2 MOV [00BA],AX
2EDA:00C5 JMP @+CB (00CB)
2EDA:00C7 INC Word Ptr [00BA]

IVector3[i4] := i4 * 4; { strength reduction }

2EDA:00CB MOV AX,[00BA]
2EDA:00CE MOV CX,0002 ; SHL replaces IMUL
2EDA:00D1 SHL AX,CL ; "
2EDA:00D3 MOV DI,[00BA]
2EDA:00D7 SHL DI,1
2EDA:00D9 MOV [DI+00CC],AX

IVector2[i4] := IVector2[i4] + IVector3[i4];

2EDA:00DD MOV DI,[00BA] ; IVector2[i4]
2EDA:00E1 MOV AL,[DI+00C9] ; on right side
2EDA:00E5 XOR AH,AH
2EDA:00E7 MOV DI,[00BA]
2EDA:00EB SHL DI,1
2EDA:00ED ADD AX,[DI+00CC]
2EDA:00F1 MOV DI,[00BA] ; IVector2[i4]
2EDA:00F5 MOV [DI+00C9],AL ; on left side

end;

2EDA:00F9 CMP Word Ptr [00BA],+02
2EDA:00FE JNZ @+C7 (00C7)

j5 := 0; { Look at code for simple loop }

2EDA:0100 XOR AX,AX
2EDA:0102 MOV [00BE],AX

k5 := 10000;

2EDA:0105 MOV Word Ptr [00C0],2710

repeat
k5 := k5 - 1;

2EDA:010B MOV AX,[00C0] ; DEC [00C0]
2EDA:010E DEC AX ; would be simpler
2EDA:010F MOV [00C0],AX ; "

j5 := j5 + 1;

2EDA:0112 MOV AX,[00BE] ; INC [00BE]
2EDA:0115 INC AX ; would be simpler
2EDA:0116 MOV [00BE],AX ; "

i5 := (k5 * 3) div (j5 * Constant5);

2EDA:0119 MOV AX,[00BE]
2EDA:011C MOV CX,0005
2EDA:011F IMUL CX
2EDA:0121 MOV BX,AX ; Uses BX register
2EDA:0123 MOV AX,[00C0] ; .
2EDA:0126 MOV CX,0003 ; .
2EDA:0129 IMUL CX ; .
2EDA:012B CWD ; for temporary
2EDA:012C IDIV BX ; storage
2EDA:012E MOV [00BC],AX

until k5 = 0;

2EDA:0131 CMP Word Ptr [00C0],+00
2EDA:0136 JNZ 010B
.
.
.


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

  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/