Skip to content

Commit 2ee15dd

Browse files
committed
Document origins of the multiplication method being used here.
1 parent 5af23aa commit 2ee15dd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/riscv.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
intrinsics! {
2-
// Implementation from gcc
2+
// Ancient Egyptian/Ethiopian/Russian multiplication method
3+
// see https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication
4+
//
5+
// This is a long-available stock algorithm; e.g. it is documented in
6+
// Knuth's "The Art of Computer Programming" volume 2 (under the section
7+
// "Evaluation of Powers") since at least the 2nd edition (1981).
8+
//
9+
// The main attraction of this method is that it implements (software)
10+
// multiplication atop four simple operations: doubling, halving, checking
11+
// if a value is even/odd, and addition. This is *not* considered to be the
12+
// fastest multiplication method, but it may be amongst the simplest (and
13+
// smallest with respect to code size).
14+
//
15+
// for reference, see also implementation from gcc
316
// https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c
417
pub extern "C" fn __mulsi3(a: u32, b: u32) -> u32 {
518
let (mut a, mut b) = (a, b);

0 commit comments

Comments
 (0)