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

Quick parameter storing into local memory #38

Open
HuseyinSimsek7904 opened this issue Jan 30, 2024 · 0 comments
Open

Quick parameter storing into local memory #38

HuseyinSimsek7904 opened this issue Jan 30, 2024 · 0 comments
Assignees
Labels
compiler Anything about the compiler enhancement New feature or request idea

Comments

@HuseyinSimsek7904
Copy link
Member

Right now, all of the procedure arguments are directly pushed to the real stack which later requires it to be moved to a let variable which slows down the program a lot. To solve this, argument storing can be implemented.

Possible syntax:

proc procedure
  int as let arg1     // This is stored to the local memory, and can be accessed like it is a 'let' variable. Immutable.
  int as memory arg2  // This is also stored to the local memory, but it is accessed like it is a 'memory' variable. Mutable.
  int                 // This is pushed directly to the real stack.
in 
  // Real stack now contains only 1 item, and there are two local variables defined named 'arg1' and 'arg2'.
  // 'arg1' will return a value, 'arg2' will return the address of the value.
  ...
end

This may also help make procedure declaration statements clearer as we normally had to write the name and types of the arguments twice for clarity. Normally, writing a procedure that acts like this one would be like:

proc procedure
  // int: arg1 int: arg2 int: arg3
  int int int --
in
  memory arg2 sizeof(int) in
    swp arg2 !64
    // 'arg2' is now stored as a 'memory' argument.

    swp let arg1 in
      // 'arg1' is now stored as a 'let' variable.
      ...
    end
  end
end
@HuseyinSimsek7904 HuseyinSimsek7904 added enhancement New feature or request idea compiler Anything about the compiler labels Jan 30, 2024
@HuseyinSimsek7904 HuseyinSimsek7904 self-assigned this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Anything about the compiler enhancement New feature or request idea
Projects
None yet
Development

No branches or pull requests

1 participant