code: function montReduce(x) {
    var x_array = x.array;
    while(x.t <= this.mt2)	// pad x so am has enough room later
      x_array[x.t++] = 0;
    for(var i = 0; i < this.m.t; ++i) {
      // faster way of calculating u0 = x[i]*mp mod DV
      var j = x_array[i]&0x7fff;
      var u0 = (j*this.mpl+(((j*this.mph+(x_array[i]>>15)*this.mpl)&this.um)<<15))&BI_DM;
      // use am to combine the multiply-shift-add into one call
      j = i+this.m.t;
      x_array[j] += this.m.am(0,u0,x,i,0,this.m.t);
      // propagate carry
      while(x_array[j] >= BI_DV) { x_array[j] -= BI_DV; x_array[++j]++; }
    }
    x.clamp();
    x.drShiftTo(this.m.t,x);
    if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
  }
docs: x = x/R mod m (HAC 14.32)