Add an internal-representation no-op function.
[u/mdw/catacomb] / mpscan.c
index cbfd138..0a5b4f0 100644 (file)
--- a/mpscan.c
+++ b/mpscan.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mpscan.c,v 1.2 1999/11/13 01:55:10 mdw Exp $
+ * $Id: mpscan.c,v 1.3 2000/07/29 17:03:31 mdw Exp $
  *
  * Sequential bit scan of multiprecision integers
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mpscan.c,v $
+ * Revision 1.3  2000/07/29 17:03:31  mdw
+ * Add support for left-to-right bitscanning, for use in modular
+ * exponentiation.
+ *
  * Revision 1.2  1999/11/13 01:55:10  mdw
  * Fixed so that they compile.  Minor interface changes.
  *
@@ -42,7 +46,7 @@
 
 #include "mpscan.h"
 
-/*----- Main code ---------------------------------------------------------*/
+/*----- Right-to-left scanning --------------------------------------------*/
 
 /* --- @mpscan_initx@ --- *
  *
@@ -86,4 +90,48 @@ int mpscan_step(mpscan *m) { return (MPSCAN_STEP(m)); }
 
 int mpscan_bit(const mpscan *m) { return (MPSCAN_BIT(m)); }
 
+/*----- Left-to right-scanning --------------------------------------------*/
+
+/* --- @mpscan_rinitx@ --- *
+ *
+ * Arguments:  @mpscan *m@ = pointer to bitscanner structure
+ *             @const mpw *v, *vl@ = vector of words to scan
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes a reverse bitscanner from a low-level
+ *             vector-and-length representation of an integer.  Initially no
+ *             bit is ready; you must call @mpscan_rstep@ before anything
+ *             useful will come out.
+ */
+
+void mpscan_rinitx(mpscan *m, const mpw *v, const mpw *vl)
+{
+  MPSCAN_RINITX(m, v, vl);
+}
+
+/* --- @mpscan_rstep@ --- *
+ *
+ * Arguments:  @mpscan *m@ = pointer to bitscanner
+ *
+ * Returns:    Nonzero if there is another bit to read.
+ *
+ * Use:                Steps on to the next bit in the integer.  The macro version
+ *             evaluates its argument multiple times.
+ */
+
+int mpscan_rstep(mpscan *m) { return (MPSCAN_RSTEP(m)); }
+
+/* --- @mpscan_rbit@ --- *
+ *
+ * Arguments:  @const mpscan *m@ = pointer to bitscanner
+ *
+ * Returns:    The value of the current bit.
+ *
+ * Use:                Reads the value of the current bit looked at by a
+ *             reverse bitscanner.
+ */
+
+int mpscan_rbit(const mpscan *m) { return (MPSCAN_RBIT(m)); }
+
 /*----- That's all, folks -------------------------------------------------*/