raz / test / mac / Sqrt.raz

35 lines · 660 B · raw · history · last change e99cab9b

1(* A code procedure that is a square root of d0 and ret is made in
2 place of its call (Gen.oneRealOp), as Math.sqrt is on x86-64; F32's
3 too. Its own here, as lib/Math.raz has x86-64's yet. *)
4module Sqrt;
5import Out, Fmt;
6import SYSTEM;
7
8proc root(x: F64): F64;
9code
10 fsqrt d0, d0;
11 ret;
12end root;
13
14proc root32(x: F32): F32;
15code
16 fsqrt s0, s0;
17 ret;
18end root32;
19
20proc real(x: F64);
21var b: [Fmt.ShortMost]U8;
22begin
23 Out.str(Fmt.short(x, b)); Out.str(" ");
24end;
25
26proc main*;
27var x: F64; f: F32;
28begin
29 x := 2.0;
30 real(root(x)); real(root(x * 8.0) + 1.0);
31 f := 2.0;
32 real(F64(root32(f))); real(root(-x)); Out.ln;
33end;
34
35end Sqrt.