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

Labels

awaiting verificationThe problem has been fixed, though external verification of this fix is requiredenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions