1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
{ %CPU=I386 }
program test_fp_instructions;
function test : extended;
var
x,y : integer;
statusword,controlword : word;
z,t : longint;
a,b,c : comp;
begin
x:=5;
c:=5;
t:=5;
z:=4;
a:=20;
{ test all FPU instructions using 's' and 'l' suffix
for word and dword size PM }
{$asmmode att}
asm
fildl z
fiadds x
fistpq b
fildl z
ficoms x
fistpq b
fildl z
ficomps x
fildl z
fidivs x
fistpq b
fildl z
fidivrs x
fistpq b
fildl z
fisubs x
fistpq b
fildl z
fisubrs x
fistpq b
fildl z
fimuls x
fistpq b
end;
if a<>b then
begin
Writeln('Error in FPU att syntax code generation');
Halt(1);
end;
asm
fildl z
fiaddl t
fistpq b
fildl z
ficoml t
fistpq b
fildl z
ficompl t
fildl z
fidivl t
fistpq b
fildl z
fidivrl t
fistpq b
fildl z
fisubl t
fistpq b
fildl z
fisubrl t
fistpq b
fildl z
fimull t
fistpq b
end;
if a<>b then
begin
Writeln('Error in FPU att syntax code generation');
Halt(1);
end;
{ test CW and SW instructions }
{ FSTSW FNSTSW
FLDCW FSTCW FNSTCW }
asm
fstsw statusword
fstsww statusword
fnstsw statusword
fnstsww statusword
fstcw controlword
fstcww controlword
fnstcw controlword
fnstcww controlword
fldcw controlword
fldcww controlword
end;
{$asmmode intel}
asm
fild dword ptr z
fimul dword ptr t
fistp qword ptr b
fild dword ptr z
fimul word ptr x
fistp qword ptr b
end;
if a<>b then
begin
Writeln('Error in FPU code generation');
Halt(1);
end;
{ test CW and SW instructions }
asm
fstsw word ptr [statusword]
fnstsw word ptr [statusword]
fstcw word ptr [controlword]
fnstcw word ptr[controlword]
fldcw word ptr [controlword]
end;
test:=b;
end;
var
z : extended;
begin
z:=test;
end.
|