summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-09-09 12:45:54 +0200
committerjonsykkel <jonrevold@gmail.com>2021-09-09 12:49:56 +0200
commit8cf5f098d2aaa6c6472184245e3a3c9d56ea2bc2 (patch)
tree71aa6d8ef8f16c17ff8c8d184924816f51e1e027
parent5ea08bdece750c899460c3e9fe2fd88b21a9783f (diff)
downloadokeffa-8cf5f098d2aaa6c6472184245e3a3c9d56ea2bc2.tar.gz
????????
-rw-r--r--prog/ch5_input2
-rw-r--r--src/fz_div.c20
2 files changed, 13 insertions, 9 deletions
diff --git a/prog/ch5_input b/prog/ch5_input
index b4eb594..33ea8d9 100644
--- a/prog/ch5_input
+++ b/prog/ch5_input
@@ -1 +1 @@
-.5.3
+.a260834918391491849184913489195.1938491849184918349183491384913843
diff --git a/src/fz_div.c b/src/fz_div.c
index 8e53c48..7be0989 100644
--- a/src/fz_div.c
+++ b/src/fz_div.c
@@ -5,21 +5,25 @@
#include <okeffa/w_op.h>
void fz_idiv(word_t *a,word_t *b,word_t *q_out,word_t *r_out,size_t len){
- size_t qr_len = len*2;
- size_t bitness = fz_bitness(len);
+ size_t qr_len = len*2;
+ size_t bitness_m1 = fz_bitness(len)-1;
word_t qr[qr_len];
- word_t *q = qr;
- word_t *r = qr+len;
+ word_t *q = qr;
+ word_t *r = qr+len;
+ wbool_t c;
- fz_copy(a,q,len);
- fz_clear(r,len);
- for(size_t x = 0;x < bitness;x++){
- wbool_t c;
+ fz_frombool(r,len,fz_shl_i(a,q,len,1,1));
+ c = fz_sub(r,b,r,len);
+ fz_add_gated(r,b,r,len,c);
+ fz_xor_w(q,c);
+
+ for(size_t x = 0;x < bitness_m1;x++){
fz_shl_i(qr,qr,qr_len,1,1);
c = fz_sub(r,b,r,len);
fz_add_gated(r,b,r,len,c);
fz_xor_w(q,c);
}
+
fz_copy(q,q_out,len);
fz_copy(r,r_out,len);
}