summaryrefslogtreecommitdiff
path: root/testasmcomp/tagged-integr.cmm
blob: cce79ebdcb47ff0fd5772efa9c3940187ec99cb9 (plain)
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
(***********************************************************************)
(*                                                                     *)
(*                           Objective Caml                            *)
(*                                                                     *)
(*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
(*                                                                     *)
(*  Copyright 1996 Institut National de Recherche en Informatique et   *)
(*  Automatique.  Distributed only by permission.                      *)
(*                                                                     *)
(***********************************************************************)

(* $Id$ *)

("res_square": skip 8)
("h": skip 8)
("x": skip 8)
("s": skip 8)
("res_integr": skip 8)

(function "square" (x: addr)
   (let r "res_square"
        (store r ( *f (load x float) (load x float)))
        r))

(function "integr" (f: addr low: addr high: addr n: int)
  (let (h "h" x "x" s "s" i n)
    (store h (/f (-f (load high float) (load low float)) (floatofint n)))
    (store x (load low float))
    (store s 0.0)
    (while (> i 0)
      (store s (+f (load s float) (load (app f x addr) float)))
      (store x (+f (load x float) (load h float)))
      (assign i (- i 1)))
    (store "res_integr" ( *f (load s float) (load h float)))
    "res_integr"))

("low": skip 8)
("hi": skip 8)

(function "test" (n: int)
  (store "low" 0.0)
  (store "hi" 1.0)
  (load (app "integr" ["square" "low" "hi" n] addr) float))