Skip to content

Large stack #356

Description

@cardillan

As of 3.18, Mindcode supports an internal and an external stack. With Mindustry Build 160, the external stack can store any value, and recursive programs using external stack are fully functional without any limitations placed on values stored on stack. Performance-wise, internal and external stacks are very similar, but with just a single memory bank, an external stack already has more capacity than an internal stack could ever have (each variable put on stack requires at least two instructions per stack frame with internal stack).

A natural extension is to use an array of memory cells/memory banks for an external stack. Switching between storage blocks would be done at the beginnings and ends of recursive functions instead of at every push/pop instruction.

All the required infrastructure is already there (ability to declare arrays of linked blocks, plus instrumentation of bodies of recursive functions). This could probably be done quite easily, and is planned for Mindcode 3.20.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.20Planned for Mindcode 3.20enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions