This commit is contained in:
Nicholas Ward 2023-03-16 11:39:19 -07:00
parent f1ad3da8eb
commit b62bc35d64
2 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,11 @@
// Compares two bignums of the same given length. Assumes that len > 0.
// Returns 1 if a > b, 0 if a == b, and -1 (that is, 2^256 - 1) if a < b.
global cmp_bignum:
// stack: len, a_start_loc, b_start_loc, retdest
DUP1
// stack: len, len, a_start_loc, b_start_loc, retdest
ISZERO
%jumpi(equal)
// stack: len, a_start_loc, b_start_loc, retdest
SWAP1
// stack: a_start_loc, len, b_start_loc, retdest

View File

@ -171,7 +171,9 @@ fn test_add_bignum(a: BigUint, b: BigUint, expected_output: BigUint) -> Result<(
if carry_limb > 0.into() {
new_memory[len] = carry_limb;
}
let output = mem_vec_to_biguint(&new_memory[a_start_loc..a_start_loc + len]);
let expected_output = biguint_to_mem_vec(expected_output);
let output = &new_memory[a_start_loc..a_start_loc + expected_output.len()];
assert_eq!(output, expected_output);
Ok(())