I have looked, and the answer to this question is certainly not obvious.
And I’d like to use it in some code I’m writing.
When you EXecute a BAL instruction, where is the return address set?
Following the EX instruction, or the BAL instruction?
To test, I wrote this code. Control came back following the EX instruction.
My question would be, “Is this how it works on a mainframe?”
------------- the comment processor certainly doesn’t like asterisks. And messes with formatting. And makes some stuff bold. That’s weird, but okay.
3times … LA … R3,3
EXBAL … EX … R0,BAL
BCT … BCT … R3,EXBAL
EXEX … EX … 0,EXEX
BAL … BAL … 4,BRR4
… DC … H’0’
BRR4 … BR … R4
… DC … H’0’
This ended with a X0C3, not S0C1. and R3 was 0…
my testing, on the z390 simulator, indicates that after EX-BAL,
control comes back following the EX instruction, not the BAL inst.
I assume that’s how it’s supposed to work.
But I don’t have a mainframe to test with.
This is the trace, when the code abended.
EZ390I Trace Table Entry 800FF05A 4400D066 EX
EZ390I Trace Table Entry 800FF066 4540D06C BAL
EZ390I Trace Table Entry 800FF06C 07F4 BR
EZ390I Trace Table Entry 800FF05E 4630D05A BCT
EZ390I Trace Table Entry 800FF05A 4400D066 EX
EZ390I Trace Table Entry 800FF066 4540D06C BAL
EZ390I Trace Table Entry 800FF06C 07F4 BR
EZ390I Trace Table Entry 800FF05E 4630D05A BCT
EZ390I Trace Table Entry 800FF062 4400D062 EX
EZ390E error 11 ABEND PSW=07850600 800FF062 4400D062 EX ABEND S0C3
–
R0-R3 F4F4F4F4800FF000 F4F4F4F400002300 F4F4F4F4F4F4F4F4 F4F4F4F400000000
R4-R7 F4F4F4F4800FF05E F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4
R8-RB F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4 F4F4F4F4F4F4F4F4
RC-RF F4F4F4F4F4F4F4F4 F4F4F4F4800FF000 F4F4F4F400002018 F4F4F4F4800FF000
EZ390E error 12 program aborting due to abend S0C3