Skip to content

[BUG] - Variable arguments are all passed on the stack #139

@Jamesbarford

Description

@Jamesbarford

Describe the bug
Variable arguments are all passed on the stack... This breaks interoperability with C

To Reproduce
Use a vargs style holyc function and compile with hcc -S <file_name> inspect the <file_name>.s to see the assembly. The first argument to the function is RDI that is argc which is correct for our purposes. Thus if you were to call from C the first argument would have to be the number of arguments?

Example Program

I64 Something(...)
{
  I64 acc = 0;
  for (I64 i = 0; i < argc; ++i) {
    acc += argv[i](I64);
  }
  return acc;
}

U0 Main()
{
  "%d", Something(1,2,3,4,5);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions