From 34a122a0b7701410bc55e7403d5bf21146662142 Mon Sep 17 00:00:00 2001 From: lkcl Date: Mon, 18 Apr 2022 02:54:08 +0100 Subject: [PATCH] --- openpower/sv/bitmanip/appendix.mdwn | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openpower/sv/bitmanip/appendix.mdwn b/openpower/sv/bitmanip/appendix.mdwn index f8ab73aaf..d589f070e 100644 --- a/openpower/sv/bitmanip/appendix.mdwn +++ b/openpower/sv/bitmanip/appendix.mdwn @@ -168,6 +168,24 @@ As a result, a big-integer subtract and multiply may be carried out in only 3 instructions, one of which is setting a scalar integer to zero. +## 2nd experiment + +``` + uint32_t carry = 0, carry2 = 0; + uint64_t products[]; + for(int j = d_bytes / sizeof(d[0]) - 1; j >= 0; j--) { + products[j] = (uint64_t)q[i] * d[j]; + } + for(int j = d_bytes / sizeof(d[0]) - 1; j >= 0; j--) { + uint64_t v = products[j] + carry; + carry = v >> 32; + v = (uint32_t)v; + v = n[i + j] - v + carry2; + carry2 = v >> 32; // either ~0 or 0 + n[i + j] = v; + } +``` + ## EXT004 Opcode map See Power ISA v3.1, Book III, Appendix D, Table 13 (sheet 7 of 8), p1357. -- 2.30.2