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

EOF container assembler prototype #148

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

EOF container assembler prototype #148

wants to merge 7 commits into from

Conversation

gumb0
Copy link
Contributor

@gumb0 gumb0 commented May 26, 2024

This is a prototype for emitting EOF container bytecode from assembler.

The following syntax for defining EOF sections is proposed:

section .code
stop

section .code outputs=1
push0
retf

section .code inputs=1 outputs=nonret max_stack_height=2
pop
push0
push0
return

section .data
%include_hex("data.etk")
  • EOF container is generated in case at least one section is defined, otherwise legacy code is generated.
  • Code sections and data section are supported.
  • Code sections may declare their number of inputs/outputs and max stack height (this data goes into EOF type section)
  • Section attributes are optional and by default are inputs=0 outputs=nonret max_stack_height=0
  • outputs=nonret means sections is non-returning.

TODO

  • Each code section should be in a separate scope
  • Test that sections get correct size when variable-size pushes are used
  • max_stack_height may be automatically calculated within a forward pass during assembly

Known issues / limitations:

  • Attributes are allowed for data sections too, but are ignored (probably shoud be disallowed)
  • Attributes can be duplicated, only last mentioned value is used (better should not be allowed)
  • No bounds checking for attribute values, panic when above the limit

Future work for EOF support

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.

1 participant