Skip to content

fix: correct u8_add modulo 256 calculation#321

Open
MozirDmitriy wants to merge 1 commit intoBitVM:mainfrom
MozirDmitriy:mms
Open

fix: correct u8_add modulo 256 calculation#321
MozirDmitriy wants to merge 1 commit intoBitVM:mainfrom
MozirDmitriy:mms

Conversation

@MozirDmitriy
Copy link
Copy Markdown

Fix logical error in u8_add() function where OP_0 was incorrectly used
instead of proper modulo 256 calculation.

The function now correctly implements (a + b) % 256 by:

  • Adding two u8 values
  • Checking if result >= 256
  • Subtracting 256 when overflow occurs
  • Returning the modulo result

This ensures proper u32 addition behavior when handling byte-level
arithmetic operations.

Copy link
Copy Markdown
Contributor

@sander2 sander2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is correct. I think the op_0 is needed because of the op_drop below. If you remove it, the op_drop would drop the output value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants