Take as an easy example a C function which gets two double parms and
builts the sum:
double sum (double x, double y)
{
return x + y;
}
there you have register 1 pointing at an address list (which should be
called parameter list in this case);
the first double is at 0(r1), and the second double is at 8(r1). The
VALUEs of the doubles are passed,
not the addresses.
You cannot call this function using the ASSEMBLER CALL macro. No chance.
Kind regards
Bernd
Am 27.03.2023 um 13:10 schrieb Bernd Oppolzer:
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 <IBM-MAIN@LISTSERV.UA.EDU> on
behalf of Bernd Oppolzer <bernd.oppol...@t-online.de>
Sent: Monday, March 27, 2023 2:49 AM
To: IBM-MAIN@LISTSERV.UA.EDU
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 lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN