aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/cfrac/phalf.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
commit77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507 (patch)
tree93d4e30a207265af03394d347bfff76ba677f3ce /src/benchmarks/cfrac/phalf.c
parent971adefadb94e8780b1a73f08ed11d76c2ead8a2 (diff)
downloadallocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.tar.gz
allocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.zip
add cfrac benchmark
Diffstat (limited to 'src/benchmarks/cfrac/phalf.c')
-rw-r--r--src/benchmarks/cfrac/phalf.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/benchmarks/cfrac/phalf.c b/src/benchmarks/cfrac/phalf.c
new file mode 100644
index 0000000..8658de5
--- /dev/null
+++ b/src/benchmarks/cfrac/phalf.c
@@ -0,0 +1,36 @@
+#include <string.h>
+#include "pdefs.h"
+#include "precision.h"
+
+#ifdef ASM_16BIT
+#include "asm16bit.h"
+#endif
+
+/*
+ * Divide a precision by 2
+ */
+precision phalf(u)
+ register precision u;
+{
+#ifdef ASM_16BIT
+ register precision w;
+ register posit usize;
+
+ pparm(u);
+ usize = u->size;
+ w = palloc(usize);
+ if (w == pUndef) return w;
+
+ w->sign = u->sign;
+ (void) memcpy(w->value, u->value, usize * sizeof(digit));
+
+ memlsrw(w->value, usize); /* 68000 assembly language routine */
+ if (usize > 1 && w->value[usize-1] == (digit) 0) { /* normalize */
+ --(w->size);
+ }
+ pdestroy(u);
+ return presult(w);
+#else
+ return pdiv(u, ptwo);
+#endif
+}