Ref:  Your note of Wed, 26 Jun 2019 09:43:30 -0400

If you have the linkage stack available and storage containing
the information needed to resume (such as an SDWA or copy) then
I think it is possible to create code to resume (at least in
problem state) at a chosen address with all registers containing
their original values, original PSW ASC mode, AMODE, condition
code and program mask, using BAKR and PR.

I originally wrote some code like this in the 1990s to implement
a sort of problem-state "must complete" where the original code
could be resumed for a few instructions from the recovery
routine, and when it turned off "must complete" it would return
control to the recovery routine. However, it was never used in
production, and I'm not sure whether it was even tested, so
this method comes with no guarantees.

Basically, you set up the registers that are returned by PR, put
the resume address in a register that isn't returned by PR,
issue BAKR to save the resume address, restore the other
registers and issue PR to resume. However, if you want to do it
properly with condition code, ASC mode and so on, it's quite
tricky.

- Start in primary mode with R1 pointing to the SDWA.

- Load access registers 2 through 14 (using one of the
  other registers to address that SDWA section).

- Load general registers R2 through R14.

- Get the program mask (with CC) and ASC mode in R15.

- Get the PSW address and AMODE indicator bits in R0 (because R1
  and R15 are still needed).

- Use SAC to set the ASC mode and SPM to set program mask.

- Copy the PSW instruction address and AMODE from R0 to R15.

- Issue BAKR R15,0 to stack the PSW and registers R2 to R14.

- Switch back to primary mode to access SDWA again.

- Get the program mask again in R15.

- Repeat the SPM in case PR doesn't restore the condition code
  (it is undefined whether PR restores the condition code, but
  it seems reasonable to assume it either takes the stacked
  one or preserves the current one).

- Load access registers 15 through 1 from the SDWA, using some
  other register to address the relevant part.

- Load general registers R15 through R1.

- Issue PR to resume execution with original state restored.

I hope I've remembered that correctly!  I probably have some
code around somewhere to do that, but I can't remember where.

Jonathan Scott, HLASM
IBM Hursley, UK

Reply via email to