Discussion:
[hercules-os380] BXLE issue
kerravon86@yahoo.com.au [hercules-os380]
2018-10-11 03:29:23 UTC
Permalink
I believe there is some issue with the BXLE
instruction or something similar that it breaks
down when memory operands are on some
sort of boundary.

What is the issue, and can the issue be
circumvented by MVS/380 not obtaining
storage that spans the 4 GiB or 2 GiB
boundaries? Or not running any programs
as AM31, always use AM32 instead?

Thanks. Paul.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-11 07:57:31 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
I believe there is some issue with the BXLE
instruction or something similar that it breaks
down when memory operands are on some
sort of boundary.
From the z/Arch POP on BXLE I see:

Since the addition and comparison operations performed during the execution of these instructions treat the operands as 32-bit signed binary integers, the value following 2 - 1 is not 2, which cannot be represented in that format, but -2. The instruction does not provide an indication of such overflow. Consequently, some common looping techniques based on the use of these instructions do not work when a data area ends at address 2 - 1. This problem is illustrated in a BRANCH ON INDEX LOW OR EQUAL example in Appendix A, “Number Representation and Instruction-Use Examples.” A similar caution applies in the 64-bit addressing mode when data is at the end of a 64-bit address space and BRANCH ON INDEX HIGH (BXHG) or BRANCH ON INDEX LOW OR EQUAL (BXLEG) is used.


I am surprised that the 64-bit version is at
the end of the 64-bit address space instead
of at the end of the signed 64-bit integer,
ie 2**63 - 1. Given that the POP also says:

For purposes of the addition and comparison, all operands and results are treated as 32-bit signed binary integers for BXH and BXLE or as 64-bit signed binary integers for BXHG and BXLEG.


And in Appendix A they show:

LA 6,GROUP Load first address
LA 8,4 Load increment 4
LA 9,GROUP+39 Load compare value
LOOP NI 3(6),X'FE' AND immediate
BXLE 6,8,LOOP Test end of loop

The technique shown in Example 2 does not work, however, on an ESA/370 system when it is in the 31-bit addressing mode and the data is located at the rightmost end of a 31-bit address space. In this case, the compare value would be set to 2-1, which is the largest possible 32-bit signed binary value. The reason the technique does not work is that the BXLE and BXH instructions treat their operands as 32-bit signed binary integers. When the address in general register 6 reaches the value 2-4, BXLE increments it to a value that is interpreted as -2, rather than 2, and the comparison remains low, which causes looping to continue indefinitely.
This situation can be avoided by not allowing data areas to extend to the rightmost location in a 31-bit address space or by using other technique


So I think that even in AM32, I will have a problem
at the 2 GiB location rather than the 4 GiB
location.

But why does the 2 GiB issue disappear
(I believe) in AM64, even for the 32-bit BXLE
instruction?

BFN. Paul.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-11 09:30:05 UTC
Permalink
Thinking about how C avoids running off
the end of a buff, I think they should have
made a BXL instruction rather than BXLE,
to avoid overflow.

And they should have used unsigned
integers for the addresses, so that the
full 32-bit address space could be
addressed.

I think we need to say that these
instructions cannot be used in 32-bit
programs. GCC doesn't generate
these instructions.

BFN. Paul.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-11 10:08:40 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
I think we need to say that these
instructions cannot be used in 32-bit
programs.
Hercules/380 could have an option to
throw a S0C1 when BXLE is executed
in AM31 or AM32 or AM64.

Or maybe throw an exception if the
addresses go negative. But we really
want consistent results between runs.

BFN. Paul.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-11 10:14:33 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
Hercules/380 could have an option to
throw a S0C1 when BXLE is executed
in AM31 or AM32 or AM64.
Or maybe make the addresses unsigned
when executing in AM32/64 and maybe
AM31 too.

BFN. Paul.
Tony Harminc tharminc@gmail.com [hercules-os380]
2018-10-12 22:43:01 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
Post by ***@yahoo.com.au [hercules-os380]
Hercules/380 could have an option to
throw a S0C1 when BXLE is executed
in AM31 or AM32 or AM64.
Or maybe make the addresses unsigned
when executing in AM32/64 and maybe
AM31 too.
Why not just use BXHG/BXLEG if you might be in anything above 31-bit
mode? Or for any mode for that matter.

Tony H.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-12 23:48:54 UTC
Permalink
Post by Tony Harminc ***@gmail.com [hercules-os380]
Post by ***@yahoo.com.au [hercules-os380]
Or maybe make the addresses unsigned
when executing in AM32/64 and maybe
AM31 too.
Why not just use BXHG/BXLEG if you might be in anything above 31-bit
mode? Or for any mode for that matter.
That's another solution, but will prevent the
module from running on S/370. It is my
intention to produce a universal load module
(like I already am for GCC), but to get
MVS/380 to start giving it memory between
2 GiB and 4 GiB for the LOC=ANY/31
GETMAIN requests.

BFN. Paul.
Mike Schwab Mike.A.Schwab@gmail.com [hercules-os380]
2018-10-13 04:33:54 UTC
Permalink
Java uses the address from 2GB to 32GB on z/OS.
Post by ***@yahoo.com.au [hercules-os380]
Post by Tony Harminc ***@gmail.com [hercules-os380]
Post by ***@yahoo.com.au [hercules-os380]
Or maybe make the addresses unsigned
when executing in AM32/64 and maybe
AM31 too.
Why not just use BXHG/BXLEG if you might be in anything above 31-bit
mode? Or for any mode for that matter.
That's another solution, but will prevent the
module from running on S/370. It is my
intention to produce a universal load module
(like I already am for GCC), but to get
MVS/380 to start giving it memory between
2 GiB and 4 GiB for the LOC=ANY/31
GETMAIN requests.
BFN. Paul.
------------------------------------
------------------------------------
------------------------------------
Yahoo Groups Links
--
Mike A Schwab, Springfield IL USA
Where do Forest Rangers go to get away from it all?
Joe Monk joemonk64@gmail.com [hercules-os380]
2018-10-11 10:14:13 UTC
Permalink
What you're not realizing is that this issue is not limited to BXLE or BXH.
Those are just the example instructions to illustrate an issue.

Most (<95%) programmers will not code the conditions which cause the
problem, so it shouldn't be a concern.

Joe
Post by ***@yahoo.com.au [hercules-os380]
Post by ***@yahoo.com.au [hercules-os380]
I think we need to say that these
instructions cannot be used in 32-bit
programs.
Hercules/380 could have an option to
throw a S0C1 when BXLE is executed
in AM31 or AM32 or AM64.
Or maybe throw an exception if the
addresses go negative. But we really
want consistent results between runs.
BFN. Paul.
kerravon86@yahoo.com.au [hercules-os380]
2018-10-12 01:04:50 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
I think we need to say that these
instructions cannot be used in 32-bit
programs.
Or how about - they should be restricted
to operating on BTL data.

BFN. Paul.
Gerhard Postpischil gerhardp@charter.net [hercules-os380]
2018-10-12 01:16:33 UTC
Permalink
Post by ***@yahoo.com.au [hercules-os380]
Or how about - they should be restricted
to operating on BTL data.
Or else an astute programmer can test beforehand, and add a fudge factor.

Gerhard Postpischil
Bradford, VT

---
This email has been checked for viruses by AVG.
https://www.avg.com
Loading...