There's more than one implementation; they all <crosses fingers> enforce the semantics. Again, what call by value is all about is that the caller's variable in not altered, regardless of how the compiler enforces that. The whole shtick with R1 and DSA is not part of the semantics.
________________________________________ From: IBM Mainframe Discussion List <[email protected]> on behalf of Bernd Oppolzer <[email protected]> Sent: Monday, March 27, 2023 7:10 AM To: [email protected] Subject: Re: ASM call by value Implementation enforces semantics in this case ... The C implementation (on z/OS at least, but IMO on other platforms as well) builts a reg1 parameter list and puts the "value parms" there. With C on z/OS, the reg1 parameter list resides on the "stack", which is addressed by reg 13 in the caller's DSA, so that the whole process remains reentrant. Then the called prog can, if it wants, change the passed values, which are in fact local variables, as seen be the called prog. But nothing is changed from the perspective of the caller. This is what call by value is about. The ASSEMBLER call macro supports this, but only for integer parms, and not for parameter lists which dont reside in the caller's CSECT. So we have two issues here: - no "larger" data types supported - no support for the reentrant case HTH, kind regards Bernd Am 27.03.2023 um 12:57 schrieb Seymour J Metz: > No. Don't confuse semantics with implementation. Call by value means that the > called routine can't change the parameter. Whether the compiler passes the > address or not, it will not allow assignments to a call by value parameter. > > Just be glad that you don't have to deal with call by name. > > ________________________________________ > From: IBM Mainframe Discussion List <[email protected]> on behalf of > Bernd Oppolzer <[email protected]> > Sent: Monday, March 27, 2023 2:49 AM > To: [email protected] > Subject: Re: ASM call by value > > Sorry that I post to the original question; > that's because most of the answers so far missed the point. > > Call by value means that a value is passed to the caller; > call by reference means that a reference (technically: an address) is > passed to the caller. > > In ASSEMBLER: > > CALL SUBPROG,(A,B,C),VL > > sends address constants of fields A, B and C to the caller (via reg1 > address list), > so that is always call by reference. > > You can instead send an integer constant to the caller using CALL or a > register: > > CALL SUBPROG,(1024,(R3)) > > with the integer constant, this sure is call by value, but you are > limited to integer arguments. > With the register argument, it depends on what is contained in the > register; > if it is an address, you have call by reference again. > > The only real "call by value" I can see here is the case where an > integer constant is part > of the reg1 parameter list (the 1024 constant above); and this is what C > technically does > in the "call by value" case. If C passes larger values "call by value", > it copies them in the > reg1 parameter list. This CANNOT BE DONE using the CALL macro. And this > would be > the correct answer to the original question. > > HTH, > kind regards > > Bernd > > > Am 26.03.2023 um 23:35 schrieb Frank Swarbrick: >> Can the MVS CALL macro be used to call a C function with "value" parameters >> (rather than reference parameters)? >> >> >> ---------------------------------------------------------------------- >> For IBM-MAIN subscribe / signoff / archive access instructions, >> send email to [email protected] with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
