Skip to content

[Feature] DaedalusVm: Expose Pc (program counter) and UnsafeJump for Ikarus loop control #22

@JaXt0r

Description

@JaXt0r

Ikarus implements its own loop constructs (repeat, while, mem_goto) by redirecting the VM's program counter at runtime. To support these in the C# wrapper, two APIs are needed.

Reference OpenGothic (directmemory.cpp):

vm.override_function("repeat", [this](zenkit::DaedalusVm& vm) {
  // ...
  vm.unsafe_jump(jmp - rp.size); // redirect execution to loop start or exit
});

vm.override_function("while", [this](zenkit::DaedalusVm& vm) {
  const int cond = vm.pop_int();
  if (cond == 0)
	  vm.unsafe_jump(loopBacktrack[vm.pc()] - rp.size);
});

Requested C# API:

  • DaedalusVm.Pc()
  • DaedalusVm.UnsafeJump()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions