Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New Instruction addi "Add-Immediate" #313

Merged
merged 3 commits into from
Aug 12, 2024
Merged

feat: New Instruction addi "Add-Immediate" #313

merged 3 commits into from
Aug 12, 2024

Conversation

aszepieniec
Copy link
Collaborator

This PR adds an instruction addi which takes an immediate argument and adds it to the top of the stack. This addresses a pattern identified by @aszepieniec but with a different solution. The main motivation is to anticipate computing the AIR circuits on an out-of-domain row located at a dynamically known address. The merits of this PR should be considered in combination of future PRs that accomplish that feat.

The word dynamic is key, because the current auto-generated tasm code hardcodes the location of the out-of-domain row to a statically known address. While that solution is more efficient in terms of tasm instruction count, it is also less versatile. In particular, it requires static memory layouts for all proofs to be verified by a program. This requirement makes certain patterns impossible, such as verifying proofs in a dynamic loop.

This instruction reduces the cost of switching to dynamic out-of-domain row locations.

In order to get the right address on top of the stack:

  • with static addresses: push [static_address]
  • with dynamic addresses, before this PR: dup x push [static_offset] add
  • with dynamic addresses, after this PR: dup x addi [static_offset]

@jan-ferdinand jan-ferdinand merged commit 3b5bc12 into master Aug 12, 2024
4 checks passed
@jan-ferdinand jan-ferdinand deleted the asz/addi branch August 12, 2024 12:27
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