Forgot to mention that this patch works with doubles (8 bytes) because that
is what the disassembler was set up with.  However, both print_n and
Configure.pl seem to prefer long doubles (12 bytes).  I have no clue which
one ya'll want to use, however, the patch below includes my previous patch,
but also patches basic_operations.ops to do a %f instead of a %Lf (in other
words it prefers doubles over long doubles).  I tried fixing the
Configure.pl stuff, but no matter what I did it still gave me long doubles
as the type...therefore, you have to manually go in and change config.h to
be double.  I assume this will eventually be taken care of by the configure
system, but if you wish to use long doubles I will see what I can do.

Thanks!
Tanton

Index: assemble.pl
===================================================================
RCS file: /home/perlcvs/parrot/assemble.pl,v
retrieving revision 1.8
diff -u -r1.8 assemble.pl
--- assemble.pl 2001/09/12 09:54:46     1.8
+++ assemble.pl 2001/09/13 07:03:52
@@ -16,20 +16,20 @@
              n => 'd',
          );
 
-my %real_type=('i'=>'i',
-              'n'=>'n',
-              'N'=>'i',
-              'I'=>'i',
-              'S'=>'i',
-              's'=>'i',
-              'D'=>'i');
+my %real_type=('i'=>'l',
+              'n'=>'d',
+              'N'=>'l',
+              'I'=>'l',
+              'S'=>'l',
+              's'=>'l',
+              'D'=>'l');
 
 my $sizeof_packi = length(pack($pack_type{i},1024));
 
 open GUTS, "interp_guts.h";
 my $opcode;
 while (<GUTS>) {
-    next unless /\tx\[(\d+)\] = ([a-z_]+);/;
+    next unless /\tx\[(\d+)\] = ([a-z0-9_]+);/;
     $opcodes{$2}{CODE} = $1;
 }
 
Index: basic_opcodes.ops
===================================================================
RCS file: /home/perlcvs/parrot/basic_opcodes.ops,v
retrieving revision 1.8
diff -u -r1.8 basic_opcodes.ops
--- basic_opcodes.ops   2001/09/12 18:39:12     1.8
+++ basic_opcodes.ops   2001/09/13 07:03:52
@@ -5,6 +5,7 @@
  */
 
 #include "parrot.h"
+#include "math.h"
 
 // SET Ix, CONSTANT
 AUTO_OP set_i_ic {
@@ -208,7 +209,7 @@
 
 // PRINT Nx
 AUTO_OP print_n {
-  printf("N reg %li is %Lf\n", P1, NUM_REG(P1));
+  printf("N reg %li is %f\n", P1, NUM_REG(P1));
 }
  
 // INC Nx
@@ -329,3 +330,205 @@
 // NOOP
 AUTO_OP noop {
 }
+
+// TRANSCENDENTAL MATH FUNCTIONS
+
+// sin_n_n
+AUTO_OP sin_n_n {
+   NUM_REG(P1) = sin(NUM_REG(P2));
+}
+
+// cos_n_n
+AUTO_OP cos_n_n {
+   NUM_REG(P1) = cos(NUM_REG(P2));
+}
+
+// tan_n_n
+AUTO_OP tan_n_n {
+   NUM_REG(P1) = tan(NUM_REG(P2));
+}
+
+// sec_n_n
+AUTO_OP sec_n_n {
+   NUM_REG(P1) = ((NV)1) / cos(NUM_REG(P2));
+}
+
+// atan_n_n
+AUTO_OP atan_n_n {
+   NUM_REG(P1) = atan(NUM_REG(P2));
+}
+
+// atan2_n_n_n
+AUTO_OP atan2_n_n_n {
+   NUM_REG(P1) = atan2(NUM_REG(P2), NUM_REG(P3));
+}
+
+// asin_n_n
+AUTO_OP asin_n_n {
+   NUM_REG(P1) = asin(NUM_REG(P2));
+}
+
+// acos_n_n
+AUTO_OP acos_n_n {
+   NUM_REG(P1) = acos(NUM_REG(P2));
+}
+
+// asec_n_n
+AUTO_OP asec_n_n {
+   NUM_REG(P1) = acos(((NV)1) / NUM_REG(P2));
+}
+
+// cosh_n_n
+AUTO_OP cosh_n_n {
+   NUM_REG(P1) = cosh(NUM_REG(P2));
+}
+
+// sinh_n_n
+AUTO_OP sinh_n_n {
+   NUM_REG(P1) = sinh(NUM_REG(P2));
+}
+
+// tanh_n_n
+AUTO_OP tanh_n_n {
+   NUM_REG(P1) = tanh(NUM_REG(P2));
+}
+
+// sech_n_n
+AUTO_OP sech_n_n {
+   NUM_REG(P1) = ((NV)1) / cosh(NUM_REG(P2));
+}
+
+// log2_n_n
+AUTO_OP log2_n_n {
+   NUM_REG(P1) = log(NUM_REG(P2)) / log((NV)2);
+}
+
+// log10_n_n
+AUTO_OP log10_n_n {
+   NUM_REG(P1) = log10(NUM_REG(P2));
+}
+
+// ln_n_n
+AUTO_OP ln_n_n {
+   NUM_REG(P1) = log(NUM_REG(P2));
+}
+
+// exp_n_n
+AUTO_OP exp_n_n {
+   NUM_REG(P1) = exp(NUM_REG(P2));
+}
+
+// pow_n_n_n
+AUTO_OP pow_n_n_n {
+   NUM_REG(P1) = pow(NUM_REG(P2), NUM_REG(P3));
+}
+
+// sin_n_i
+AUTO_OP sin_n_i {
+   NUM_REG(P1) = sin(INT_REG(P2));
+}
+
+// cos_n_i
+AUTO_OP cos_n_i {
+   NUM_REG(P1) = cos(INT_REG(P2));
+}
+
+// tan_n_i
+AUTO_OP tan_n_i {
+   NUM_REG(P1) = tan(INT_REG(P2));
+}
+
+// sec_n_i
+AUTO_OP sec_n_i {
+   NUM_REG(P1) = ((NV)1) / cos(INT_REG(P2));
+}
+
+// atan_n_i
+AUTO_OP atan_n_i {
+   NUM_REG(P1) = atan(INT_REG(P2));
+}
+
+// atan2_n_n_i
+AUTO_OP atan2_n_n_i {
+   NUM_REG(P1) = atan2(NUM_REG(P2), INT_REG(P3));
+}
+
+// atan2_n_i_n
+AUTO_OP atan2_n_i_n {
+   NUM_REG(P1) = atan2(INT_REG(P2), NUM_REG(P3));
+}
+
+// atan2_n_i_i
+AUTO_OP atan2_n_i_i {
+   NUM_REG(P1) = atan2(INT_REG(P2), INT_REG(P3));
+}
+
+// asin_n_i
+AUTO_OP asin_n_i {
+   NUM_REG(P1) = asin(INT_REG(P2));
+}
+
+// acos_n_i
+AUTO_OP acos_n_i {
+   NUM_REG(P1) = acos(INT_REG(P2));
+}
+
+// asec_n_i
+AUTO_OP asec_n_i {
+   NUM_REG(P1) = acos(((NV)1) / ((NV)INT_REG(P2)));
+}
+
+// cosh_n_i
+AUTO_OP cosh_n_i {
+   NUM_REG(P1) = cosh(INT_REG(P2));
+}
+
+// sinh_n_i
+AUTO_OP sinh_n_i {
+   NUM_REG(P1) = sinh(INT_REG(P2));
+}
+
+// tanh_n_i
+AUTO_OP tanh_n_i {
+   NUM_REG(P1) = tanh(INT_REG(P2));
+}
+
+// sech_n_i
+AUTO_OP sech_n_i {
+   NUM_REG(P1) = ((NV)1) / cosh(INT_REG(P2));
+}
+
+// log2_n_i
+AUTO_OP log2_n_i {
+   NUM_REG(P1) = log(INT_REG(P2)) / log((NV)2);
+}
+
+// log10_n_i
+AUTO_OP log10_n_i {
+   NUM_REG(P1) = log10(INT_REG(P2));
+}
+
+// ln_n_i
+AUTO_OP ln_n_i {
+   NUM_REG(P1) = log(INT_REG(P2));
+}
+
+// exp_n_i
+AUTO_OP exp_n_i {
+   NUM_REG(P1) = exp(INT_REG(P2));
+}
+
+// pow_n_n_i
+AUTO_OP pow_n_n_i {
+   NUM_REG(P1) = pow(NUM_REG(P2), INT_REG(P3));
+}
+
+// pow_n_i_i
+AUTO_OP pow_n_i_i {
+   NUM_REG(P1) = pow(INT_REG(P2), INT_REG(P3));
+}
+
+// pow_n_n_i
+AUTO_OP pow_n_i_n {
+   NUM_REG(P1) = pow(INT_REG(P2), NUM_REG(P3));
+}
\ No newline at end of file
Index: disassemble.pl
===================================================================
RCS file: /home/perlcvs/parrot/disassemble.pl,v
retrieving revision 1.4
diff -u -r1.4 disassemble.pl
--- disassemble.pl      2001/09/12 09:54:46     1.4
+++ disassemble.pl      2001/09/13 07:03:52
@@ -28,7 +28,7 @@
 open GUTS, "interp_guts.h";
 my $opcode;
 while (<GUTS>) {
-    next unless /\tx\[(\d+)\] = ([a-z_]+);/;
+    next unless /\tx\[(\d+)\] = ([a-z0-9_]+);/;
     $opcodes{$2}{CODE} = $1;
 }
 
Index: opcode_table
===================================================================
RCS file: /home/perlcvs/parrot/opcode_table,v
retrieving revision 1.9
diff -u -r1.9 opcode_table
--- opcode_table        2001/09/12 18:39:12     1.9
+++ opcode_table        2001/09/13 07:03:53
@@ -102,3 +102,45 @@
 clear_n        0
 clear_p        0
 
+# Transcendental Math Ops
+
+sin_n_n        2       N N
+cos_n_n        2       N N
+tan_n_n        2       N N
+sec_n_n        2       N N
+atan_n_n       2       N N
+atan2_n_n_n    3       N N N
+asin_n_n       2       N N
+acos_n_n       2       N N
+asec_n_n       2       N N
+cosh_n_n       2       N N
+sinh_n_n       2       N N
+tanh_n_n       2       N N
+sech_n_n       2       N N
+log2_n_n       2       N N
+log10_n_n      2       N N
+ln_n_n         2       N N
+exp_n_n        2       N N
+pow_n_n_n      3       N N N
+sin_n_i        2       N I
+cos_n_i        2       N I
+tan_n_i        2       N I
+sec_n_i        2       N I
+atan_n_i       2       N I
+atan2_n_n_i    3       N N I
+atan2_n_i_n    3       N I N
+atan2_n_i_i    3       N I I
+asin_n_i       2       N I
+acos_n_i       2       N I
+asec_n_i       2       N I
+cosh_n_i       2       N I
+sinh_n_i       2       N I
+tanh_n_i       2       N I
+sech_n_i       2       N I
+log2_n_i       2       N I
+log10_n_i      2       N I
+ln_n_i         2       N I
+exp_n_i        2       N I
+pow_n_n_i      3       N N I
+pow_n_i_i      3       N I I
+pow_n_i_n      3       N I N

Reply via email to