In response to the original post from: Colin Paice <[email protected]> .................................................................. You might want to consider using a small "glue" code segment like that shown below at start of your function. The basic ideas are:
. The glue code is invoked by the caller in whatever addressing mode the caller chooses. The general expectation is that the caller has done nothing to change the addressing mode when effecting the call. . The glue code does not alter any GPR other than R15 which is used to contain a pure 64-bit address of the desired target code segment. . The glue code uses BAKR to create a Linkage Stack entry with all of the callers GPRs (with the exception of GPR 15) and ARs as they were when the glue code was entered, and effect a transfer of control to the desired target function. . The target function exits via PR which, among other things, restores GPRs 2-14 and ARs 2-14 from the Linkage stack. This PR causes a transfer of control to the instruction immediately following the BAKR. . The glue code returns control to caller in the addressing mode in effect at the time the glue code was entered. There are always going to be unusual situations where this scheme will need to be adjusted. However, I believe that in the great majority of situations (including yours) this will do the job nicely. XGR R15,R15 * In combination these two LARL R15,TARGET * instructions place into * * GPR 15 a pure 64-bit * * address of the function * * to be invoked without * * needing to be aware of * * (or do anything * * explicitly related to) * * the current addressing * * mode. * BAKR 0,R15 Create a Linkage Stack * entry and invoke the target * function without changing * the addressing mode. * BR R14 Return to the caller. * TARGET DC 0D * : * : The code of the intended function being invoked * : by the original caller * : PR , Return to the "glue" code * segment with GPRs 2-14 * and ARs 2-14 restored. * * GPRs 0, 1 and 15 (and the * corresponding ARs) contain * whatever the target * function put into them.
