-
- while((GET_FBS(a) > rfbs+1) && (a->length_B == r->length_B)){
- bigint_sub_u_bitscale(a, r, GET_FBS(a)-rfbs-1);
+ uint16_t shift;
+ while(a->length_W > r->length_W){
+ shift = (a->length_W - r->length_W) * 8 * sizeof(bigint_word_t) + GET_FBS(a) - rfbs - 1;
+ /*
+ if((a->wordv[a->length_W-1] & ((1LL<<GET_FBS(a)) - 1)) > r->wordv[r->length_W-1]){
+ // cli_putc('~');
+ cli_putstr("\r\n ~ [a] = ");
+ cli_hexdump_rev(&a->wordv[a->length_W-1], 4);
+ cli_putstr(" [r] = ");
+ cli_hexdump_rev(&r->wordv[r->length_W-1], 4);
+ shift += 1;
+ }
+ */
+// cli_putstr("\r\nDBG: (p) shift = "); cli_hexdump_rev(&shift, 2);
+// cli_putstr(" a_len = "); cli_hexdump_rev(&a->length_W, 2);
+// cli_putstr(" r_len = "); cli_hexdump_rev(&r->length_W, 2);
+// uart_flush(0);
+ bigint_sub_u_bitscale(a, r, shift);
+// cli_putstr("\r\nDBG: (1) = "); bigint_print_hex(a);
+ }
+ while((GET_FBS(a) > rfbs) && (a->length_W == r->length_W)){
+ shift = GET_FBS(a)-rfbs-1;
+// cli_putstr("\r\nDBG: (q) shift = "); cli_hexdump_rev(&shift, 2);
+ bigint_sub_u_bitscale(a, r, shift);
+// cli_putstr("\r\nDBG: (2) = "); bigint_print_hex(a);