Browse Source

* removed all explicit leave;ret commands and let them generate by
the compiler (needed for stack alignment)

peter 27 years ago
parent
commit
24cb89c2bd
1 changed files with 119 additions and 206 deletions
  1. 119 206
      rtl/i386/math.inc

+ 119 - 206
rtl/i386/math.inc

@@ -22,67 +22,48 @@
                        Real/Double data type routines
                        Real/Double data type routines
  ****************************************************************************}
  ****************************************************************************}
 
 
-    function pi : real;
-
-      begin
-         asm
+    function pi : real;assembler;
+      asm
             fldpi
             fldpi
             leave
             leave
             ret
             ret
-         end [];
-      end;
-
+      end [];
 
 
-    function abs(d : real) : real;
 
 
-      begin
-         asm
+    function abs(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fabs
             fabs
-            leave
-            ret $8
-         end [];
-      end;
+      end [];
 
 
-    function sqr(d : real) : real;
 
 
-      begin
-         asm
+    function sqr(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fldl 8(%ebp)
             fldl 8(%ebp)
             fmulp
             fmulp
-            leave
-            ret $8
-         end [];
-      end;
+      end [];
 
 
-    function sqrt(d : real) : real;
 
 
-      begin
-         asm
+    function sqrt(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fsqrt
             fsqrt
             leave
             leave
             ret $8
             ret $8
-         end [];
-      end;
+      end [];
 
 
-    function arctan(d : real) : real;
 
 
-      begin
-         asm
+    function arctan(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fld1
             fld1
             fpatan
             fpatan
-            leave
-            ret $8
-         end [];
-      end;
+      end [];
 
 
-    function cos(d : real) : real;
 
 
-      begin
-         asm
+    function cos(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fcos
             fcos
             fstsw
             fstsw
@@ -90,18 +71,15 @@
             jnp .LCOS1
             jnp .LCOS1
             fstp %st(0)
             fstp %st(0)
             fldl .LCOS0
             fldl .LCOS0
-         .LCOS1:
-            leave
-            ret $8
+            jmp .LCOS1
          .LCOS0:
          .LCOS0:
             .quad       0xffffffffffffffff
             .quad       0xffffffffffffffff
-         end ['EAX'];
-      end;
+         .LCOS1:
+      end ['EAX'];
 
 
-    function exp(d : real) : real;
 
 
-      begin
-         asm
+    function exp(d : real) : real;assembler;
+      asm
             // comes from DJ GPP
             // comes from DJ GPP
             fldl        8(%ebp)
             fldl        8(%ebp)
             fldl2e
             fldl2e
@@ -122,8 +100,7 @@
             faddp
             faddp
             fscale
             fscale
             fstp        %st(1)
             fstp        %st(1)
-            leave
-            ret $8
+            jmp         .LCW3
 
 
             // store some help data in the data segment
             // store some help data in the data segment
             .data
             .data
@@ -132,12 +109,11 @@
     .LCW2:
     .LCW2:
             .word       0
             .word       0
             .text
             .text
-         end;
+    .LCW3:
       end;
       end;
 
 
-    function frac(d : real) : real;
 
 
-      begin
+    function frac(d : real) : real;assembler;
          asm
          asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
@@ -154,15 +130,11 @@
             fstp %st(1)
             fstp %st(1)
             fclex
             fclex
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $8
-         end ['ECX'];
-      end;
+       end ['ECX'];
 
 
-    function int(d : real) : real;
 
 
-      begin
-         asm
+    function int(d : real) : real;assembler;
+       asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -175,15 +147,11 @@
             frndint
             frndint
             fclex
             fclex
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $8
-         end ['ECX'];
-      end;
+      end ['ECX'];
 
 
-    function trunc(d : real) : longint;
 
 
-      begin
-         asm
+    function trunc(d : real) : longint;assembler;
+      asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -196,15 +164,11 @@
             fistpl -8(%ebp)
             fistpl -8(%ebp)
             movl -8(%ebp),%eax
             movl -8(%ebp),%eax
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $8
-         end ['EAX','ECX'];
-      end;
+      end ['EAX','ECX'];
 
 
-    function round(d : real) : longint;
 
 
-      begin
-         asm
+    function round(d : real) : longint;assembler;
+      asm
             subl $8,%esp
             subl $8,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -215,27 +179,19 @@
             fistpl -8(%ebp)
             fistpl -8(%ebp)
             movl -8(%ebp),%eax
             movl -8(%ebp),%eax
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $8
-         end ['EAX','ECX'];
-      end;
+      end ['EAX','ECX'];
 
 
-    function ln(d : real) : real;
 
 
-      begin
-         asm
+    function ln(d : real) : real;assembler;
+      asm
             fldln2
             fldln2
             fldl 8(%ebp)
             fldl 8(%ebp)
             fyl2x
             fyl2x
-            leave
-            ret $8
-         end [];
-      end;
+      end [];
 
 
-    function sin(d : real) : real;
 
 
-      begin
-         asm
+    function sin(d : real) : real;assembler;
+      asm
             fldl 8(%ebp)
             fldl 8(%ebp)
             fsin
             fsin
             fstsw
             fstsw
@@ -243,13 +199,12 @@
             jnp .LSIN1
             jnp .LSIN1
             fstp %st(0)
             fstp %st(0)
             fldl .LSIN0
             fldl .LSIN0
-         .LSIN1:
-            leave
-            ret $8
+            jmp .LSIN1
          .LSIN0:
          .LSIN0:
             .quad       0xffffffffffffffff
             .quad       0xffffffffffffffff
-         end ['EAX'];
-      end;
+         .LSIN1:
+      end ['EAX'];
+
 
 
    function power(bas,expo : real) : real;
    function power(bas,expo : real) : real;
      begin
      begin
@@ -262,96 +217,73 @@
                        EXTENDED data type routines
                        EXTENDED data type routines
  ****************************************************************************}
  ****************************************************************************}
 
 
-    function pi : extended;{$ifdef MORECONST}[internconst:in_const_pi];{$endif}
-
-      begin
-         asm
+    function pi : extended;assembler;{$ifdef MORECONST}[internconst:in_const_pi];{$endif}
+      asm
             fldpi
             fldpi
-            leave
-            ret
-         end [];
-      end;
+      end [];
 
 
-    function abs(d : extended) : extended;[internconst:in_const_abs];
 
 
-      begin
-         asm
-            fldt 8(%ebp)
+    function abs(d : extended) : extended;assembler;[internconst:in_const_abs];
+      asm
+            fldt d
             fabs
             fabs
-            leave
-            ret $10
-         end [];
-      end;
+      end [];
 
 
-    function sqr(d : extended) : extended;[internconst:in_const_sqr];
 
 
-      begin
-         asm
-            fldt 8(%ebp)
-            fldt 8(%ebp)
+    function sqr(d : extended) : extended;assembler;[internconst:in_const_sqr];
+      asm
+            fldt d
+            fldt d
             fmulp
             fmulp
-            leave
-            ret $10
-         end [];
-      end;
+      end [];
 
 
-    function sqrt(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_sqrt];{$endif}
 
 
-      begin
-         asm
-            fldt 8(%ebp)
+    function sqrt(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_sqrt];{$endif}
+      asm
+            fldt d
             fsqrt
             fsqrt
-            leave
-            ret $10
-         end [];
-      end;
+      end [];
 
 
-    function arctan(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_arctan];{$endif}
 
 
-      begin
-         asm
-            fldt 8(%ebp)
+    function arctan(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_arctan];{$endif}
+      asm
+            fldt d
             fld1
             fld1
             fpatan
             fpatan
-            leave
-            ret $10
-         end [];
-      end;
+      end [];
 
 
-    function cos(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_cos];{$endif}
 
 
-      begin
-         asm
-            fldt 8(%ebp)
+    function cos(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_cos];{$endif}
+      asm
+            fldt d
             fcos
             fcos
             fstsw
             fstsw
             sahf
             sahf
             jnp .LCOS1
             jnp .LCOS1
             fstp %st(0)
             fstp %st(0)
             fldt .LCOS0
             fldt .LCOS0
-         .LCOS1:
-            leave
-            ret $10
+            jmp .LCOS1
+         .data
          .LCOS0:
          .LCOS0:
             .long       0xffffffff
             .long       0xffffffff
             .long       0xffffffff
             .long       0xffffffff
-            .word       0xffff
-         end ['EAX'];
-      end;
+            .long       0xffffffff
+         .text
+         .LCOS1:
+      end ['EAX'];
 
 
-    function exp(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_exp];{$endif}
 
 
-      begin
-         asm
+    function exp(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_exp];{$endif}
+       asm
             // comes from DJ GPP
             // comes from DJ GPP
-            fldt        8(%ebp)
+            fldt        d
             fldl2e
             fldl2e
             fmulp
             fmulp
             fstcw      .LCW1
             fstcw      .LCW1
             fstcw      .LCW2
             fstcw      .LCW2
             fwait
             fwait
             andw        $0xf3ff,.LCW2
             andw        $0xf3ff,.LCW2
-            orw $0x0400,.LCW2
+            orw         $0x0400,.LCW2
             fldcw      .LCW2
             fldcw      .LCW2
             fld         %st(0)
             fld         %st(0)
             frndint
             frndint
@@ -363,23 +295,20 @@
             faddp
             faddp
             fscale
             fscale
             fstp        %st(1)
             fstp        %st(1)
-            leave
-            ret $10
-
+            jmp         .LCW3
             // store some help data in the data segment
             // store some help data in the data segment
-            .data
-    .LCW1:
+        .data
+        .LCW1:
             .word       0
             .word       0
-    .LCW2:
+        .LCW2:
             .word       0
             .word       0
-            .text
-         end;
+        .text
+        .LCW3:
       end;
       end;
 
 
-    function frac(d : extended) : extended;[internconst:in_const_frac];
 
 
-      begin
-         asm
+    function frac(d : extended) : extended;assembler;[internconst:in_const_frac];
+      asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -388,22 +317,18 @@
             movw %cx,-8(%ebp)
             movw %cx,-8(%ebp)
             fldcw -8(%ebp)
             fldcw -8(%ebp)
             fwait
             fwait
-            fldt 8(%ebp)
+            fldt d
             frndint
             frndint
-            fldt 8(%ebp)
+            fldt d
             fsub %st(1)
             fsub %st(1)
             fstp %st(1)
             fstp %st(1)
             fclex
             fclex
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $10
-         end ['ECX'];
-      end;
+      end ['ECX'];
 
 
-    function int(d : extended) : extended;[internconst:in_const_int];
 
 
-      begin
-         asm
+    function int(d : extended) : extended;assembler;[internconst:in_const_int];
+      asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -412,19 +337,15 @@
             movw %cx,-8(%ebp)
             movw %cx,-8(%ebp)
             fldcw -8(%ebp)
             fldcw -8(%ebp)
             fwait
             fwait
-            fldt 8(%ebp)
+            fldt d
             frndint
             frndint
             fclex
             fclex
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $10
-         end ['ECX'];
-      end;
+      end ['ECX'];
 
 
-    function trunc(d : extended) : longint;[internconst:in_const_trunc];
 
 
-      begin
-         asm
+    function trunc(d : extended) : longint;assembler;[internconst:in_const_trunc];
+      asm
             subl $16,%esp
             subl $16,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
@@ -433,69 +354,57 @@
             movw %cx,-8(%ebp)
             movw %cx,-8(%ebp)
             fldcw -8(%ebp)
             fldcw -8(%ebp)
             fwait
             fwait
-            fldt 8(%ebp)
+            fldt d
             fistpl -8(%ebp)
             fistpl -8(%ebp)
             movl -8(%ebp),%eax
             movl -8(%ebp),%eax
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $10
-         end ['EAX','ECX'];
-      end;
+      end ['EAX','ECX'];
 
 
-    function round(d : extended) : longint;[internconst:in_const_round];
 
 
-      begin
-         asm
+    function round(d : extended) : longint;assembler;[internconst:in_const_round];
+      asm
             subl $8,%esp
             subl $8,%esp
             fnstcw -4(%ebp)
             fnstcw -4(%ebp)
             fwait
             fwait
             movw $0x1372,-8(%ebp)
             movw $0x1372,-8(%ebp)
             fldcw -8(%ebp)
             fldcw -8(%ebp)
             fwait
             fwait
-            fldt 8(%ebp)
+            fldt d
             fistpl -8(%ebp)
             fistpl -8(%ebp)
             movl -8(%ebp),%eax
             movl -8(%ebp),%eax
             fldcw -4(%ebp)
             fldcw -4(%ebp)
-            leave
-            ret $10
-         end ['EAX','ECX'];
-      end;
+      end ['EAX','ECX'];
 
 
-    function ln(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_ln];{$endif}
 
 
-      begin
-         asm
+    function ln(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_ln];{$endif}
+      asm
             fldln2
             fldln2
-            fldt 8(%ebp)
+            fldt d
             fyl2x
             fyl2x
-            leave
-            ret $10
-         end [];
-      end;
+      end [];
 
 
-    function sin(d : extended) : extended;{$ifdef MORECONST}[internconst:in_const_sin];{$endif}
 
 
-      begin
-         asm
-            fldt 8(%ebp)
+    function sin(d : extended) : extended;assembler;{$ifdef MORECONST}[internconst:in_const_sin];{$endif}
+      asm
+            fldt d
             fsin
             fsin
             fstsw
             fstsw
             sahf
             sahf
             jnp .LSIN1
             jnp .LSIN1
             fstp %st(0)
             fstp %st(0)
             fldt .LSIN0
             fldt .LSIN0
-         .LSIN1:
-            leave
-            ret $10
+            jmp .LSIN1
+         .data
          .LSIN0:
          .LSIN0:
             .long       0xffffffff
             .long       0xffffffff
             .long       0xffffffff
             .long       0xffffffff
-            .word       0xffff
-         end ['EAX'];
-      end;
+            .long       0xffffffff
+         .text
+         .LSIN1:
+      end ['EAX'];
 
 
-   function power(bas,expo : extended) : extended;
 
 
+   function power(bas,expo : extended) : extended;
      begin
      begin
         power:=exp(ln(bas)*expo);
         power:=exp(ln(bas)*expo);
      end;
      end;
@@ -634,7 +543,11 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.11  1998-11-16 14:26:03  pierre
+  Revision 1.12  1998-11-24 12:54:57  peter
+    * removed all explicit leave;ret commands and let them generate by
+      the compiler (needed for stack alignment)
+
+  Revision 1.11  1998/11/16 14:26:03  pierre
    * changed fsqrtl to fsqrt (needed by as v2.9.4 for win32)
    * changed fsqrtl to fsqrt (needed by as v2.9.4 for win32)
 
 
   Revision 1.10  1998/10/02 09:25:29  peter
   Revision 1.10  1998/10/02 09:25:29  peter