diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index f4c4343..c236428 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -19,8 +19,9 @@ struct BnT { static inline size_t getUnitSize() { return Fp::op_.N * 2; } void dump() const { - for (size_t i = 0; i < getUnitSize(); i++) { - printf("%016llx ", (long long)v_[i]); + const size_t n = getUnitSize(); + for (size_t i = 0; i < n; i++) { + printf("%016llx ", (long long)v_[n - 1 - i]); } printf("\n"); } diff --git a/src/fp.cpp b/src/fp.cpp index a0a3995..3f11bd5 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -138,7 +138,6 @@ struct OpeFunc { */ static inline void fpDbl_addPC(Unit *z, const Unit *x, const Unit *y, const Unit *p) { -puts("BBB"); Unit ret[N * 2 + 2]; // not N + 1 Unit pDbl[N * 2]; mpz_t mz, mx, my, mp; diff --git a/src/short.txt b/src/short.txt index b340f79..75c0ad2 100644 --- a/src/short.txt +++ b/src/short.txt @@ -56,7 +56,8 @@ entry: %t0 = add i$(b2u) %x1, %y1 ; x + y = [H:L] %t1 = trunc i$(b2u) %t0 to i$(bit) ; t1 = L store i$(bit) %t1, i$(bit)* %pz ; store L - %t2 = shl i$(b2u) %t0, $(bit) + + %t2 = lshr i$(b2u) %t0, $(bit) %H = trunc i$(b2u) %t2 to i$(bu) %p = load i$(bit)* %pp diff --git a/test/fp_tower_test.cpp b/test/fp_tower_test.cpp index ab74fb1..091508e 100644 --- a/test/fp_tower_test.cpp +++ b/test/fp_tower_test.cpp @@ -92,7 +92,6 @@ void testFpDbl() mcl::Gmp::addMod(mo, mx, my, mp); z.getMpz(mz); CYBOZU_TEST_EQUAL(mz, mo); - mcl::Gmp::subMod(mo, mx, my, mp); FpDbl::sub(z, x, y); z.getMpz(mz); @@ -105,8 +104,8 @@ void testFpDbl() void test(const char *p) { printf("prime=%s\n", p); -// Fp::setModulo(p); - Fp::setModulo(p, 0, mcl::fp::FP_LLVM); // QQQ + Fp::setModulo(p); +// Fp::setModulo(p, 0, mcl::fp::FP_LLVM); // QQQ testFp2(); if (Fp::getBitSize() <= 256) { testFpDbl();