ref: a07a2025dab770421992362d8f4e4acbbf776fa8
parent: 590a4980bcf1ba21b3ddbef032bc4ca0589c840c
author: aiju <devnull@localhost>
date: Mon Aug 8 18:19:29 EDT 2016
document mplogic functions
--- a/sys/man/2/mp
+++ b/sys/man/2/mp
@@ -106,6 +106,27 @@
void mpright(mpint *b, int shift, mpint *res)
.PP
.B
+void mpand(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void mpbic(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void mpor(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void mpnot(mpint *b, mpint *res)
+.PP
+.B
+void mpxor(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void mptrunc(mpint *b, int n, mpint *res)
+.PP
+.B
+void mpxtend(mpint *b, int n, mpint *res)
+.PP
+.B
void mpmul(mpint *b1, mpint *b2, mpint *prod)
.PP
.B
@@ -542,6 +563,42 @@
is not zero, otherwise
.I b2
is assigned to
+.IR res .
+.PD
+.PP
+Logical operations (treating negative numbers using two's complement):
+.TF mpxtend_
+.TP
+.I mpand
+.BR "res = b1 & b2" .
+.TP
+.I mpbic
+.BR "res = b1 & ~b2" .
+.TP
+.I mpor
+.BR "res = b1 | b2" .
+.TP
+.I mpxor
+.BR "res = b1 ^ b2" .
+.TP
+.I mpnot
+.BR "res = ~b1" .
+.TP
+.I mptrunc
+truncates
+.I b
+to
+.I n
+bits and stores the result in
+.IR res .
+The result is never negative.
+.TP
+.I mpxtend
+truncates
+.I b
+to
+.I n
+bits, sign extends the MSB and stores the result in
.IR res .
.PD
.PP