Skip to content

Memory Size #3

Description

@asdfjkl

I wonder whether there is a bug in the machine implementation (or maybe I am confusing something).

  • the instruction pointer points to (absolute) offsets, i.e. for next() and prev() it is increased by sizeof(int32_t). Since it is a pointer of type int32, the pointer is internally increased by sizeof(int32_t) * sizeof(int32_t).
  • memory is allocated by memory(new int32_t[memsize]), but memsize itself is initialized as memsize(10001024sizeof(int32_t)),

Therefore I think you are using sizeof(int32_t) more memory than actually required. I think there are two ways to resolve this:

  • a) decrease memory size and access memory contents by memory[ip/4]
  • b) decrease memory size and access memory contents by manual computation of the offset of the allocated memory unsigned int* offset = (unsigned int*) ((unsigned char *) memory + ip);

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions