modexp uses current_general

This commit is contained in:
Nicholas Ward 2023-06-20 11:56:21 -07:00
parent 39d2237dee
commit 264192aa05
9 changed files with 21 additions and 21 deletions

View File

@ -14,10 +14,10 @@ global add_bignum:
add_loop:
// stack: carry, i, a_cur_loc, b_cur_loc, retdest
DUP4
%mload_kernel_general
%mload_current_general
// stack: b[cur], carry, i, a_cur_loc, b_cur_loc, retdest
DUP4
%mload_kernel_general
%mload_current_general
// stack: a[cur], b[cur], carry, i, a_cur_loc, b_cur_loc, retdest
ADD
ADD
@ -32,7 +32,7 @@ add_loop:
// stack: c[cur] = (a[cur] + b[cur] + carry) % 2^128, carry_new = (a[cur] + b[cur] + carry) // 2^128, i, a_cur_loc, b_cur_loc, retdest
DUP4
// stack: a_cur_loc, c[cur], carry_new, i, a_cur_loc, b_cur_loc, retdest
%mstore_kernel_general
%mstore_current_general
// stack: carry_new, i, a_cur_loc, b_cur_loc, retdest
SWAP2
%increment

View File

@ -14,7 +14,7 @@ addmul_loop:
// stack: carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
DUP4
// stack: b_cur_loc, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
%mload_kernel_general
%mload_current_general
// stack: b[cur], carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
DUP6
// stack: val, b[cur], carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
@ -31,7 +31,7 @@ addmul_loop:
// stack: prod_lo = val * b[cur] % 2^128, prod_hi = (val * b[cur]) // 2^128, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
DUP5
// stack: a_cur_loc, prod_lo, prod_hi, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
%mload_kernel_general
%mload_current_general
// stack: a[cur], prod_lo, prod_hi, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
DUP1
// stack: a[cur], a[cur], prod_lo, prod_hi, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
@ -75,7 +75,7 @@ addmul_loop:
// stack: to_write, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
DUP4
// stack: a_cur_loc, to_write, carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
%mstore_kernel_general
%mstore_current_general
// stack: carry_limb, i, a_cur_loc, b_cur_loc, val, retdest
SWAP1
// stack: i, carry_limb, a_cur_loc, b_cur_loc, val, retdest

View File

@ -32,9 +32,9 @@ ge_loop:
DUP3
DUP3
// stack: a_i_loc, b_i_loc, i, a_i_loc, b_i_loc, retdest
%mload_kernel_general
%mload_current_general
SWAP1
%mload_kernel_general
%mload_current_general
SWAP1
// stack: a[i], b[i], i, a_i_loc, b_i_loc, retdest
%stack (vals: 2) -> (vals, vals)

View File

@ -10,7 +10,7 @@ global isone_bignum:
// stack: len, start_loc, retdest
DUP2
// stack: start_loc, len, start_loc, retdest
%mload_kernel_general
%mload_current_general
// stack: start_val, len, start_loc, retdest
%eq_const(1)
%jumpi(starts_with_one)

View File

@ -17,7 +17,7 @@ iszero_loop:
// stack: cur_loc, end_loc, retdest
DUP1
// stack: cur_loc, cur_loc, end_loc, retdest
%mload_kernel_general
%mload_current_general
// stack: cur_val, cur_loc, end_loc, retdest
%jumpi(neqzero)
// stack: cur_loc, end_loc, retdest

View File

@ -72,7 +72,7 @@ e_zero_return:
PUSH 1
DUP6
// stack: out_loc, 1, len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
%mstore_kernel_general
%mstore_current_general
modexp_loop:
// stack: len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
@ -80,7 +80,7 @@ modexp_loop:
// y := e % 2
DUP3
// stack: e_loc, len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
%mload_kernel_general
%mload_current_general
// stack: e_first, len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
%mod_const(2)
// stack: y = e_first % 2 = e % 2, len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
@ -186,7 +186,7 @@ b_and_e_zero:
// stack: len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
PUSH 1
DUP6
%mstore_kernel_general
%mstore_current_general
%pop10
// stack: retdest
JUMP

View File

@ -31,7 +31,7 @@ modmul_remainder_loop:
DUP3
ADD
// stack: out_loc[i], PI, i, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest
%mstore_kernel_general
%mstore_current_general
// stack: i, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest
%increment
DUP2
@ -79,7 +79,7 @@ modmul_quotient_loop:
DUP3
ADD
// stack: s1[i], PI, i, 2*len, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest
%mstore_kernel_general
%mstore_current_general
// stack: i, 2*len, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest
%increment
DUP2
@ -136,9 +136,9 @@ modmul_check_loop:
// stack: n, i, j, retdest
%stack (l, idx: 2) -> (idx, l, idx)
// stack: i, j, n, i, j, retdest
%mload_kernel_general
%mload_current_general
SWAP1
%mload_kernel_general
%mload_current_general
SWAP1
// stack: mem[i], mem[j], n, i, j, retdest
%assert_eq

View File

@ -20,7 +20,7 @@ mul_loop:
// stack: mul_addmul_return, n, len, a_start_loc, bi, output_cur, retdest
DUP5
// stack: bi, mul_addmul_return, n, len, a_start_loc, bi, output_cur, retdest
%mload_kernel_general
%mload_current_general
// stack: b[i], mul_addmul_return, n, len, a_start_loc, bi, output_cur, retdest, b
DUP5
// stack: a_start_loc, b[i], mul_addmul_return, n, len, a_start_loc, bi, output_cur, retdest, b
@ -37,7 +37,7 @@ mul_addmul_return:
// stack: len, output_cur, carry_limb, n, len, a_start_loc, bi, output_cur, retdest
ADD
// stack: output_cur + len, carry_limb, n, len, a_start_loc, bi, output_cur, retdest
%mstore_kernel_general
%mstore_current_general
// stack: n, len, a_start_loc, bi, output_cur, retdest
%decrement
// stack: n-1, len, a_start_loc, bi, output_cur, retdest

View File

@ -22,7 +22,7 @@ shr_loop:
// stack: i, carry, start_loc, retdest
DUP1
// stack: i, i, carry, start_loc, retdest
%mload_kernel_general
%mload_current_general
// stack: a[i], i, carry, start_loc, retdest
DUP1
// stack: a[i], a[i], i, carry, start_loc, retdest
@ -40,7 +40,7 @@ shr_loop:
// stack: carry << 127 | a[i] >> 1, i, new_carry, start_loc, retdest
DUP2
// stack: i, carry << 127 | a[i] >> 1, i, new_carry, start_loc, retdest
%mstore_kernel_general
%mstore_current_general
// stack: i, new_carry, start_loc, retdest
DUP1
// stack: i, i, new_carry, start_loc, retdest