From ad75ea5457e64db46c65180a0ae59d89140579f3 Mon Sep 17 00:00:00 2001 From: kadenzipfel Date: Thu, 29 Sep 2022 19:10:15 -0700 Subject: [PATCH 1/3] Remove unnecessary swap --- src/utils/BitPackLib.huff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/BitPackLib.huff b/src/utils/BitPackLib.huff index ba7383c8..c24a34ca 100644 --- a/src/utils/BitPackLib.huff +++ b/src/utils/BitPackLib.huff @@ -10,7 +10,7 @@ #define macro PACK_VALUE() = takes (4) returns (1) { // Input stack: // [length, index, value, word] 0x100 sub sub // [shift, value, word] - shl swap1 or // [new_word] + shl or // [new_word] } /// @notice Unpacks value of given length from right of word From 9d14ee7f0d6f7ba51d1c00a36a9388b913686c2f Mon Sep 17 00:00:00 2001 From: kadenzipfel Date: Thu, 29 Sep 2022 19:40:57 -0700 Subject: [PATCH 2/3] Cleanup comments --- src/utils/BitPackLib.huff | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/BitPackLib.huff b/src/utils/BitPackLib.huff index c24a34ca..628baca3 100644 --- a/src/utils/BitPackLib.huff +++ b/src/utils/BitPackLib.huff @@ -31,13 +31,13 @@ } /// @notice Unpcks value of given length from index of word -/// @dev Assume index < 256 - length +/// @dev Assumes index < 256 - length /// (word & ((~0 >> 256 - length) << (256 - length - index))) >> (256 - length - index) #define macro UNPACK_FROM_CENTER() = takes (3) returns (1) { // Input stack: // [length, index, word] - 0x100 sub // [offset, index, word] - swap1 dup2 sub // [shift, offset, word] - [MAX] swap1 swap2 shr // [offset_shift, shift, word] - dup2 shl swap1 swap2 and // [left_shifted_word, shift] + 0x100 sub // [256 - length, index, word] + swap1 dup2 sub // [256 - length - index, 256 - length, word] + [MAX] swap1 swap2 shr // [~0 >> 256 - length, 256 - length - index, word] + dup2 shl swap1 swap2 and // [(word & ((~0 >> 256 - length) << (256 - length - index))), 256 - length - index] swap1 shr // [value] } From 041f570b5ca8d552a43629ef196bdacb0a1671c7 Mon Sep 17 00:00:00 2001 From: kaden Date: Fri, 30 Sep 2022 08:35:22 -0700 Subject: [PATCH 3/3] Update src/utils/BitPackLib.huff Co-authored-by: Mathis Gontier Delaunay <74971347+MathisGD@users.noreply.github.com> --- src/utils/BitPackLib.huff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/BitPackLib.huff b/src/utils/BitPackLib.huff index 628baca3..8d29ec0a 100644 --- a/src/utils/BitPackLib.huff +++ b/src/utils/BitPackLib.huff @@ -30,7 +30,7 @@ shr // [value] } -/// @notice Unpcks value of given length from index of word +/// @notice Unpacks value of given length from index of word /// @dev Assumes index < 256 - length /// (word & ((~0 >> 256 - length) << (256 - length - index))) >> (256 - length - index) #define macro UNPACK_FROM_CENTER() = takes (3) returns (1) {