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

Refactor i/o assembly instructions #84

Closed
bobbinth opened this issue Jan 27, 2022 · 3 comments
Closed

Refactor i/o assembly instructions #84

bobbinth opened this issue Jan 27, 2022 · 3 comments
Assignees
Labels
assembly Related to Miden assembly

Comments

@bobbinth
Copy link
Contributor

As discussed in #44 and in #73 we should refactor i/o assembly operations to follow the what.where format and also add new operations for handling memory-based local variables. Overall, the new i/o instruction set should be as follows:

Pushing values onto the stack:

  • push.xyz - similar to current push but should allow pushing multiple values (up to 8). For example, the following should be valid: push.1, push.1.2, push.1.2.0x3 etc.
  • pushw.0x... - this should push a single 32-byte value provided in hexadecimal format. Semantically, this should be equivalent to push.a.b.c.d where a is the first 8 bytes of the value, b is the next 8 bytes etc. (although, maybe we should reverse the order?).
  • push.evn.sdepth
  • pushw.mem.addr
  • pushw.local.idx where idx is the index of the local variable. using this instruction outside of a procedure should be an error.
  • push.adv.n where n can be up to 8.

Removing values from the stack:

  • popw.mem.addr
  • popw.local.idx where idx is the index of the local variable. using this instruction outside of a procedure should be an error.

Overwriting values on the stack:

  • loadw.mem.addr
  • loadw.local.idx where idx is the index of the local variable. using this instruction outside of a procedure should be an error.
  • loadw.adv

Save stack values without removing them:

  • storew.mem.addr
  • storew.local.idx where idx is the index of the local variable. using this instruction outside of a procedure should be an error.

To enable handling locals, we'll also need to update procedure parsers. The new procedure declaration format should include an optional specifier for the number of memory-based locals the procedure can access. For example:

proc.foo.2   # needs access to 2 memory-based locals
proc.bar     # same as proc.bar.0

If code within a procedure tries to access a local outside of the specified bounds, the assembler should return an error.

@bobbinth
Copy link
Contributor Author

bobbinth commented Feb 2, 2022

I updated assembly specs to reflect the above changes. One thing I changes: I got ride of pushw and allowed removing periods between values in hexadecimal format: https://hackmd.io/YDbjUVHTRn64F4LPelC-NA?#Constant-inputs.

Also, increased the maximum value of the parameter for push.adv to 16.

@grjte
Copy link
Collaborator

grjte commented Feb 6, 2022

I'm updating this in 4 stages:

  • 1. refactor i/o operations to "what.where" format + update tests (no change to how push is handled for constants)
  • 2. update push handling for constants to the new specs + update tests for push with constant inputs
  • 3. add handling for locals (io_ops + procedure parsers) + add tests
  • 4. add integration tests to the processor for io operations

@bobbinth
Copy link
Contributor Author

Closed by #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assembly Related to Miden assembly
Projects
None yet
Development

No branches or pull requests

2 participants