From: lkcl Date: Mon, 18 Apr 2022 01:54:08 +0000 (+0100) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~2738 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=34a122a0b7701410bc55e7403d5bf21146662142;p=libreriscv.git --- 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.