< -->

Program FPUCRead;
{$E-,N+}
var
  CR : Word;
Function FPUCR:Word;Assembler;
var
  tmp : Word;
asm
  fnstcw        tmp
  mov           ax, word ptr tmp
end;
Function Pi : Extended;Assembler;
asm
  fldpi
end;
Function r(z : Extended) : Extended;Assembler;{sqrt(a^2/3*z^4/3-z^2)}
asm
  fld   a                 {a}
  fld1                    {1\a}
  fld1                    {1\1\a}
  fld1                    {1\1\1\a}
  fadd                    {2\1\a}
  fadd  st(1), st(0)      {2\3\a}
  fxch                    {3\2\a}
  fdivp st(1), st(0)      {(2/3)\a}
  fxch                    {a\(2/3)}
  fyl2x                   {(2/3)*log2(a)}

  fld   st(0)             {-\-}
  fxtract                 {mant(-)\expon(-)\-}


  f2xm1                   {a^(2/3)-1}
  fld1                    {1\(aa-1)}
  fadd                    {aa}

  fld   z                 {z\aa}
  fld1                    {1\z\aa}
  fld1                    {1\1\z\aa}
  fld1                    {1\1\1\z\aa}
  fadd                    {2\1\z\aa}
  fadd  st(1), st(0)      {2\3\z\aa}
  fxch                    {3\2\z\aa}
  fdivp st(1), st(0)      {(2/3)\z\aa}
  fxch                    {z\(2/3)\aa}
  fyl2x                   {(2/3)*log2(z)\aa}
  f2xm1                   {z^(2/3)-1\aa}
  fld1                    {1\(zz-1)\aa}
  fadd                    {zz\aa}
  fld  st(0)              {zz\zz\aa}
  fmul                    {zzz\aa}
  fmul                    {z1}
  fld   z                 {z\z1}
  fld   st(0)             {z\z\z1}
  fmul                    {z^2\z1}
  fsubp st(1), st(0)      {uaz}

  fsqrt                   {sqrt(uaz)}
end;
begin
  CR := FPUCR;
  WriteLn('Резерв 15..13: ', CR shr 13);
  WriteLn('U 12: ', (CR shr 12) and 1);
  WriteLn('RC округление 11..10: ', (CR shr 10) and 3);
  WriteLn('PC точность 9..8: ', (CR shr 8) and 3);
  WriteLn('7..6: ', (CR shr 6) and 3);
  WriteLn('PM: ', (CR shr 5) and 1);
  WriteLn('UM: ', (CR shr 4) and 1);
  WriteLn('OM: ', (CR shr 3) and 1);
  WriteLn('ZM: ', (CR shr 2) and 1);
  WriteLn('DM: ', (CR shr 1) and 1);
  WriteLn('IM: ', CR and 1);
end.

Назад