You can probably do this by maintaining two parallel stacks, changes to prologue/epilogue code and runtime startup files.